Skip to main content
Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.

Installation and setup

  • Install the Python SDK :
Get a Cohere api key and set it as an environment variable (COHERE_API_KEY)

Cohere langchain integrations

Quick copy examples

Chat

Usage of the Cohere chat model

LLM

Usage of the Cohere (legacy) LLM model

Tool calling

Tool calling with Cohere LLM can be done by binding the necessary tools to the llm as seen above. An alternative, is to support multi hop tool calling with the ReAct agent as seen below.

ReAct Agent

The agent is based on the paper ReAct: Synergizing Reasoning and Acting in Language Models.
The langchain-community package is no longer maintained. Examples that import from langchain_community may be outdated or broken. Use with caution.
The ReAct agent can be used to call multiple tools in sequence.

RAG retriever

Usage of the Cohere RAG Retriever

Text embedding

Usage of the Cohere Text Embeddings model

Reranker

Usage of the Cohere Reranker