Cohere API
LLMs for text generation, embeddings, classification and reranking.
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
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 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"}]}'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].text | Chat reply text (v2 API) |
| results[].index | Rerank: position of the document in your input list |
| results[].relevance_score | Rerank: 0–1 relevance for that document |
| embeddings.float[] | Embed: the vector(s) for your input texts |
| meta.billed_units | Tokens or search units you were charged |
Common errors
| 401 | Invalid API key. |
| 429 | Trial-key rate or monthly limit reached — slow down or upgrade. |
| 400 | Unknown model name or malformed documents/messages. |
| 500 | Transient — 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