Official Cohere provider for the PHP AI SDK. Uses Cohere's native v2 Chat and Embed APIs.
composer require aisdk/cohereuse AiSdk\Cohere;
use AiSdk\Generate;
Cohere::create(['apiKey' => $_ENV['COHERE_API_KEY']]);
$result = Generate::text('Explain vector databases in one sentence.')
->model(Cohere::model('command-a-03-2025'))
->run();$result = Generate::embedding(['A document to index'])
->model(Cohere::model('embed-v4.0'))
->providerOptions('cohere', ['inputType' => 'search_document'])
->run();| Variable | Description | Default |
|---|---|---|
COHERE_API_KEY |
API key for authentication | Required |
COHERE_BASE_URL |
Base URL for API requests | https://api.cohere.com |
| Capability | Support |
|---|---|
| Text generation and streaming | Native v2 Chat API |
| Tools, structured output, reasoning, image input | Native where supported by the selected model |
| Embeddings | Native v2 Embed API |
Use providerOptions('cohere', ['raw' => [...]]) for Cohere fields outside the portable SDK surface. Model IDs are opaque strings and are validated by Cohere.