Cohere API Key: Create, Secure, and Use
What you’ll build
Section titled “What you’ll build”By the end of this guide you will have a Cohere API key stored in an environment variable and a working Python call that returns a chat completion. You will also understand the difference between Cohere’s trial and production keys and when to upgrade.
Prerequisites
Section titled “Prerequisites”| Requirement | Notes |
|---|---|
| Cohere account | Sign up at dashboard.cohere.com |
| Verified email | Required before creating keys |
| Payment method | Only required for production keys |
| Python 3.9+ | To run the verification samples |
The free trial key works without a payment method and covers development and testing.
Step 1 — Get your API key
Section titled “Step 1 — Get your API key”Cohere provides a trial key automatically on account creation.
- Sign in at dashboard.cohere.com.
- Click API Keys in the left sidebar.
- Your trial key is listed here. Copy it.
- To create an additional key, click Create API Key, give it a name, and click Create.
Unlike some providers, Cohere lets you view the full key value at any time from the dashboard.
Step 2 � Trial vs. production keys
Section titled “Step 2 � Trial vs. production keys”| Trial key | Production key | |
|---|---|---|
| Payment required | No | Yes |
| Rate limit | 100 requests/min | Higher (plan-dependent) |
| Monthly quota | Limited | Pay-as-you-go |
| Suitable for | Development and testing | Live applications |
For production workloads, go to Billing in the dashboard, add a payment method, and use a production key.
Step 3 � Store the key securely
Section titled “Step 3 � Store the key securely”Linux / macOS (current shell session):
export COHERE_API_KEY="your-key-here"Windows PowerShell (current session):
$env:COHERE_API_KEY = "your-key-here".env file for local development (add .env to .gitignore):
COHERE_API_KEY=your-key-hereLoad it in Python with python-dotenv:
from dotenv import load_dotenvload_dotenv()Step 4 � Verify the key works
Section titled “Step 4 � Verify the key works”Install the SDK, then run a minimal request.
pip install cohereSave as check_key.py and run with python check_key.py (Python 3.9+):
import cohereimport os
co = cohere.ClientV2(api_key=os.environ["COHERE_API_KEY"])
response = co.chat( model="command-r-plus", messages=[{"role": "user", "content": "Reply with the word VERIFIED."}],)
print(response.message.content[0].text)# Expected output: VERIFIEDOr use cURL:
curl https://api.cohere.com/v2/chat \ -H "Authorization: Bearer $COHERE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "command-r-plus", "messages": [{"role": "user", "content": "Reply with the word VERIFIED."}] }'Available models
Section titled “Available models”| Model | Best for |
|---|---|
command-r-plus |
Complex reasoning, retrieval-augmented generation |
command-r |
Balanced general-purpose tasks |
command-light |
Fast responses, lower cost |
embed-english-v3.0 |
English semantic search |
embed-multilingual-v3.0 |
Multilingual embeddings |
rerank-english-v3.0 |
Re-scoring search results for relevance |
Model availability and pricing change. Check docs.cohere.com/docs/models for the current list.
Managing keys
Section titled “Managing keys”View keys: Dashboard � API Keys shows each key’s name, type, creation date, and actions.
Delete a key: Click the trash icon and confirm. Any application using that key immediately receives 401 Unauthorized.
Troubleshooting
Section titled “Troubleshooting”| Error | Likely cause | Fix |
|---|---|---|
401 Unauthorized |
Key missing, wrong value, or deleted | Re-check the Authorization: Bearer header. Verify the key in the dashboard. |
429 Too many requests |
Trial rate limit hit | Implement exponential backoff or upgrade to a production key. |
model not found |
Model name incorrect | Check current model IDs at docs.cohere.com. |
Next steps
Section titled “Next steps”- RAG vs agentic RAG � Cohere’s Embed and Rerank models are well suited for RAG pipelines
- LLM model selection guide � choosing between Cohere, OpenAI, Anthropic, and Google
- API Tokens overview � comparison of all supported providers
Official references
Section titled “Official references”- Cohere Dashboard � key management and billing
- Cohere API documentation � versioned REST and SDK reference
- Models list � current model IDs and capabilities
- Python SDK �
coherepackage on PyPI