PHP code example of papi-ai / cohere

1. Go to this page and download the library: Download papi-ai/cohere library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

papi-ai / cohere example snippets


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;

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'

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