PHPackages                             talleu/cohere-php-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. talleu/cohere-php-client

ActiveLibrary[API Development](/categories/api)

talleu/cohere-php-client
========================

PHP client to interact with Cohere API

v1.0(12mo ago)5761[1 PRs](https://github.com/clementtalleu/cohere-php-client/pulls)MITPHPPHP &gt;=8.2

Since Jun 27Pushed 12mo agoCompare

[ Source](https://github.com/clementtalleu/cohere-php-client)[ Packagist](https://packagist.org/packages/talleu/cohere-php-client)[ RSS](/packages/talleu-cohere-php-client/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (15)Versions (8)Used By (0)

[![PHPStan](https://camo.githubusercontent.com/695729a68277577171bbc4ff5533a3c7244b4a3161cf940f5c194bf996b8fa1b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4f4b2d627269676874677265656e)](https://camo.githubusercontent.com/695729a68277577171bbc4ff5533a3c7244b4a3161cf940f5c194bf996b8fa1b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4f4b2d627269676874677265656e)[![Packagist Version](https://camo.githubusercontent.com/e5757bfd993239cc06693350cbee680870967856077e424464ad8f46c2fc9d6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616c6c65752f636f686572652d7068702d636c69656e742e737667)](https://packagist.org/packages/talleu/cohere-php-client)[![GitHub](https://camo.githubusercontent.com/360104bc69b10371b5bc406016068ef592c4734a169058b0cb6387920af615c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636c656d656e7474616c6c65752f636f686572652d7068702d636c69656e742e737667)](https://github.com/averias/phpredis-json)

---

Cohere PHP Client
-----------------

[](#cohere-php-client)

A PHP client to interact with the [Cohere® API](https://cohere.com/), designed to be framework-agnostic, simple to use, and fully compatible with [PSR-18](https://www.php-fig.org/psr/psr-18/).

This package provides an easy and structured way to use Cohere's powerful language models — for **embeddings**, **chat**, **classification**, **tokenization**, and more — in any PHP project.

---

Features 🛠️
-----------

[](#features-️)

- ✅ Support for **Cohere API v1/v2** endpoints (chat, embed, classify, tokenize, etc.)
- ✅ Compatible with any **PSR-18 HTTP Client**
- ✅ File upload and multipart support
- ✅ Developer-friendly DTOs and response builders
- ✅ Easily extendable with your own endpoints

---

Requirements ⚙️
---------------

[](#requirements-️)

- PHP **8.2** or higher
- Composer
- A PSR-18 compatible HTTP client ( e.g. [Guzzle](https://github.com/guzzle/guzzle), [Symfony HttpClient](https://symfony.com/doc/current/http_client.html), [HTTPlug clients](https://packagist.org/providers/php-http/client-implementation))

Installation 📝
--------------

[](#installation-)

Install the library via Composer:

```
composer require talleu/cohere-php-client

```

Then install your preferred HTTP client

Using Symfony HttpClient:

```
composer require symfony/http-client

```

Using Guzzle:

```
composer require guzzlehttp/guzzle

```

Or another client implementing PSR18

Basic Usage 🎯
-------------

[](#basic-usage-)

Minimal example

```
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);
```

Or to simple chats with LLM

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

Authentication 🔐
----------------

[](#authentication-)

You can pass the API key directly in the http client:

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

Or use an environment variable (recommended):

```
#.env
COHERE_API_KEY=your-api-key
```

Available Endpoints 📚
---------------------

[](#available-endpoints-)

The following endpoints are supported:

EndpointClassDescription`v2/embed``Embed`Generate embeddings from input text`v2/chat``Chat`Perform conversational chat with a LLM`v1/classify``Classify`Text classification based on custom labels`v1/tokenize``Tokenize`Token-level breakdown of input text`v1/detokenize``Detokenize`De-tokenify tokens to text`v1/connectors``Connector`Cohere connectors`v1/embed-jobs``EmbedJob`Async embed jobs`v2/rerank``Rerank`Retrieve Cohere available models`v1/models``Model`Produces an ordered array with text`v1/datasets``Dataset`Create a dataset by uploading a file, retrieve datasets`v1/finetuning``FineTuning`Trains, deploy, list datasetsYou can access them via:

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

Then you can use it simple :

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

Each endpoint returns a strongly typed DTO with the result of the API call.

To send a request without using provided resources, you can use directly the CohereClient sendRequesst() method

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

📚 Documentation by endpoints
----------------------------

[](#-documentation-by-endpoints)

- [Embedding](docs/embed.md)
- [Chat Completion](docs/chat.md)
- [Rerank](docs/rerank.md)
- [Model](docs/model.md)
- [Connector](docs/connector.md)
- [Classify](docs/classify.md)
- [Fine Tuning](docs/fine-tuning.md)
- [Dataset](docs/dataset.md)
- [Embed jobs](docs/embed-job.md)
- [Tokenize](docs/tokenize.md)
- [Detokenize](docs/detokenize.md)
- [A tutorial for Fine-tune and Classify a dataset](docs/embed-job.md)

Documentation 📚
---------------

[](#documentation-)

- 🧠 Cohere official docs:
- 📘 API Reference:
- 📦 This PHP client wraps the API endpoints in a friendly OO API with typed DTOs.

Contributing 🤝
--------------

[](#contributing-)

PRs are welcome! If you’d like to add support for more endpoints, improve tests or add features, feel free to open an issue or submit a PR.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance50

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

7

Last Release

364d ago

Major Versions

v0.3.3 → v1.02025-07-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11056924?v=4)[Clément Talleu](/maintainers/clementtalleu)[@clementtalleu](https://github.com/clementtalleu)

---

Top Contributors

[![clementtalleu](https://avatars.githubusercontent.com/u/11056924?v=4)](https://github.com/clementtalleu "clementtalleu (20 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/talleu-cohere-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/talleu-cohere-php-client/health.svg)](https://phpackages.com/packages/talleu-cohere-php-client)
```

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M318](/packages/openai-php-client)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M50](/packages/getbrevo-brevo-php)[n1ebieski/ksef-php-client

PHP API client that allows you to interact with the API Krajowego Systemu e-Faktur

9067.8k](/packages/n1ebieski-ksef-php-client)[trycourier/courier

Courier PHP SDK

15660.9k](/packages/trycourier-courier)[anthropic-ai/sdk

Anthropic PHP SDK

163583.3k17](/packages/anthropic-ai-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
