| name | cohere-rate-limits |
| description | Implement Cohere rate limiting, backoff, and request queuing patterns.
Use when handling 429 errors, implementing retry logic,
or optimizing API request throughput for Cohere.
Trigger with phrases like "cohere rate limit", "cohere throttling",
"cohere 429", "cohere retry", "cohere backoff".
|
| allowed-tools | Read, Write, Edit |
| version | 1.5.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ai","nlp","cohere"] |
| compatibility | Designed for Claude Code |
Cohere Rate Limits
Overview
Handle Cohere rate limits with exponential backoff, request queuing, and proactive throttling. Real rate limits from Cohere's documentation.
Prerequisites
cohere-ai SDK installed
- Understanding of async/await patterns
Actual Cohere Rate Limits
| Key Type | Endpoint | Rate Limit | Monthly Limit |
|---|
| Trial | Chat | 20 calls/min | 1,000 total |
| Trial | Embed | 5 calls/min | 1,000 total |
| Trial | Rerank | 5 calls/min | 1,000 total |
| Trial | Classify | 5 calls/min | 1,000 total |
| Production | All endpoints | 1,000 calls/min | Unlimited |
Trial keys are free. Production keys require billing at dashboard.cohere.com.
Instructions
Step 1: Exponential Backoff with Jitter
import { CohereError, CohereTimeoutError } from 'cohere-ai';
interface RetryConfig {
maxRetries: number;
baseDelayMs: number;
maxDelayMs: number;
}
const DEFAULT_RETRY: RetryConfig = {
maxRetries: 5,
baseDelayMs: 1000,
maxDelayMs: 60_000,
};
async function withBackoff<T>(
: <T>,
config =
): <T> {
( attempt = ; attempt <= config.; attempt++) {
{
();
} (err) {
(attempt === config.) err;
shouldRetry = ;
: | ;
(err ) {
(err. === ) {
shouldRetry = ;
} (err. && err. >= ) {
shouldRetry = ;
}
} (err ) {
shouldRetry = ;
}
(!shouldRetry) err;
exponential = config. * .(, attempt);
jitter = .() * config.;
delay = .(exponential + jitter, config.);
.();
( (r, retryAfterMs ?? delay));
}
}
();
}