Cohere Install & Auth
Overview
Set up the Cohere SDK (v2) and configure authentication for Chat, Embed, Rerank, and Classify endpoints.
Prerequisites
- Node.js 18+ or Python 3.10+
- Package manager (npm, pnpm, or pip)
- Cohere account at dashboard.cohere.com
- API key from Cohere dashboard (trial keys are free, production keys require billing)
Instructions
Step 1: Install SDK
# Node.js / TypeScript
npm install cohere-ai
# Python
pip install cohere
Step 2: Configure API Key
# Set environment variable
export CO_API_KEY="your-api-key-here"
# Or create .env file (add .env to .gitignore!)
echo 'CO_API_KEY=your-api-key-here' >> .env
Key types:
- Trial key — free, rate-limited (5-20 calls/min per endpoint, 1000/month others)
- Production key — metered billing, 1000 calls/min all endpoints, unlimited monthly
Step 3: Verify Connection (TypeScript)
import { CohereClientV2 } from 'cohere-ai';
const cohere = new CohereClientV2({
token: process.env.CO_API_KEY,
});
async function verify() {
const response = await cohere.chat({
model: 'command-a-03-2025',
messages: [
{ role: 'user', content: 'Say "connection verified" and nothing else.' },
],
});
console.log('Status:', response.message?.content?.[0]?.text);
}
verify().catch(console.error);
Step 4: Verify Connection (Python)
import cohere
import os
co = cohere.ClientV2(api_key=os.environ.get("CO_API_KEY"))
response = co.chat(
model="command-a-03-2025",
messages=[
{"role": "user", "content": "Say 'connection verified' and nothing else."}
],
)
print("Status:", response.message.content[0].text)
Available Models
| Model |
ID |
Context |
Best For |
| Command A |
command-a-03-2025 |
256K |
Latest, most capable |
| Command R+ |
command-r-plus-08-2024 |
128K |
Complex RAG, agents |
| Command R |
command-r-08-2024 |
128K |
RAG, cost-effective |
| Command R7B |
command-r7b-12-2024 |
128K |
Fast, lightweight |
| Embed English v4 |
embed-v4.0 |
128K |
Embeddings (EN) |
| Embed Multilingual v3 |
embed-multilingual-v3.0 |
512 |
Embeddings (100+ langs) |
| Rerank v3.5 |
rerank-v3.5 |
4K |
Search reranking |
Output
- Installed
cohere-ai (TS) or cohere (Python) package
- Environment variable
CO_API_KEY configured
- Verified API connectivity with a chat completion
Error Handling
| Error |
Cause |
Solution |
CohereApiError: invalid api token |
Wrong or expired key |
Regenerate at dashboard.cohere.com |
CohereConnectionError |
Network blocked |
Ensure HTTPS to api.cohere.com allowed |
429 Too Many Requests |
Trial rate limit hit |
Wait 60s or upgrade to production key |
MODULE_NOT_FOUND cohere-ai |
Package not installed |
Run npm install cohere-ai |
SDK Auto-Detection
The SDK reads CO_API_KEY automatically if set. You can skip the token param:
// Auto-reads CO_API_KEY from environment
const cohere = new CohereClientV2();
Resources
Next Steps
After successful auth, proceed to cohere-hello-world for your first real API call.
1---
2name: cohere-install-auth
3description: |
4 Install and configure Cohere SDK authentication with API v2.
5 Use when setting up a new Cohere integration, configuring API keys,
6 or initializing the CohereClientV2 in your project.
7 Trigger with phrases like "install cohere", "setup cohere",
8 "cohere auth", "configure cohere API key".
9allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(pip:*), Grep
10version: 1.0.0
11license: MIT
12author: Jeremy Longshore <jeremy@intentsolutions.io>
13tags: [saas, ai, nlp, cohere]
14compatible-with: claude-code
15metadata:
16 source: https://skillmd.com/skills/aibot88/cohere-install-auth
17---
18
19# Cohere Install & Auth
20
21## Overview
22Set up the Cohere SDK (v2) and configure authentication for Chat, Embed, Rerank, and Classify endpoints.
23
24## Prerequisites
25- Node.js 18+ or Python 3.10+
26- Package manager (npm, pnpm, or pip)
27- Cohere account at [dashboard.cohere.com](https://dashboard.cohere.com)
28- API key from Cohere dashboard (trial keys are free, production keys require billing)
29
30## Instructions
31
32### Step 1: Install SDK
33
34```bash
35# Node.js / TypeScript
36npm install cohere-ai
37
38# Python
39pip install cohere
40```
41
42### Step 2: Configure API Key
43
44```bash
45# Set environment variable
46export CO_API_KEY="your-api-key-here"
47
48# Or create .env file (add .env to .gitignore!)
49echo 'CO_API_KEY=your-api-key-here' >> .env
50```
51
52**Key types:**
53- **Trial key** — free, rate-limited (5-20 calls/min per endpoint, 1000/month others)
54- **Production key** — metered billing, 1000 calls/min all endpoints, unlimited monthly
55
56### Step 3: Verify Connection (TypeScript)
57
58```typescript
59import { CohereClientV2 } from 'cohere-ai';
60
61const cohere = new CohereClientV2({
62 token: process.env.CO_API_KEY,
63});
64
65async function verify() {
66 const response = await cohere.chat({
67 model: 'command-a-03-2025',
68 messages: [
69 { role: 'user', content: 'Say "connection verified" and nothing else.' },
70 ],
71 });
72 console.log('Status:', response.message?.content?.[0]?.text);
73}
74
75verify().catch(console.error);
76```
77
78### Step 4: Verify Connection (Python)
79
80```python
81import cohere
82import os
83
84co = cohere.ClientV2(api_key=os.environ.get("CO_API_KEY"))
85
86response = co.chat(
87 model="command-a-03-2025",
88 messages=[
89 {"role": "user", "content": "Say 'connection verified' and nothing else."}
90 ],
91)
92print("Status:", response.message.content[0].text)
93```
94
95## Available Models
96
97| Model | ID | Context | Best For |
98|-------|----|---------|----------|
99| Command A | `command-a-03-2025` | 256K | Latest, most capable |
100| Command R+ | `command-r-plus-08-2024` | 128K | Complex RAG, agents |
101| Command R | `command-r-08-2024` | 128K | RAG, cost-effective |
102| Command R7B | `command-r7b-12-2024` | 128K | Fast, lightweight |
103| Embed English v4 | `embed-v4.0` | 128K | Embeddings (EN) |
104| Embed Multilingual v3 | `embed-multilingual-v3.0` | 512 | Embeddings (100+ langs) |
105| Rerank v3.5 | `rerank-v3.5` | 4K | Search reranking |
106
107## Output
108- Installed `cohere-ai` (TS) or `cohere` (Python) package
109- Environment variable `CO_API_KEY` configured
110- Verified API connectivity with a chat completion
111
112## Error Handling
113| Error | Cause | Solution |
114|-------|-------|----------|
115| `CohereApiError: invalid api token` | Wrong or expired key | Regenerate at dashboard.cohere.com |
116| `CohereConnectionError` | Network blocked | Ensure HTTPS to `api.cohere.com` allowed |
117| `429 Too Many Requests` | Trial rate limit hit | Wait 60s or upgrade to production key |
118| `MODULE_NOT_FOUND cohere-ai` | Package not installed | Run `npm install cohere-ai` |
119
120## SDK Auto-Detection
121The SDK reads `CO_API_KEY` automatically if set. You can skip the `token` param:
122
123```typescript
124// Auto-reads CO_API_KEY from environment
125const cohere = new CohereClientV2();
126```
127
128## Resources
129- [Cohere API v2 Reference](https://docs.cohere.com/reference/about)
130- [Cohere Dashboard](https://dashboard.cohere.com)
131- [Cohere Models Overview](https://docs.cohere.com/docs/models)
132- [API Key & Rate Limits](https://docs.cohere.com/docs/rate-limits)
133
134## Next Steps
135After successful auth, proceed to `cohere-hello-world` for your first real API call.