Cohere API
Chat with Command models, use tools, answer from documents with citations, get JSON, embed text and images, rerank and classify.
AI & machine learningGuided#cohere#llm#rag#embeddings#rerank#chat#citations
Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.
Overview
Cohere's API is built for business search and assistants: Chat with the Command models (with tool use, grounded answers with citations over your own documents, JSON output, reasoning and image input), Embed for semantic search and classification over text and images, Rerank to put the most relevant results first in any search pipeline, plus Classify, models and tokenizer endpoints. This collection uses the current v2 endpoints for chat, embed and rerank, and the v1 endpoints where Cohere has no v2 version (models, classify, tokenize, detokenize).
Get an API key
- Sign up or sign in at the Cohere dashboard.
- Open API keys. A free trial (evaluation) key is available straight away; it is rate-limited and capped at 1,000 calls a month, which is enough to run this collection.
- For real traffic, add billing and create a production key on the same page. Some newer chat models (such as Command A+ and Command A Reasoning) need a sales contact before production keys get production limits.
- Paste the key into the apiKey variable here. It is marked secret, so it is never shown or shared when you fork or publish.
Authentication and base URL
Send the key as a bearer token: Authorization: Bearer <key> (the collection sets it). Optionally add X-Client-Name to label which app made the call. Base URL: https://api.cohere.com; paths start with /v2/ or /v1/ as shown on each request.
Models
The model variable defaults to command-a-03-2025 (Command A: 256k context, text, production rate limits on production keys). command-a-plus-05-2026 (Command A+) is the newest Command model and reads images; command-a-reasoning-08-2025 thinks before answering; command-a-vision-07-2025 is the vision model; command-r7b-12-2024 is small and fast. command, command-light, command-r and command-r-plus (the undated aliases) are deprecated. For search: embed-v5.0-pro / embed-v5.0-fast (text and images) and rerank-v5.0-pro, which Cohere recommends for new projects. See Models or run List models.
How to use this collection
- Set apiKey and run 1. Start here (list models, first chat).
- 2. Chat covers system messages and history, streaming, JSON output, reasoning and images.
- 3. Tool use is a two-request round trip; the first request saves the tool call for the second.
- 4. Grounded answers (RAG) answers from documents you pass in, with citations.
- 5. Embed, 6. Rerank, 7. Classify and 8. Tokens cover the rest.
Common errors
| Status | Meaning | What to do |
|---|---|---|
| 400 | Invalid body | Missing or invalid field; read the message. |
| 401 | Bad key | Key missing, wrong or expired. |
| 402 | Billing limit reached | Add or update payment, or raise the key's spending limit in the dashboard. |
| 404 | Not found | Wrong model name or resource ID. |
| 422 | Unprocessable | A value is the wrong type or out of range. |
| 429 | Rate limited | Trial keys have low per-minute limits and a monthly cap: slow down or use a production key. |
| 499 | Cancelled | The request was cancelled; retry. |
| 500 / 503 / 504 | Server side | Retry with backoff; contact support if it persists. |
Limits and pricing
Chat is billed per input and output token, Embed per input token (and image), and Rerank per search unit; trial keys are free but limited. Every response reports billed units (usage.billed_units on chat, meta.billed_units elsewhere). See Pricing, How pricing works, Rate limits, Errors and the API reference.
Endpoints 17
1. Start here
- GETList models
/v1/modelsLists Cohere models with what each can do: name (the value for model), endpoints it works with, context_length, features (for example tool use or JSON schema… - GETGet one model
/v1/models/{{model}}Returns one model's details (same fields as in List models). Check is_deprecated before you build on a model, and context_length for how much text it accepts.… - POSTChat: first message
/v2/chatPOST /v2/chat takes model and messages (each with a role: system, user, assistant or tool, and content) and returns one assistant message. Reading the answer:…
2. Chat
- POSTSystem message and conversation history
/v2/chatChat v2 is stateless: send the conversation so far every time. Put instructions in a system message first, then alternate user and assistant messages, ending… - POSTStream the answer
/v2/chatWith "stream": true the response is a stream of server-sent events, each with a type: Append each content-delta text to show the answer as it is written. - POSTJSON output with a schema
/v2/chatresponse_format with type: "json_object" makes the answer valid JSON; add schema (a JSON Schema) to make it match a shape. The JSON is the text in… - POSTReasoning (thinking)
/v2/chatcommand-a-reasoning-08-2025 can think before it answers. Control it with thinking: {"type": "enabled", "token_budget": N} caps thinking tokens, {"type":… - POSTAsk about an image
/v2/chatPut a list of parts in the user message's content: {"type": "text"} and {"type": "image_url", "image_url": {"url": ..., "detail": "auto"}}. url is an https…
3. Tool use
- POST1) Offer a tool
/v2/chatDescribe each tool as {"type": "function", "function": {"name", "description", "parameters"}} with a JSON Schema for the parameters. When the model wants a… - POST2) Send the tool result back
/v2/chatRepeat the conversation, then add the assistant message from the previous reply (tool_plan and tool_calls, unchanged) and one tool message per call:…
4. Grounded answers (RAG)
- POSTChat with documents and citations
/v2/chatPass the texts the answer must come from in documents: plain strings, or objects {"id": ..., "data": {...}} where data holds any fields (title, snippet, url).…
5. Embed
- POSTEmbed documents for search
/v2/embedPOST /v2/embed returns vectors for up to 96 texts per call. Vectors come back grouped by type: embeddings.float[i] belongs to texts[i]. Embed documents once… - POSTEmbed a search query (text and image inputs)
/v2/embedEmbeds the user's search with input_type: search_query. This example uses inputs instead of texts: each input has a content list that can mix {"type": "text"}…
6. Rerank
- POSTRerank documents
/v2/rerankGive a query and a list of documents (strings; put structured records in as YAML text) and get them back ordered from most to least relevant. It works on…
7. Classify
- POSTClassify with examples
/v1/classifyPOST /v1/classify labels up to 96 inputs using examples you provide (text and label; at least 2 per label, up to 2,500 in total). Pass model only for a…
8. Tokens
- POSTTokenize text
/v1/tokenizeSplits text (1 to 65,536 characters) into the tokens of model's tokenizer. Returns tokens (IDs) and token_strings. Use it to check a prompt fits a model's… - POSTDetokenize tokens
/v1/detokenizeTurns a list of token IDs back into text with model's tokenizer; useful when debugging token-level output. tokenIds is a JSON array set by Tokenize text (it…
API details
- Base URL
https://api.cohere.com- Authentication
- A bearer token in the Authorization header
- Operations
- 17 operations on 17 pathsPOST 15GET 2
- Main resources
- 1. Start here 32. Chat 53. Tool use 24. Grounded answers (RAG) 15. Embed 26. Rerank 17. Classify 18. Tokens 2
- Description format
- Swastik Codes guided collection, API version
checked against the docs on 2026-11-17 - Links
- Documentation
How to test the Cohere API in Swastik Codes
- Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
- Fork it into your workspaceChoose a workspace. You get your own copy of the Cohere API collection, without the publisher's secrets.
- Add your credentialsThis API uses A bearer token in the Authorization header. Add yours in the collection's variables or an environment; the requests already reference it.
- Send a requestPick an endpoint, for example “List models” (GET /v1/models), and press Send. Check the response, add tests and run the whole collection with the runner.
Frequently asked questions
What is the Cohere API?
Chat with Command models, use tools, answer from documents with citations, get JSON, embed text and images, rerank and classify. It is listed under AI & machine learning and has 17 endpoints.
Who publishes the Cohere API?
It is listed from Cohere's public API description (an OpenAPI document), not published by Cohere on Swastik Codes. Anyone who controls cohere.ai can claim the profile by adding a DNS TXT record.
What is the base URL of the Cohere API?
Requests go to https://api.cohere.com. Endpoint paths are added to this base URL.
How do I authenticate with the Cohere API?
With A bearer token in the Authorization header.
How many endpoints does the Cohere API have?
17 operations on 17 paths (15 POST, 2 GET). The largest groups are 1. Start here, 2. Chat, 3. Tool use, 4. Grounded answers (RAG).
Is forking the Cohere API free?
Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.