Using Cohere Models on OpenRouter
Cohere models are supported on OpenRouter, which provides a single API for models from many providers. You can use Cohere’s Command, Embed, Rerank, and North models through OpenRouter with an OpenRouter API key. Browse them on Cohere’s OpenRouter page.
Benefits
- One API and API key: Use Cohere models alongside models from other providers, with one API key and one account for billing.
- Easy switching: Move between models by changing the
modelparameter, without changing your integration. - Served by Cohere: Cohere is the provider for its models on OpenRouter, so OpenRouter forwards your requests to the Cohere API.
Latest additions: Embed 5 and Rerank 5
The latest Cohere models on OpenRouter are Embed 5 and Rerank 5, each available in Pro and Fast variants:
- Embed 5 (
cohere/embed-5-pro,cohere/embed-5-fast): Embeds text, images, and mixed text-and-image inputs such as PDF pages, with a 128k-token context window. Pro and Fast share an embedding space, so you can index with Pro and query with Fast. - Rerank 5 (
cohere/rerank-5-pro,cohere/rerank-5-fast): Reranks text with calibrated relevance scores, with a 32,768-token context window for each query and document combined.
Available models
For pricing, see each model’s OpenRouter page. For model details, see the models overview.
Setup checklist
- Create an OpenRouter account and an API key, and set the key as the
OPENROUTER_API_KEYenvironment variable. - Install the OpenRouter Python SDK with
pip install openrouter(Python 3.10 or later; source on GitHub), or call OpenRouter’s HTTP API directly. - Choose a model from the table above and pass its OpenRouter model ID as the
modelparameter. Each model’s OpenRouter page includes example requests. - Call the API for the model type:
- Command and North models: Chat
- Embed models: Embeddings
- Rerank models: Rerank
- To combine embeddings, reranking, and generation in one pipeline, follow OpenRouter’s RAG cookbook.
Differences from the Cohere API
OpenRouter’s APIs use OpenRouter’s request and response formats rather than Cohere’s, and support a subset of the Cohere API’s parameters:
- Chat: OpenRouter’s chat API is OpenAI-compatible. Supported parameters vary by model; for example, tool use
(
tools) is available for Command A+, Command R+ (08-2024), Command R (08-2024), and North Mini Code, but not for Command A or Command R7B. - Embeddings: OpenRouter supports
input,input_type,dimensions, andencoding_format(floatorbase64). Embeddings are returned indata[].embedding. To embed images, use OpenRouter’s multimodal input format. Forint8orbinaryembeddings, use the Cohere Embed API. - Rerank: OpenRouter supports
query,documents, andtop_n. Results are returned inresults[], each with anindex,relevance_score, anddocument. Context Focus (relevant_spans) isn’t part of OpenRouter’s Rerank API; to use it, call the Cohere Rerank API.