API Directory › 🤖 AI & Machine Learning › Cohere
API KeyHTTPSCORS

Cohere API

LLMs for text generation, embeddings, classification and reranking.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open Cohere docs ↗

What it does

Cohere provides enterprise-focused language models: the Command family for chat and generation, Embed for multilingual text embeddings, and Rerank for reordering search results by relevance. Rerank in particular is a popular drop-in quality boost for retrieval pipelines.

Base URL

https://api.cohere.com/v2

Authentication

Sign up at dashboard.cohere.com and copy your API key. Send it as Authorization: Bearer YOUR_KEY. Trial keys are free and rate-limited; production keys are pay-as-you-go with much higher limits.

Code examples

curl
curl https://api.cohere.com/v2/chat \
  -H "Authorization: Bearer $CO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"command-r-plus","messages":[{"role":"user","content":"Say hi"}]}'
Python
import cohere

co = cohere.ClientV2()  # reads CO_API_KEY

res = co.rerank(
    model="rerank-v3.5",
    query="best free weather api",
    documents=["OpenWeatherMap docs", "A cake recipe", "Open-Meteo docs"],
    top_n=2,
)
print([(r.index, round(r.relevance_score, 3)) for r in res.results])

Rate limits & quotas

Trial keys are capped low — roughly 20 calls/minute for chat and similar for embed/rerank, plus a monthly ceiling of about 1,000 calls, and they may not be used in production. Production keys lift this to thousands per minute and are billed per token (chat/embed) or per search unit (rerank).

Key response fields

message.content[0].textChat reply text (v2 API)
results[].indexRerank: position of the document in your input list
results[].relevance_scoreRerank: 0–1 relevance for that document
embeddings.float[]Embed: the vector(s) for your input texts
meta.billed_unitsTokens or search units you were charged

Common errors

401Invalid API key.
429Trial-key rate or monthly limit reached — slow down or upgrade.
400Unknown model name or malformed documents/messages.
500Transient — retry with backoff.

When to use it (and alternatives)

Strongest pick when you need first-class reranking or high-quality multilingual embeddings for search and RAG. For general chat it competes with the OpenAI API and Claude.

FAQ

What is Cohere Rerank used for?

You run a cheap first-pass search (keyword or vector), then pass the top ~50–100 hits plus the query to Rerank, which reorders them by true semantic relevance. It typically improves answer quality in RAG more than swapping the generator model.

Can I use a trial key in production?

No — trial keys are for evaluation, are heavily rate-limited and can be deprecated. Move to a production key before you launch.

Does Cohere support tool calling?

Yes, the v2 Chat endpoint supports tools/function calling and structured outputs, similar to other chat APIs.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

Prompt ImproverLearn Prompt Engineering

Related AI & Machine Learning APIs

← Back

More AI & Machine Learning APIs · All 196 APIs