Skip to main content
You are currently on a page documenting the use of Cohere models as text completion models. Many popular Cohere models are chat completion models.You may be looking for this page instead.
Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.
Head to the API reference for detailed documentation of all attributes and methods.

Overview

Integration details

Setup

The integration lives in the langchain-community package. We also need to install the cohere package itself. We can install these with:

Credentials

We’ll need to get a Cohere API key and set the COHERE_API_KEY environment variable:

Installation

It’s also helpful (but not needed) to set up LangSmith for best-in-class observability

Invocation

Cohere supports all LLM functionality:

Chaining

You can also easily combine with a prompt template for easy structuring of user input. We can do this using LCEL

API reference

For detailed documentation of all Cohere llm features and configurations head to the API reference: python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html