Download the PHP package talleu/cohere-php-client without Composer

On this page you can find all versions of the php package talleu/cohere-php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cohere-php-client

PHPStan Packagist Version GitHub


Cohere PHP Client

A PHP client to interact with the Cohereยฎ API, designed to be framework-agnostic, simple to use, and fully compatible with 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 ๐Ÿ› ๏ธ


Requirements โš™๏ธ

Installation ๐Ÿ“

Install the library via Composer:

Then install your preferred HTTP client

Using Symfony HttpClient:

Using Guzzle:

Or another client implementing PSR18

Basic Usage ๐ŸŽฏ

Minimal example

Or to simple chats with LLM

Authentication ๐Ÿ”

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

Or use an environment variable (recommended):

Available Endpoints ๐Ÿ“š

The following endpoints are supported:

Endpoint Class Description
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 datasets

You can access them via:

Then you can use it simple :

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

๐Ÿ“š Documentation by endpoints

Documentation ๐Ÿ“š

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.


All versions of cohere-php-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-json Version *
php-http/discovery Version ^1.20
psr/http-client-implementation Version *
psr/http-factory-implementation Version *
psr/http-client Version ^1.0
psr/http-message Version ^2.0
psr/http-factory Version ^1.1
nyholm/psr7 Version ^1.8
php-http/multipart-stream-builder Version ^1.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package talleu/cohere-php-client contains the following files

Loading the files please wait ...