README

A lightweight PSR-17/PSR-18 client for the current Mistral AI API, with examples for
every exposed SDK method, SSE streaming, streamed multipart uploads, structured errors, and optional response wrappers.
Requirements
- PHP 8.2.35+, 8.3.36+, 8.4.27+, 8.5.12+, or 8.6.x. Earlier patch releases in each branch are not supported.
CI tests PHP 8.2.35 with lowest dependencies and the latest PHP 8.5 release with current dependencies.
PHP 8.6 is an experimental, non-blocking job.
- A PSR-17 request, stream, and URI factory.
- A PSR-18 HTTP client.
- The JSON extension.
Guzzle is used below because it provides both the PSR-17 factories and a PSR-18 client implementation. The SDK itself depends only on the PSR interfaces, so other compliant implementations remain supported.
Installation
composer require softcreatr/php-mistral-ai-sdk guzzlehttp/guzzle
Client Setup
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use SoftCreatR\MistralAI\MistralAI;
$factory = new HttpFactory();
$mistral = new MistralAI(
requestFactory: $factory,
streamFactory: $factory,
uriFactory: $factory,
httpClient: new Client(['stream' => true]),
apiKey: (string) getenv('MISTRAL_API_KEY'),
);
Keep API keys on the server and out of source control.
Chat Completions
use const JSON_THROW_ON_ERROR;
$response = $mistral->createChatCompletion([
'model' => 'mistral-small-latest',
'messages' => [
['role' => 'user', 'content' => 'Give me a one-sentence summary of PSR-18.'],
],
]);
$result = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);
echo $result['choices'][0]['message']['content'];
Endpoint methods return a PSR-7 ResponseInterface, including calls that deliver SSE events to a callback.
Arguments
Body-only endpoints use a single body array:
$mistral->createEmbedding([
'model' => 'mistral-embed',
'input' => 'A sentence to embed.',
]);
For endpoints with path parameters, a single combined array is the preferred form. Path fields are separated from
the request body using the endpoint template:
$mistral->updateAgent([
'agent_id' => 'ag_abc123',
'description' => 'Updated description',
]);
Use separate parameter and body arrays when an endpoint needs both query parameters and a request body:
$mistral->updateAgent(
['agent_id' => 'ag_abc123'],
['description' => 'Updated description'],
);
For bodyless endpoints, non-path values become RFC 3986 query parameters. Endpoints that declare a JSON body,
including managed-index document deletion, keep that body separate from path and query parameters. Path parameter
values are URL encoded. The explicit form is available when method names are determined at runtime:
$response = $mistral->request(
'listFiles',
['page' => 0, 'page_size' => 20],
customHeaders: ['X-Trace-Id' => 'trace_abc123'],
);
Streaming
Set stream to true and pass a callback. The decoder supports arbitrarily split chunks, CRLF and LF delimiters, comments, multiline data fields, final unterminated frames, and [DONE].
$mistral->createChatCompletion(
[
'model' => 'mistral-small-latest',
'messages' => [['role' => 'user', 'content' => 'Write a short haiku about PHP.']],
'stream' => true,
],
static function (array $event): void {
echo $event['choices'][0]['delta']['content'] ?? '';
},
);
An ordinary JSON response is still returned when a callback is supplied without requesting an SSE stream. Inherently streaming endpoints select a StreamingClientInterface transport without requiring a body flag.
File Uploads
Multipart endpoints accept readable local file paths. Files are copied as raw bytes into a temporary stream rather than being base64 encoded or assembled in one large PHP string.
$response = $mistral->uploadFile([
'file' => __DIR__ . '/batch.jsonl',
'purpose' => 'batch',
]);
Nested non-file values are encoded using bracket notation.
Errors
4xx and 5xx responses throw MistralAIException. The exception keeps the parsed API error, raw response body, response headers, status code, and x-request-id for diagnostics.
use SoftCreatR\MistralAI\Exception\MistralAIException;
try {
$mistral->retrieveModel(['model_id' => 'missing-model']);
} catch (MistralAIException $exception) {
error_log(sprintf(
'Mistral AI request %s failed (%d): %s',
$exception->getRequestId() ?? 'unknown',
$exception->getCode(),
$exception->getMessage(),
));
}
PSR-18 transport failures are wrapped in MistralAIException and retain the original exception as getPrevious().
Response Handling
Response helpers are optional. Endpoint methods still return raw PSR-7 responses; no DTO conversion or payload
validation is applied unless your application requests it.
use SoftCreatR\MistralAI\Response\JsonResponse;
use SoftCreatR\MistralAI\Response\ChatCompletionResponse;
$json = JsonResponse::fromResponse($response);
$data = $json->toArray();
$requestId = $json->getRequestId();
$completion = ChatCompletionResponse::fromJsonResponse($json);
echo $completion->getOutputText();
JsonResponse snapshots the original body and retains the HTTP response, headers, unknown fields, and raw JSON.
Seekable streams are read without changing their position. Non-seekable streams are consumed, so wrap those
responses before reading them elsewhere. map() receives the decoded array; mapJson() receives the unchanged
JSON string and preserves JSON distinctions such as objects versus arrays.
ChatCompletionResponse exposes id, model, choices, and usage. getOutputText() reads the first alternative,
accepts string or text-chunk content, and ignores reasoning and unknown chunk types. Pass a choice index to read a
different alternative. getFinishReason() exposes the provider's reason without hiding truncation or tool calls.
The DTO checks the common envelope and recognized fields it reads; it is not a complete API-schema validator.
Unknown fields and finish reasons remain available through toArray().
Optional Validation
JSONPayloadContract can validate application-specific JSON
contracts and map results to your own DTOs. It is a suggested dependency, not a runtime requirement of the SDK.
Install it explicitly on PHP 8.3 or newer:
composer require softcreatr/json-payload-contract:^1.0
php examples/response-handling/withJsonPayloadContract.php
The offline example validates the completion's finish reason and the generated JSON before constructing a typed
application DTO. Use Mistral's response_format for structured generation, and validate generated values before
using them in your application. SSE callbacks remain plain event arrays; contracts can be applied selectively.
Examples
Examples load the ignored project-level .env through examples/MistralAIFactory.php:
cp .env.example .env
php examples/chat/createChatCompletion.php
Administration examples use MISTRAL_ADMIN_API_KEY. Resource-specific examples read IDs from the variables
documented in .env.example. Fixtures for files, audio, and OCR are under examples/fixtures; the optional mapper
uses a local chat-completion fixture without making an API call. Review resource creation, uploads, cancellation,
deletion, role assignment, and authentication examples before running them. Realtime session responses contain
short-lived client secrets and must not be published or logged.
Skills use JSON definitions with Markdown bodies loaded from examples/fixtures/skills/basic-math/SKILL.md.
Audio examples use the current Voxtral transcription models;
availability depends on your account's access to the selected model.
Supported Methods
The catalog follows the current Mistral AI API reference. Beta endpoints remain grouped by their documented API area, and the v2 Prompts and Skills routes use their endpoint-specific base path automatically.
Chat
| SDK method |
HTTP route |
Request body |
Example |
createChatCompletion |
POST /v1/chat/completions |
json |
PHP |
FIM
| SDK method |
HTTP route |
Request body |
Example |
createFimCompletion |
POST /v1/fim/completions |
json |
PHP |
Embeddings
| SDK method |
HTTP route |
Request body |
Example |
createEmbedding |
POST /v1/embeddings |
json |
PHP |
Classifiers
| SDK method |
HTTP route |
Request body |
Example |
createModeration |
POST /v1/moderations |
json |
PHP |
createChatModeration |
POST /v1/chat/moderations |
json |
PHP |
createClassification |
POST /v1/classifications |
json |
PHP |
createChatClassification |
POST /v1/chat/classifications |
json |
PHP |
OCR
| SDK method |
HTTP route |
Request body |
Example |
createOcr |
POST /v1/ocr |
json |
PHP |
Audio
| SDK method |
HTTP route |
Request body |
Example |
listVoices |
GET /v2/audio/voices |
none |
PHP |
createSpeech |
POST /v1/audio/speech |
json |
PHP |
createAudioTranscription |
POST /v1/audio/transcriptions |
multipart |
PHP |
createAudioTranscriptionStream |
POST /v1/audio/transcriptions |
multipart |
PHP |
createVoice |
POST /v1/audio/voices |
json |
PHP |
deleteVoice |
DELETE /v1/audio/voices/{voice_id} |
none |
PHP |
updateVoice |
PATCH /v1/audio/voices/{voice_id} |
json |
PHP |
getVoice |
GET /v1/audio/voices/{voice_id} |
none |
PHP |
getVoiceSampleAudio |
GET /v1/audio/voices/{voice_id}/sample |
none |
PHP |
Realtime
| SDK method |
HTTP route |
Request body |
Example |
createClientSession |
POST /v1/client/sessions |
json |
PHP |
Models
| SDK method |
HTTP route |
Request body |
Example |
listModels |
GET /v1/models |
none |
PHP |
retrieveModel |
GET /v1/models/{model_id} |
none |
PHP |
deleteModel |
DELETE /v1/models/{model_id} |
none |
PHP |
updateFineTunedModel |
PATCH /v1/fine_tuning/models/{model_id} |
json |
PHP |
archiveModel |
POST /v1/fine_tuning/models/{model_id}/archive |
none |
PHP |
unarchiveModel |
DELETE /v1/fine_tuning/models/{model_id}/archive |
none |
PHP |
Agents
| SDK method |
HTTP route |
Request body |
Example |
createAgent |
POST /v1/agents |
json |
PHP |
listAgentPages |
GET /v1/agents/pages |
none |
PHP |
retrieveAgent |
GET /v1/agents/{agent_id} |
none |
PHP |
updateAgent |
PATCH /v1/agents/{agent_id} |
json |
PHP |
deleteAgent |
DELETE /v1/agents/{agent_id} |
none |
PHP |
updateAgentVersion |
PATCH /v1/agents/{agent_id}/version |
none |
PHP |
listAgentVersions |
GET /v1/agents/{agent_id}/versions |
none |
PHP |
retrieveAgentVersion |
GET /v1/agents/{agent_id}/versions/{version} |
none |
PHP |
upsertAgentVersionAlias |
PUT /v1/agents/{agent_id}/aliases |
none |
PHP |
listAgentVersionAliases |
GET /v1/agents/{agent_id}/aliases |
none |
PHP |
deleteAgentVersionAlias |
DELETE /v1/agents/{agent_id}/aliases |
none |
PHP |
Conversations
| SDK method |
HTTP route |
Request body |
Example |
startConversation |
POST /v1/conversations |
json |
PHP |
listConversations |
GET /v1/conversations |
none |
PHP |
retrieveConversation |
GET /v1/conversations/{conversation_id} |
none |
PHP |
deleteConversation |
DELETE /v1/conversations/{conversation_id} |
none |
PHP |
appendConversation |
POST /v1/conversations/{conversation_id} |
json |
PHP |
listConversationHistory |
GET /v1/conversations/{conversation_id}/history |
none |
PHP |
listConversationMessages |
GET /v1/conversations/{conversation_id}/messages |
none |
PHP |
restartConversation |
POST /v1/conversations/{conversation_id}/restart |
json |
PHP |
startConversationStream |
POST /v1/conversations |
json |
PHP |
appendConversationStream |
POST /v1/conversations/{conversation_id} |
json |
PHP |
restartConversationStream |
POST /v1/conversations/{conversation_id}/restart |
json |
PHP |
Files
| SDK method |
HTTP route |
Request body |
Example |
uploadFile |
POST /v1/files |
multipart |
PHP |
listFiles |
GET /v1/files |
none |
PHP |
retrieveFile |
GET /v1/files/{file_id} |
none |
PHP |
deleteFile |
DELETE /v1/files/{file_id} |
none |
PHP |
downloadFile |
GET /v1/files/{file_id}/content |
none |
PHP |
retrieveFileSignedUrl |
GET /v1/files/{file_id}/url |
none |
PHP |
Batch
| SDK method |
HTTP route |
Request body |
Example |
listBatchJobs |
GET /v1/batch/jobs |
none |
PHP |
createBatchJob |
POST /v1/batch/jobs |
json |
PHP |
retrieveBatchJob |
GET /v1/batch/jobs/{job_id} |
none |
PHP |
deleteBatchJob |
DELETE /v1/batch/jobs/{job_id} |
none |
PHP |
cancelBatchJob |
POST /v1/batch/jobs/{job_id}/cancel |
none |
PHP |
Libraries
| SDK method |
HTTP route |
Request body |
Example |
listLibraries |
GET /v1/libraries |
none |
PHP |
createLibrary |
POST /v1/libraries |
json |
PHP |
retrieveLibrary |
GET /v1/libraries/{library_id} |
none |
PHP |
deleteLibrary |
DELETE /v1/libraries/{library_id} |
none |
PHP |
patchLibrary |
PATCH /v1/libraries/{library_id} |
json |
PHP |
Libraries / Documents
| SDK method |
HTTP route |
Request body |
Example |
listLibraryDocuments |
GET /v1/libraries/{library_id}/documents |
none |
PHP |
uploadLibraryDocument |
POST /v1/libraries/{library_id}/documents |
multipart |
PHP |
retrieveLibraryDocument |
GET /v1/libraries/{library_id}/documents/{document_id} |
none |
PHP |
patchLibraryDocument |
PATCH /v1/libraries/{library_id}/documents/{document_id} |
json |
PHP |
deleteLibraryDocument |
DELETE /v1/libraries/{library_id}/documents/{document_id} |
none |
PHP |
retrieveLibraryDocumentTextContent |
GET /v1/libraries/{library_id}/documents/{document_id}/text_content |
none |
PHP |
retrieveLibraryDocumentStatus |
GET /v1/libraries/{library_id}/documents/{document_id}/status |
none |
PHP |
retrieveLibraryDocumentSignedUrl |
GET /v1/libraries/{library_id}/documents/{document_id}/signed-url |
none |
PHP |
retrieveLibraryDocumentExtractedTextSignedUrl |
GET /v1/libraries/{library_id}/documents/{document_id}/extracted-text-signed-url |
none |
PHP |
reprocessLibraryDocument |
POST /v1/libraries/{library_id}/documents/{document_id}/reprocess |
none |
PHP |
Libraries / Shares
| SDK method |
HTTP route |
Request body |
Example |
listLibraryShares |
GET /v1/libraries/{library_id}/share |
none |
PHP |
upsertLibraryShare |
PUT /v1/libraries/{library_id}/share |
json |
PHP |
deleteLibraryShare |
DELETE /v1/libraries/{library_id}/share |
json |
PHP |
Prompts
| SDK method |
HTTP route |
Request body |
Example |
listPrompts |
GET /v2/prompts |
none |
PHP |
createPrompt |
POST /v2/prompts |
json |
PHP |
retrievePrompt |
GET /v2/prompts/{prompt_id} |
none |
PHP |
deletePrompt |
DELETE /v2/prompts/{prompt_id} |
none |
PHP |
updatePrompt |
PATCH /v2/prompts/{prompt_id} |
json |
PHP |
listPromptVersions |
GET /v2/prompts/{prompt_id}/versions |
none |
PHP |
createPromptVersion |
POST /v2/prompts/{prompt_id}/versions |
json |
PHP |
retrievePromptVersion |
GET /v2/prompts/{prompt_id}/versions/{version} |
none |
PHP |
updatePromptVersionMetadata |
PATCH /v2/prompts/{prompt_id}/versions/{version} |
json |
PHP |
Skills
| SDK method |
HTTP route |
Request body |
Example |
listSkills |
GET /v2/skills |
none |
PHP |
createSkill |
POST /v2/skills |
json |
PHP |
retrieveSkill |
GET /v2/skills/{skill_id} |
none |
PHP |
deleteSkill |
DELETE /v2/skills/{skill_id} |
none |
PHP |
updateSkill |
PATCH /v2/skills/{skill_id} |
json |
PHP |
listSkillVersions |
GET /v2/skills/{skill_id}/versions |
none |
PHP |
createSkillVersion |
POST /v2/skills/{skill_id}/versions |
json |
PHP |
retrieveSkillVersion |
GET /v2/skills/{skill_id}/versions/{version} |
none |
PHP |
updateSkillVersionMetadata |
PATCH /v2/skills/{skill_id}/versions/{version} |
json |
PHP |
Connectors
| SDK method |
HTTP route |
Request body |
Example |
shareConnectorWithOrganization |
PUT /v1/connectors/{connector_id}/organization/share |
none |
PHP |
unshareConnectorFromOrganization |
DELETE /v1/connectors/{connector_id}/organization/share |
none |
PHP |
createConnectorCredentials |
POST /v1/connectors/{connector_id_or_name}/{consumer_scope}/credentials |
json |
PHP |
updateConnectorCredentials |
PATCH /v1/connectors/{connector_id_or_name}/{consumer_scope}/credentials |
json |
PHP |
deleteConnectorCredentials |
DELETE /v1/connectors/{connector_id_or_name}/{consumer_scope}/credentials/{credentials_name} |
none |
PHP |
createConnector |
POST /v1/connectors |
json |
PHP |
listConnectors |
GET /v1/connectors |
none |
PHP |
getConnectorAuthUrl |
GET /v1/connectors/{connector_id_or_name}/auth_url |
none |
PHP |
shareConnector |
PUT /v1/connectors/{connector_id}/share |
none |
PHP |
unshareConnector |
DELETE /v1/connectors/{connector_id}/share |
none |
PHP |
activateForConsumerConnector |
POST /v1/connectors/{connector_id}/{consumer_scope}/activate |
none |
PHP |
deactivateForConsumerConnector |
POST /v1/connectors/{connector_id}/{consumer_scope}/deactivate |
none |
PHP |
listConnectorTools |
GET /v1/connectors/{connector_id_or_name}/tools |
none |
PHP |
getConnectorAuthenticationMethods |
GET /v1/connectors/{connector_id_or_name}/authentication_methods |
none |
PHP |
listConnectorOrganizationCredentials |
GET /v1/connectors/{connector_id_or_name}/organization/credentials |
none |
PHP |
listConnectorWorkspaceCredentials |
GET /v1/connectors/{connector_id_or_name}/workspace/credentials |
none |
PHP |
listConnectorUserCredentials |
GET /v1/connectors/{connector_id_or_name}/user/credentials |
none |
PHP |
deleteAllConnectorUserCredentials |
DELETE /v1/connectors/{connector_id_or_name}/user/credentials |
none |
PHP |
retrieveConnector |
GET /v1/connectors/{connector_id_or_name} |
none |
PHP |
updateConnector |
PATCH /v1/connectors/{connector_id} |
json |
PHP |
deleteConnector |
DELETE /v1/connectors/{connector_id} |
none |
PHP |
Service Accounts
| SDK method |
HTTP route |
Request body |
Example |
createServiceAccount |
POST /v1/service-accounts |
json |
PHP |
listServiceAccounts |
GET /v1/service-accounts |
none |
PHP |
listAssignableServiceAccountRoles |
GET /v1/service-accounts/assignable-roles |
none |
PHP |
retrieveServiceAccount |
GET /v1/service-accounts/{service_account_id} |
none |
PHP |
updateServiceAccount |
PATCH /v1/service-accounts/{service_account_id} |
json |
PHP |
deleteServiceAccount |
DELETE /v1/service-accounts/{service_account_id} |
none |
PHP |
setServiceAccountRoles |
PUT /v1/service-accounts/{service_account_id}/roles |
json |
PHP |
listServiceAccountRoles |
GET /v1/service-accounts/{service_account_id}/roles |
none |
PHP |
Observability / Datasets
| SDK method |
HTTP route |
Request body |
Example |
postDatasetRecordsFromSpans |
POST /v1/observability/datasets/{dataset_id}/imports/from-spans |
json |
PHP |
createDataset |
POST /v1/observability/datasets |
json |
PHP |
getDatasets |
GET /v1/observability/datasets |
none |
PHP |
getDatasetById |
GET /v1/observability/datasets/{dataset_id} |
none |
PHP |
deleteDataset |
DELETE /v1/observability/datasets/{dataset_id} |
none |
PHP |
updateDataset |
PATCH /v1/observability/datasets/{dataset_id} |
json |
PHP |
getDatasetRecords |
GET /v1/observability/datasets/{dataset_id}/records |
none |
PHP |
createDatasetRecord |
POST /v1/observability/datasets/{dataset_id}/records |
json |
PHP |
postDatasetRecordsFromFile |
POST /v1/observability/datasets/{dataset_id}/imports/from-file |
json |
PHP |
postDatasetRecordsFromPlayground |
POST /v1/observability/datasets/{dataset_id}/imports/from-playground |
json |
PHP |
postDatasetRecordsFromDataset |
POST /v1/observability/datasets/{dataset_id}/imports/from-dataset |
json |
PHP |
exportDatasetToJsonl |
GET /v1/observability/datasets/{dataset_id}/exports/to-jsonl |
none |
PHP |
getDatasetImportTask |
GET /v1/observability/datasets/{dataset_id}/tasks/{task_id} |
none |
PHP |
getDatasetImportTasks |
GET /v1/observability/datasets/{dataset_id}/tasks |
none |
PHP |
Observability / Pipelines
| SDK method |
HTTP route |
Request body |
Example |
createPipeline |
POST /v1/observability/pipelines |
json |
PHP |
listPipelines |
GET /v1/observability/pipelines |
none |
PHP |
retrievePipeline |
GET /v1/observability/pipelines/{pipeline_id} |
none |
PHP |
updatePipeline |
PUT /v1/observability/pipelines/{pipeline_id} |
json |
PHP |
deletePipeline |
DELETE /v1/observability/pipelines/{pipeline_id} |
none |
PHP |
Observability / Spans
| SDK method |
HTTP route |
Request body |
Example |
aggregateSpanEvaluations |
POST /v1/observability/spans/evaluations/aggregate |
json |
PHP |
searchPipelineResults |
POST /v1/observability/pipeline-results/search |
json |
PHP |
searchSpans |
POST /v1/observability/spans/search |
json |
PHP |
aggregateSpans |
POST /v1/observability/spans/aggregate |
json |
PHP |
searchSpanEvaluations |
POST /v1/observability/spans/evaluations/search |
json |
PHP |
searchLatestSpanEvaluations |
POST /v1/observability/spans/evaluations/search/latest |
json |
PHP |
getSpanFields |
GET /v1/observability/spans/fields |
none |
PHP |
getSpanEvaluationFields |
GET /v1/observability/spans/evaluations/fields |
none |
PHP |
getSpanFieldOptions |
GET /v1/observability/spans/fields/{field_name}/options |
none |
PHP |
getSpanEvaluationFieldOptions |
GET /v1/observability/spans/evaluations/fields/{field_name}/options |
none |
PHP |
Observability / Projects
| SDK method |
HTTP route |
Request body |
Example |
listObservabilityProjects |
GET /v1/observability/projects |
none |
PHP |
retrieveObservabilityProject |
GET /v1/observability/projects/{project_slug} |
none |
PHP |
Observability / Evaluations
| SDK method |
HTTP route |
Request body |
Example |
listProjectEvaluations |
GET /v1/observability/projects/{project_slug}/evaluations_v2 |
none |
PHP |
retrieveEvaluation |
GET /v1/observability/evaluations_v2/{evaluation_slug} |
none |
PHP |
Observability / Evaluations / Runs
| SDK method |
HTTP route |
Request body |
Example |
searchEvaluationRuns |
POST /v1/observability/evaluations_v2/{evaluation_slug}/runs/search |
json |
PHP |
searchAllEvaluationRuns |
POST /v1/observability/evaluation-runs_v2/search |
json |
PHP |
retrieveEvaluationRun |
GET /v1/observability/evaluation-runs_v2/{run_id} |
none |
PHP |
getEvaluationRunStatistics |
GET /v1/observability/evaluation-runs_v2/{run_id}/statistics |
none |
PHP |
computeEvaluationRunStatistics |
POST /v1/observability/evaluation-runs_v2/{run_id}/statistics/compute |
json |
PHP |
Observability / Evaluations / Records
| SDK method |
HTTP route |
Request body |
Example |
retrieveEvaluationRunRecord |
GET /v1/observability/evaluation-runs_v2/{run_id}/records/{record_id} |
none |
PHP |
searchEvaluationRunRecords |
POST /v1/observability/evaluation-runs_v2/{run_id}/records/search |
json |
PHP |
Observability / Evaluations / Optimizations
| SDK method |
HTTP route |
Request body |
Example |
listOptimizations |
GET /v1/observability/optimizations |
none |
PHP |
retrieveOptimization |
GET /v1/observability/optimizations/{optimization_id} |
none |
PHP |
listOptimizationTrials |
GET /v1/observability/optimizations/{optimization_id}/trials |
none |
PHP |
Workflows / Deployments
| SDK method |
HTTP route |
Request body |
Example |
unhardenDeployment |
POST /v1/workflows/deployments/{deployment_id}/unharden |
none |
PHP |
listDeployments |
GET /v1/workflows/deployments |
none |
PHP |
createDeployment |
POST /v1/workflows/deployments |
json |
PHP |
updateDeployment |
PATCH /v1/workflows/deployments/{name} |
json |
PHP |
deleteDeployment |
DELETE /v1/workflows/deployments/{name} |
none |
PHP |
getDeployment |
GET /v1/workflows/deployments/{name} |
none |
PHP |
stopDeployment |
POST /v1/workflows/deployments/{name}/stop |
none |
PHP |
startDeployment |
POST /v1/workflows/deployments/{name}/start |
none |
PHP |
restartDeployment |
POST /v1/workflows/deployments/{name}/restart |
none |
PHP |
listDeploymentWorkers |
GET /v1/workflows/deployments/{name}/workers |
none |
PHP |
getDeploymentLogs |
GET /v1/workflows/deployments/{name}/logs |
none |
PHP |
streamDeploymentLogs |
GET /v1/workflows/deployments/{name}/logs/stream |
none |
PHP |
RAG / Managed Indexes
| SDK method |
HTTP route |
Request body |
Example |
createManagedIndex |
POST /v1/rag/managed_indexes |
json |
PHP |
listManagedIndexes |
GET /v1/rag/managed_indexes |
none |
PHP |
retrieveManagedIndex |
GET /v1/rag/managed_indexes/{index_name} |
none |
PHP |
updateManagedIndex |
PUT /v1/rag/managed_indexes/{index_name} |
json |
PHP |
deleteManagedIndex |
DELETE /v1/rag/managed_indexes/{index_name} |
none |
PHP |
ingestManagedIndexDocuments |
POST /v1/rag/managed_indexes/{index_name}/documents |
json |
PHP |
deleteManagedIndexDocuments |
DELETE /v1/rag/managed_indexes/{index_name}/documents |
json |
PHP |
searchManagedIndex |
POST /v1/rag/managed_indexes/{index_name}/search |
json |
PHP |
navigateManagedIndex |
POST /v1/rag/managed_indexes/{index_name}/navigate |
json |
PHP |
readManagedIndex |
POST /v1/rag/managed_indexes/{index_name}/read |
json |
PHP |
grepManagedIndex |
POST /v1/rag/managed_indexes/{index_name}/grep |
json |
PHP |
retrieveManagedIndexChunk |
GET /v1/rag/managed_indexes/{index_name}/chunks/{chunk_id} |
none |
PHP |
Users
| SDK method |
HTTP route |
Request body |
Example |
getWhoAmI |
GET /v1/whoami |
none |
PHP |
getIdentity |
GET /v1/users/me |
none |
PHP |
listOrganizations |
GET /v1/users/me/organizations |
none |
PHP |
listWorkspaces |
GET /v1/users/me/workspaces |
none |
PHP |
Observability / Judges
| SDK method |
HTTP route |
Request body |
Example |
createJudge |
POST /v1/observability/judges |
json |
PHP |
getJudges |
GET /v1/observability/judges |
none |
PHP |
getJudgeById |
GET /v1/observability/judges/{judge_id} |
none |
PHP |
deleteJudge |
DELETE /v1/observability/judges/{judge_id} |
none |
PHP |
updateJudge |
PUT /v1/observability/judges/{judge_id} |
json |
PHP |
judgeConversation |
POST /v1/observability/judges/{judge_id}/live-judging |
json |
PHP |
Observability / Datasets / Records
| SDK method |
HTTP route |
Request body |
Example |
getDatasetRecord |
GET /v1/observability/dataset-records/{dataset_record_id} |
none |
PHP |
deleteDatasetRecord |
DELETE /v1/observability/dataset-records/{dataset_record_id} |
none |
PHP |
deleteDatasetRecords |
POST /v1/observability/dataset-records/bulk-delete |
json |
PHP |
judgeDatasetRecord |
POST /v1/observability/dataset-records/{dataset_record_id}/live-judging |
json |
PHP |
updateDatasetRecordPayload |
PUT /v1/observability/dataset-records/{dataset_record_id}/payload |
json |
PHP |
updateDatasetRecordProperties |
PUT /v1/observability/dataset-records/{dataset_record_id}/properties |
json |
PHP |
Observability / Logs
| SDK method |
HTTP route |
Request body |
Example |
searchLogs |
POST /v1/observability/logs/search |
json |
PHP |
getLogFields |
GET /v1/observability/logs/fields |
none |
PHP |
getLogFieldOptions |
GET /v1/observability/logs/fields/{field_name}/options |
none |
PHP |
Observability / Traces
| SDK method |
HTTP route |
Request body |
Example |
searchTraces |
POST /v1/observability/traces/search |
json |
PHP |
aggregateTraces |
POST /v1/observability/traces/aggregate |
json |
PHP |
getTraceFields |
GET /v1/observability/traces/fields |
none |
PHP |
getTraceById |
GET /v1/observability/traces/{trace_id} |
none |
PHP |
getTraceSpans |
GET /v1/observability/traces/{trace_id}/spans |
none |
PHP |
getTraceFieldOptions |
GET /v1/observability/traces/fields/{field_name}/options |
none |
PHP |
getSpanById |
GET /v1/observability/traces/{trace_id}/spans/{span_id} |
none |
PHP |
Workflows / Executions
| SDK method |
HTTP route |
Request body |
Example |
getWorkflowExecution |
GET /v1/workflows/executions/{execution_id} |
none |
PHP |
getWorkflowExecutionHistory |
GET /v1/workflows/executions/{execution_id}/history |
none |
PHP |
signalWorkflowExecution |
POST /v1/workflows/executions/{execution_id}/signals |
json |
PHP |
queryWorkflowExecution |
POST /v1/workflows/executions/{execution_id}/queries |
json |
PHP |
terminateWorkflowExecution |
POST /v1/workflows/executions/{execution_id}/terminate |
none |
PHP |
batchTerminateWorkflowExecutions |
POST /v1/workflows/executions/terminate |
json |
PHP |
cancelWorkflowExecution |
POST /v1/workflows/executions/{execution_id}/cancel |
none |
PHP |
batchCancelWorkflowExecutions |
POST /v1/workflows/executions/cancel |
json |
PHP |
resetWorkflow |
POST /v1/workflows/executions/{execution_id}/reset |
json |
PHP |
updateWorkflowExecution |
POST /v1/workflows/executions/{execution_id}/updates |
json |
PHP |
getWorkflowExecutionTraceInfo |
GET /v1/workflows/executions/{execution_id}/trace/info |
none |
PHP |
getWorkflowExecutionTraceOtel |
GET /v1/workflows/executions/{execution_id}/trace/otel |
none |
PHP |
getWorkflowExecutionTraceSummary |
GET /v1/workflows/executions/{execution_id}/trace/summary |
none |
PHP |
getWorkflowExecutionTraceEvents |
GET /v1/workflows/executions/{execution_id}/trace/events |
none |
PHP |
streamWorkflowExecution |
GET /v1/workflows/executions/{execution_id}/stream |
none |
PHP |
getWorkflowExecutionLogs |
GET /v1/workflows/executions/{execution_id}/logs |
none |
PHP |
streamWorkflowExecutionLogs |
GET /v1/workflows/executions/{execution_id}/logs/stream |
none |
PHP |
Workflows / Metrics
| SDK method |
HTTP route |
Request body |
Example |
getWorkflowMetrics |
GET /v1/workflows/{workflow_name}/metrics |
none |
PHP |
Workflows / Runs
| SDK method |
HTTP route |
Request body |
Example |
listRuns |
GET /v1/workflows/runs |
none |
PHP |
getRun |
GET /v1/workflows/runs/{run_id} |
none |
PHP |
getRunHistory |
GET /v1/workflows/runs/{run_id}/history |
none |
PHP |
Workflows / Schedules
| SDK method |
HTTP route |
Request body |
Example |
getSchedules |
GET /v1/workflows/schedules |
none |
PHP |
scheduleWorkflow |
POST /v1/workflows/schedules |
json |
PHP |
getSchedule |
GET /v1/workflows/schedules/{schedule_id} |
none |
PHP |
unscheduleWorkflow |
DELETE /v1/workflows/schedules/{schedule_id} |
none |
PHP |
updateSchedule |
PATCH /v1/workflows/schedules/{schedule_id} |
json |
PHP |
pauseSchedule |
POST /v1/workflows/schedules/{schedule_id}/pause |
json |
PHP |
resumeSchedule |
POST /v1/workflows/schedules/{schedule_id}/resume |
json |
PHP |
triggerSchedule |
POST /v1/workflows/schedules/{schedule_id}/trigger |
json |
PHP |
Workflows / Events
| SDK method |
HTTP route |
Request body |
Example |
getStreamEvents |
GET /v1/workflows/events/stream |
none |
PHP |
getWorkflowEvents |
GET /v1/workflows/events/list |
none |
PHP |
Workflows
| SDK method |
HTTP route |
Request body |
Example |
getWorkflows |
GET /v1/workflows |
none |
PHP |
getWorkflowRegistrations |
GET /v1/workflows/registrations |
none |
PHP |
executeWorkflow |
POST /v1/workflows/{workflow_identifier}/execute |
json |
PHP |
getWorkflow |
GET /v1/workflows/{workflow_identifier} |
none |
PHP |
updateWorkflow |
PUT /v1/workflows/{workflow_identifier} |
json |
PHP |
getWorkflowRegistration |
GET /v1/workflows/registrations/{workflow_registration_id} |
none |
PHP |
bulkArchiveWorkflows |
PUT /v1/workflows/archive |
json |
PHP |
bulkUnarchiveWorkflows |
PUT /v1/workflows/unarchive |
json |
PHP |
archiveWorkflow |
PUT /v1/workflows/{workflow_identifier}/archive |
none |
PHP |
unarchiveWorkflow |
PUT /v1/workflows/{workflow_identifier}/unarchive |
none |
PHP |
RAG / Ingestion
| SDK method |
HTTP route |
Request body |
Example |
getConfigs |
GET /v1/rag/ingestion_pipeline_configurations |
none |
PHP |
registerConfig |
PUT /v1/rag/ingestion_pipeline_configurations |
json |
PHP |
updateRunInfo |
PUT /v1/rag/ingestion_pipeline_configurations/{id}/run_info |
json |
PHP |
RAG / Search Indexes
| SDK method |
HTTP route |
Request body |
Example |
getDeploymentSummaries |
GET /v1/rag/deployments |
none |
PHP |
registerDeployment |
PUT /v1/rag/deployments |
json |
PHP |
unregisterDeployment |
DELETE /v1/rag/deployments/{deployment_id} |
none |
PHP |
updateIndexMetrics |
PUT /v1/rag/deployments/{deployment_id}/metrics |
json |
PHP |
Administration / Billing
| SDK method |
HTTP route |
Request body |
Example |
queryAdminUsage |
POST /v1/admin/usage/query |
json |
PHP |
listAdminRateLimits |
GET /v1/admin/rate-limit |
none |
PHP |
listAdminSpendLimits |
GET /v1/admin/spend-limit |
none |
PHP |
updateAdminSpendLimits |
POST /v1/admin/spend-limit |
json |
PHP |
listAdminUsage |
GET /v1/admin/usage |
none |
PHP |
Administration / Users
| SDK method |
HTTP route |
Request body |
Example |
deactivateAdminUser |
POST /v1/admin/users/{user_id}/deactivate |
none |
PHP |
listAdminUsers |
GET /v1/admin/users |
none |
PHP |
createAdminUsers |
POST /v1/admin/users |
json |
PHP |
inviteAdminUsers |
POST /v1/admin/users-invite |
json |
PHP |
listAdminInvite |
GET /v1/admin/users-invite |
none |
PHP |
deleteAdminInvite |
DELETE /v1/admin/users-invite/{invite_uuid} |
none |
PHP |
updateAdminUser |
PATCH /v1/admin/users/{user_id} |
json |
PHP |
deleteAdminUser |
DELETE /v1/admin/users/{user_id} |
none |
PHP |
retrieveAdminUser |
GET /v1/admin/users/{user_id} |
none |
PHP |
listAdminRoles |
GET /v1/admin/roles |
none |
PHP |
Administration / Workspaces
| SDK method |
HTTP route |
Request body |
Example |
listAdminWorkspaces |
GET /v1/admin/workspaces |
none |
PHP |
createAdminWorkspace |
POST /v1/admin/workspaces |
json |
PHP |
updateAdminWorkspaces |
PATCH /v1/admin/workspaces/{workspace_uuid} |
json |
PHP |
deleteAdminWorkspaces |
DELETE /v1/admin/workspaces/{workspace_uuid} |
none |
PHP |
addAdminUsersWorkspaces |
POST /v1/admin/workspaces/{workspace_uuid}/add-users |
json |
PHP |
addAdminOrUpdateUsersWorkspaces |
PATCH /v1/admin/workspaces/{workspace_uuid}/users |
json |
PHP |
removeAdminUsersWorkspaces |
DELETE /v1/admin/workspaces/{workspace_uuid}/remove-users |
json |
PHP |
Administration / Audit Logs
| SDK method |
HTTP route |
Request body |
Example |
listAdminAuditLogs |
GET /v1/admin/audit-logs |
none |
PHP |
Administration / User Groups
| SDK method |
HTTP route |
Request body |
Example |
listAdminUserGroups |
GET /v1/admin/user-groups |
none |
PHP |
createAdminUserGroup |
POST /v1/admin/user-groups |
json |
PHP |
retrieveAdminUserGroup |
GET /v1/admin/user-groups/{group_uuid} |
none |
PHP |
updateAdminUserGroup |
PATCH /v1/admin/user-groups/{group_uuid} |
json |
PHP |
deleteAdminUserGroup |
DELETE /v1/admin/user-groups/{group_uuid} |
none |
PHP |
retrieveAdminUserGroupMembers |
GET /v1/admin/user-groups/{group_uuid}/members |
none |
PHP |
assignAdminUsersToGroup |
POST /v1/admin/user-groups/{group_uuid}/members |
json |
PHP |
removeAdminUsersFromGroup |
DELETE /v1/admin/user-groups/{group_uuid}/members |
json |
PHP |
retrieveAdminGroupWorkspaceAssignments |
GET /v1/admin/user-groups/{group_uuid}/workspaces |
none |
PHP |
assignAdminGroupToWorkspace |
POST /v1/admin/user-groups/{group_uuid}/workspaces |
json |
PHP |
updateAdminGroupWorkspaceAssignment |
PATCH /v1/admin/user-groups/{group_uuid}/workspaces/{workspace_uuid} |
json |
PHP |
removeAdminGroupFromWorkspace |
DELETE /v1/admin/user-groups/{group_uuid}/workspaces/{workspace_uuid} |
none |
PHP |
updateAdminUserGroupOrganizationRole |
PATCH /v1/admin/user-groups/{group_uuid}/organization-role |
json |
PHP |
retrieveAdminNestedGroupsAdmin |
GET /v1/admin/user-groups/{group_uuid}/nested |
none |
PHP |
setAdminNestedGroupsAdmin |
PATCH /v1/admin/user-groups/{group_uuid}/nested |
json |
PHP |
Administration / API Keys
| SDK method |
HTTP route |
Request body |
Example |
listAdminApiKeys |
GET /v1/admin/api-keys |
none |
PHP |
createAdminApiKey |
POST /v1/admin/api-keys |
json |
PHP |
deleteAdminApiKey |
DELETE /v1/admin/api-keys/{key_id} |
none |
PHP |
Administration / SCIM
| SDK method |
HTTP route |
Request body |
Example |
triggerAdminScimSync |
POST /v1/admin/scim/sync |
json |
PHP |
retrieveAdminScimSyncRun |
GET /v1/admin/scim/sync/{run_id} |
none |
PHP |
Administration / Vibe Work Analytics
| SDK method |
HTTP route |
Request body |
Example |
usageAdminByUser |
GET /v1/admin/analytics/vibe/work/usage/by_user_stats |
none |
PHP |
usageAdminByAgent |
GET /v1/admin/analytics/vibe/work/usage/by_agent_stats |
none |
PHP |
usageAdminOverTime |
GET /v1/admin/analytics/vibe/work/usage/by_time_stats |
none |
PHP |
Administration / Vibe Code Analytics
| SDK method |
HTTP route |
Request body |
Example |
usageAdminByWorkspace |
GET /v1/admin/analytics/vibe/code/usage/by_workspace |
none |
PHP |
usageAdminByOrganization |
GET /v1/admin/analytics/vibe/code/usage/by_organization |
none |
PHP |
Custom API Origin
Pass a hostname or absolute base URL through the constructor's origin argument. basePath overrides the path
in an absolute origin. Without an override, the SDK selects /v1 or /v2 for each endpoint. Examples read
MISTRAL_API_ORIGIN and MISTRAL_API_BASE_PATH from .env.
Migration Notes
- PHP 8.1 is no longer supported. Each supported PHP branch has its own minimum patch version listed above.
- Rename the constructor and URL-builder named argument
apiVersion to basePath, and replace
MISTRAL_API_VERSION with MISTRAL_API_BASE_PATH. Leave the latter empty to select versions per endpoint.
The old API_VERSION constant is removed; use MistralAIURLBuilder::BASE_PATH for the default path.
listVoices() now uses the cursor-paginated /v2/audio/voices route. Use the documented page_size and
page_token parameters instead of offset pagination.
- Replace
listAgents() with listAgentPages(), updateLibrary() with patchLibrary(), and
updateLibraryDocument() with patchLibraryDocument().
- Replace deprecated
createAgentsCompletion() calls with Conversations operations such as startConversation().
Adapt the request and response payloads; this is not a drop-in alias.
- Replace the scope-specific connector credential create/update/delete helpers with
createConnectorCredentials(),
updateConnectorCredentials(), and deleteConnectorCredentials(), passing consumer_scope as a path parameter.
- Old observability campaign and chat-completion-event operations are removed. Use the current evaluations,
pipelines, spans, traces, logs, and dataset-import endpoints for new integrations.
- Deprecated direct connector tool calls, workflow-registration execution, and group provisioning helpers are removed.
Use current workflow execution and group/workspace assignment operations where applicable.
See CHANGELOG.md for the breaking-change summary. Explicit parameter/body pairs remain supported
for query/body separation; private-helper compatibility fallbacks and legacy aliases are not retained.
Development
composer update
composer test
composer analyse
vendor/bin/php-cs-fixer fix --dry-run --diff
CI also audits dependencies, validates the optional contract example, and requires 100% statement, method,
and element coverage.
Changelog
See CHANGELOG.md for release history and migration notes.
License
This library is licensed under the ISC License. See LICENSE.md.