PHP code example of aisdk / cohere
1. Go to this page and download the library: Download aisdk/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/ */
aisdk / cohere example snippets
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();
$result = Generate::embedding(['A document to index'])
->model(Cohere::model('embed-v4.0'))
->providerOptions('cohere', ['inputType' => 'search_document'])
->run();