Skip to content

Repository files navigation

aisdk/cohere

GitHub Workflow Status Latest Version License


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.

Documentation

About

Official Cohere provider for the PHP AI SDK.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages