aisdk / cohere
Official Cohere provider for the PHP AI SDK.
Fund package maintenance!
v0.8.3
2026-07-22 07:10 UTC
Requires
- php: ^8.3
- aisdk/core: ^0.8.0
Requires (Dev)
- laravel/pint: ^1.18
- nyholm/psr7: ^1.8
- pestphp/pest: ^3.0 || ^4.0
- phpstan/phpstan: ^2.0
- rector/rector: ^2.0
README
Official Cohere provider for the PHP AI SDK. Uses Cohere's native v2 Chat and Embed APIs.
Installation
composer require aisdk/cohere
Basic Usage
use 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();
Embeddings
$result = Generate::embedding(['A document to index']) ->model(Cohere::model('embed-v4.0')) ->providerOptions('cohere', ['inputType' => 'search_document']) ->run();
Configuration
| Variable | Description | Default |
|---|---|---|
COHERE_API_KEY |
API key for authentication | Required |
COHERE_BASE_URL |
Base URL for API requests | https://api.cohere.com |
Supported Capabilities
| 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.