PHP code example of talleu / cohere-php-client

1. Go to this page and download the library: Download talleu/cohere-php-client 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/ */

    

talleu / cohere-php-client example snippets


use Talleu\CohereClient\Cohere;

$client = Cohere::client('your-api-key'); 

// Call the embed endpoint
$embeds = $client->embed()->create([
      'Cohere is amazing!',
      'Let’s try embedding some text.'
  ]);

var_dump($embeds);

    $chat = $client->chat()->create([
        [
            'role' => 'user',
            'content' => 'how are you ?'
        ]
    ]);

Cohere::client('your-api-key');

$client->embed();
$client->chat();
$client->tokenize();
$client->detokenize();
$client->classify();
$client->rerank();
$client->dataset();
$client->fineTuning();
$client->model();
$client->embedJob();
$client->connector();
// etc.

$connector = $client->connector()->create($name, $url, ['model' => 'command-a-03-2025']);
$connector = $client->connector()->get($id);
$connector = $client->connector()->list();

$chat = Cohere::client()->sendRequest('GET', '/v2/chat', $body);

composer