1. Go to this page and download the library: Download adaiasmagdiel/meta-ai-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adaiasmagdiel / meta-ai-api example snippets
use AdaiasMagdiel\MetaAI\Client;
$client = new Client();
$response = $client->prompt("What's the date and weather in Itaituba, Pará, today?");
echo $response->message . PHP_EOL;
use AdaiasMagdiel\MetaAI\Client;
$client = new Client();
$response = $client->prompt("Tell me about the latest tech news.", stream: true);
foreach ($response as $chunk) {
var_dump($chunk);
}
use AdaiasMagdiel\MetaAI\Client;
$client = new Client();
// Send a prompt to the API with streaming enabled
$response = $client->prompt(
"Who is Bruce Wayne?",
stream: true
);
// Initialize line counter
$lines = 0;
// Iterate over the response stream
foreach ($response as $chunk) {
// Move cursor to top of previous lines, if necessary
$esc = $lines > 0 ? "\x1B[{$lines}F" : "\r";
// Format message to 75 characters per line
$message = wordwrap($chunk->message, 75, "\n", true);
// Display message in terminal
echo $esc . $message;
flush(); // Ensure output is displayed immediately
// Update line counter
$lines = substr_count($message, "\n");
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.