1. Go to this page and download the library: Download aisdk/mistral 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/ */
aisdk / mistral example snippets
use AiSdk\Generate;
use AiSdk\Mistral;
$result = Generate::text()
->model(Mistral::model('mistral-large-latest'))
->instructions('Write short, clear answers.')
->prompt('Explain closures in PHP.')
->run();
echo $result->text;
Generate::model(Mistral::model('mistral-large-latest'));
$result = Generate::text('Explain closures in PHP.')->run();
use AiSdk\Generate;
use AiSdk\Mistral;
$stream = Generate::text('Tell me a story.')
->model(Mistral::model('mistral-large-latest'))
->stream();
foreach ($stream->chunks() as $chunk) {
echo $chunk;
}
$result = $stream->run();
use AiSdk\Generate;
use AiSdk\Mistral;
use AiSdk\Schema;
$result = Generate::text()
->model(Mistral::model('mistral-large-latest'))
->prompt('Extract the city and country from: Lahore, Pakistan.')
->output(Schema::object(
name: 'address',
properties: [
Schema::string(name: 'city')->
use AiSdk\Generate;
use AiSdk\Mistral;
use AiSdk\Schema;
use AiSdk\Tool;
$weather = Tool::make('weather', 'Get current weather')
->input(Schema::string(name: 'city')->er in Lahore?')
->tool($weather)
->run();