Search by

papi-ai / cohere

md

Cohere provider for PapiAI

Package info

github.com/papi-ai/cohere

Type:papi-provider

pkg:composer/papi-ai/cohere

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.16.3 2026-11-16 20:41 UTC

This package is not auto-updated.

Last update: 2026-11-16 20:45:11 UTC


README

CI Latest Version Total Downloads PHP Version License

Cohere provider for PapiAI - A simple but powerful PHP library for building AI agents.

Installation

composer require papi-ai/cohere

Usage

use PapiAI\Core\Agent;
use PapiAI\Cohere\CohereProvider;

$provider = new CohereProvider(
    apiKey: $_ENV['COHERE_API_KEY'],
);

$agent = new Agent(
    provider: $provider,
    instructions: 'You are a helpful assistant.',
);

$response = $agent->run('Hello!');
echo $response->text;

Available Models

Chat Models

CohereProvider::MODEL_COMMAND_A_PLUS      // 'command-a-plus-05-2026' (default)
CohereProvider::MODEL_COMMAND_A           // 'command-a-03-2025'
CohereProvider::MODEL_COMMAND_A_REASONING // 'command-a-reasoning-08-2025'
CohereProvider::MODEL_COMMAND_R7B         // 'command-r7b-12-2024'

The MODEL_COMMAND, MODEL_COMMAND_R and MODEL_COMMAND_R_PLUS constants are still shipped but deprecated: all three were deprecated on 15 September 2025, and the two oldest predate command-r7b, so they reject forced tool choice.

Embedding Models

CohereProvider::MODEL_EMBED_V4            // 'embed-v4.0'
CohereProvider::MODEL_EMBED_ENGLISH       // 'embed-english-v3.0'
CohereProvider::MODEL_EMBED_MULTILINGUAL  // 'embed-multilingual-v3.0'

Features

  • Chat completions via Cohere v2 API
  • Tool/function calling
  • Streaming support
  • Text embeddings

Creating It by Name

An application that picks its provider from configuration can build this one without naming its class:

use PapiAI\Core\Factory\ComposerDiscovery;
use PapiAI\Core\Factory\ProviderRegistry;

$registry = new ProviderRegistry(new ComposerDiscovery());

$provider = $registry->create('cohere', [
    'api_key' => $_ENV['COHERE_API_KEY'],
]);

It takes api_key (required) and model. Anything it is not given falls back to the constructor's defaults, and a missing or unknown setting throws ConfigurationException before any request is made.

License

MIT