1. Go to this page and download the library: Download modelflow-ai/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/ */
modelflow-ai / mistral example snippets
use ModelflowAi\Mistral\Mistral;
$client = Mistral::client('your-api-key');
$chat = $client->chat();
// Create a chat conversation
$parameters = [
'model' => 'mistral-medium',
'messages' => [
[
'role' => 'system',
'content' => 'You are a helpful assistant.'
],
[
'role' => 'user',
'content' => 'Who won the world series in 2020?'
]
]
];
$response = $chat->create($parameters);
// The response is an instance of CreateResponse
echo $response->id;
$embeddings = $client->embeddings();
// Generate embeddings for your data
$parameters = [
'model' => 'mistral-medium',
'texts' => ['text1', 'text2']
];
$response = $embeddings->create($parameters);
// The response is an instance of CreateResponse
echo $response->id;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.