LegacyCohere has marked their
generate endpoint for LLMs as deprecated. Follow their migration guide to start using their Chat API via the ChatCohere integration.You are currently on a page documenting the use of Cohere models as text completion models. Many popular models available on Cohere are chat completion models.You may be looking for this page instead.
Cohere features and configuration options, please refer to the API reference.
Overview
Integration details
| Class | Package | Local | Serializable | PY support | Downloads | Version |
|---|---|---|---|---|---|---|
| Cohere | @langchain/cohere | ❌ | ✅ | ✅ |
Setup
To access Cohere models you’ll need to create a Cohere account, get an API key, and install the@langchain/cohere integration package.
Credentials
Head to cohere.com to sign up to Cohere and generate an API key. Once you’ve done this set theCOHERE_API_KEY environment variable:
Installation
The LangChain Cohere integration lives in the@langchain/cohere package:
Instantiation
Now we can instantiate our model object and generate chat completions:Custom client for Cohere on Azure, Cohere on AWS Bedrock, and Standalone Cohere Instance
We can instantiate a customCohereClient and pass it to the ChatCohere constructor.
Note: If a custom client is provided both COHERE_API_KEY environment variable and apiKey parameter in the constructor will be ignored.
Invocation
API reference
For detailed documentation of all Cohere features and configurations head to the API reference.Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.