cohere-common-errors

Diagnose and fix Cohere API v2 errors and exceptions. Use when encountering Cohere errors, debugging failed requests, or troubleshooting CohereError, CohereTimeoutError, rate limits. Trigger with phrases like "cohere error", "fix cohere", "cohere not working", "debug cohere", "cohere 429", "cohere 400".

25 stars

Best use case

cohere-common-errors is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Diagnose and fix Cohere API v2 errors and exceptions. Use when encountering Cohere errors, debugging failed requests, or troubleshooting CohereError, CohereTimeoutError, rate limits. Trigger with phrases like "cohere error", "fix cohere", "cohere not working", "debug cohere", "cohere 429", "cohere 400".

Teams using cohere-common-errors should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/cohere-common-errors/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/jeremylongshore/claude-code-plugins-plus-skills/cohere-common-errors/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/cohere-common-errors/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How cohere-common-errors Compares

Feature / Agentcohere-common-errorsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Diagnose and fix Cohere API v2 errors and exceptions. Use when encountering Cohere errors, debugging failed requests, or troubleshooting CohereError, CohereTimeoutError, rate limits. Trigger with phrases like "cohere error", "fix cohere", "cohere not working", "debug cohere", "cohere 429", "cohere 400".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Cohere Common Errors

## Overview
Quick reference for real Cohere API v2 errors with exact messages, causes, and fixes.

## Prerequisites
- `cohere-ai` SDK installed
- `CO_API_KEY` configured
- Access to error logs

## Error Reference

### 400 — Bad Request: Missing Required Field

```
CohereError: model is required
```

**Cause:** API v2 requires `model` for all endpoints (Chat, Embed, Rerank, Classify).

**Fix:**
```typescript
// Wrong (v1 style)
await cohere.chat({ messages: [...] });

// Correct (v2)
await cohere.chat({ model: 'command-a-03-2025', messages: [...] });
```

---

### 400 — Embed: Missing embedding_types

```
CohereError: embedding_types is required for embed models v3 and higher
```

**Fix:**
```typescript
await cohere.embed({
  model: 'embed-v4.0',
  texts: ['hello'],
  inputType: 'search_document',
  embeddingTypes: ['float'],  // Required for v3+
});
```

---

### 400 — Embed: Missing input_type

```
CohereError: input_type is required for embed models v3 and higher
```

**Fix:** Use one of: `search_document`, `search_query`, `classification`, `clustering`, `image`.

---

### 401 — Invalid API Token

```
CohereError: invalid api token
```

**Cause:** `CO_API_KEY` is missing, wrong, or revoked.

**Fix:**
```bash
# Verify key is set
echo $CO_API_KEY

# Test directly
curl -H "Authorization: Bearer $CO_API_KEY" \
  https://api.cohere.com/v2/chat \
  -H "Content-Type: application/json" \
  -d '{"model":"command-r7b-12-2024","messages":[{"role":"user","content":"hi"}]}'
```

---

### 429 — Rate Limit Exceeded

```
CohereError: You are using a Trial key, which is limited to N calls/minute
```

**Rate limits by key type:**

| Key Type | Chat | Embed | Rerank | Other |
|----------|------|-------|--------|-------|
| Trial | 20/min | 5/min | 5/min | 1000/month |
| Production | 1000/min | 1000/min | 1000/min | Unlimited |

**Fix:**
```typescript
import { CohereError } from 'cohere-ai';

try {
  await cohere.chat({ model: 'command-a-03-2025', messages: [...] });
} catch (err) {
  if (err instanceof CohereError && err.statusCode === 429) {
    // Back off and retry
    await new Promise(r => setTimeout(r, 60_000)); // wait 60s for trial keys
    // retry...
  }
}
```

---

### 400 — Classify: Too Few Examples

```
CohereError: each unique label requires at least 2 examples
```

**Fix:**
```typescript
await cohere.classify({
  model: 'embed-english-v3.0',
  inputs: ['This product is amazing'],
  examples: [
    // Need at least 2 examples PER label
    { text: 'I love it', label: 'positive' },
    { text: 'Great product', label: 'positive' },
    { text: 'Terrible', label: 'negative' },
    { text: 'Worst ever', label: 'negative' },
  ],
});
```

---

### 400 — Rerank: Too Many Documents

```
CohereError: too many documents, max is 1000
```

**Fix:** Batch your documents:
```typescript
async function batchRerank(query: string, docs: string[], topN = 10) {
  const BATCH = 1000;
  let allResults: any[] = [];

  for (let i = 0; i < docs.length; i += BATCH) {
    const batch = docs.slice(i, i + BATCH);
    const resp = await cohere.rerank({
      model: 'rerank-v3.5',
      query,
      documents: batch,
      topN,
    });
    allResults.push(
      ...resp.results.map(r => ({ ...r, index: r.index + i }))
    );
  }

  return allResults.sort((a, b) => b.relevanceScore - a.relevanceScore).slice(0, topN);
}
```

---

### 400 — Chat: response_format with documents

```
CohereError: response_format is not supported with documents or tools
```

**Cause:** `response_format: { type: 'json_object' }` cannot be combined with `documents` or `tools`.

**Fix:** Use either JSON mode OR document/tool mode, not both. For structured RAG output, parse the text response yourself.

---

### 500/503 — Server Error

```
CohereError: internal server error
```

**Fix:** Retry with exponential backoff. If persistent, check [status.cohere.com](https://status.cohere.com).

---

### CohereTimeoutError

```
CohereTimeoutError: Request timed out
```

**Fix:** The SDK has a default timeout. Increase it or reduce payload:
```typescript
const cohere = new CohereClientV2({
  token: process.env.CO_API_KEY,
  timeoutInSeconds: 120, // default is lower
});
```

## Diagnostic Commands

```bash
# Check Cohere service status
curl -s https://status.cohere.com/api/v2/status.json | jq '.status'

# Verify API key works
curl -s -o /dev/null -w "%{http_code}" \
  -H "Authorization: Bearer $CO_API_KEY" \
  https://api.cohere.com/v2/chat \
  -H "Content-Type: application/json" \
  -d '{"model":"command-r7b-12-2024","messages":[{"role":"user","content":"ping"}]}'

# Check installed SDK version
npm list cohere-ai 2>/dev/null || pip show cohere 2>/dev/null
```

## Error Handling Wrapper

```typescript
import { CohereError, CohereTimeoutError } from 'cohere-ai';

function diagnoseCohereError(err: unknown): string {
  if (err instanceof CohereTimeoutError) {
    return 'TIMEOUT: Increase timeoutInSeconds or reduce input size';
  }
  if (err instanceof CohereError) {
    switch (err.statusCode) {
      case 400: return `BAD_REQUEST: ${err.message}`;
      case 401: return 'AUTH: Check CO_API_KEY';
      case 429: return 'RATE_LIMIT: Back off or upgrade key';
      case 500: return 'SERVER: Retry later, check status.cohere.com';
      default:  return `UNKNOWN (${err.statusCode}): ${err.message}`;
    }
  }
  return `UNEXPECTED: ${String(err)}`;
}
```

## Resources
- [Cohere Error Codes](https://docs.cohere.com/reference/errors)
- [Cohere Status Page](https://status.cohere.com)
- [Rate Limits](https://docs.cohere.com/docs/rate-limits)
- [API v1 to v2 Migration](https://docs.cohere.com/docs/migrating-v1-to-v2)

## Next Steps
For comprehensive debugging, see `cohere-debug-bundle`.

Related Skills

fathom-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix Fathom API errors including auth failures and missing data. Use when API calls fail, transcripts are empty, or webhooks are not firing. Trigger with phrases like "fathom error", "fathom not working", "fathom api failure", "fix fathom".

exa-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix Exa API errors by HTTP code and error tag. Use when encountering Exa errors, debugging failed requests, or troubleshooting integration issues. Trigger with phrases like "exa error", "fix exa", "exa not working", "debug exa", "exa 429", "exa 401".

evernote-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix common Evernote API errors. Use when encountering Evernote API exceptions, debugging failures, or troubleshooting integration issues. Trigger with phrases like "evernote error", "evernote exception", "fix evernote issue", "debug evernote", "evernote troubleshooting".

elevenlabs-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix ElevenLabs API errors by HTTP status code. Use when encountering ElevenLabs errors, debugging failed TTS/STS requests, or troubleshooting voice cloning and streaming issues. Trigger: "elevenlabs error", "fix elevenlabs", "elevenlabs not working", "debug elevenlabs", "elevenlabs 401", "elevenlabs 429", "elevenlabs 400".

documenso-common-errors

25
from ComeOnOliver/skillshub

Diagnose and resolve common Documenso API errors and issues. Use when encountering Documenso errors, debugging integration issues, or troubleshooting failed operations. Trigger with phrases like "documenso error", "documenso 401", "documenso failed", "fix documenso", "documenso not working".

deepgram-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix common Deepgram errors and issues. Use when troubleshooting Deepgram API errors, debugging transcription failures, or resolving integration issues. Trigger: "deepgram error", "deepgram not working", "fix deepgram", "deepgram troubleshoot", "transcription failed", "deepgram 401".

cursor-common-errors

25
from ComeOnOliver/skillshub

Troubleshoot common Cursor IDE errors: authentication, completion, indexing, API, and performance issues. Triggers on "cursor error", "cursor not working", "cursor issue", "cursor problem", "fix cursor", "cursor crash".

coreweave-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix CoreWeave GPU scheduling, pod, and networking errors. Use when pods are stuck Pending, GPUs are not allocated, or experiencing CUDA and NCCL errors. Trigger with phrases like "coreweave error", "coreweave pod pending", "coreweave gpu not found", "coreweave debug", "fix coreweave".

cohere-webhooks-events

25
from ComeOnOliver/skillshub

Implement Cohere streaming event handling, SSE patterns, and connector webhooks. Use when building streaming UIs, handling chat/tool events, or registering Cohere connectors for RAG. Trigger with phrases like "cohere streaming", "cohere events", "cohere SSE", "cohere connectors", "cohere webhook".

cohere-upgrade-migration

25
from ComeOnOliver/skillshub

Migrate from Cohere API v1 to v2 and upgrade SDK versions. Use when upgrading cohere-ai SDK, migrating from CohereClient to CohereClientV2, or handling breaking changes between API versions. Trigger with phrases like "upgrade cohere", "cohere migration", "cohere v1 to v2", "update cohere SDK", "cohere breaking changes".

cohere-security-basics

25
from ComeOnOliver/skillshub

Apply Cohere security best practices for API key management and access control. Use when securing API keys, implementing key rotation, or auditing Cohere security configuration. Trigger with phrases like "cohere security", "cohere secrets", "secure cohere", "cohere API key security", "cohere key rotation".

cohere-sdk-patterns

25
from ComeOnOliver/skillshub

Apply production-ready Cohere SDK patterns for TypeScript and Python. Use when implementing Cohere integrations, refactoring SDK usage, or establishing team coding standards for Cohere API v2. Trigger with phrases like "cohere SDK patterns", "cohere best practices", "cohere code patterns", "idiomatic cohere", "cohere wrapper".