| name | mistral-rate-limits |
| description | Implement Mistral AI rate limiting, backoff, and request management.
Use when handling rate limit errors, implementing retry logic,
or optimizing API request throughput for Mistral AI.
Trigger with phrases like "mistral rate limit", "mistral throttling",
"mistral 429", "mistral retry", "mistral backoff".
|
| allowed-tools | Read, Write, Edit |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","mistral","api"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Mistral Rate Limits
Overview
Rate limit management for Mistral AI API. Mistral enforces per-workspace RPM (requests/minute) and TPM (tokens/minute) limits that vary by usage tier (Experiment free tier vs Scale pay-as-you-go). View your workspace limits at admin.mistral.ai/plateforme/limits.
Prerequisites
- Mistral API key configured
- Understanding of workspace tier (Experiment vs Scale)
- Application with retry infrastructure
Mistral Rate Limit Architecture
Limits are set at the workspace level, not per key. All API keys in a workspace share the same RPM/TPM budget.
| Endpoint | What's limited |
|---|
/v1/chat/completions | RPM + TPM (input + output) |
/v1/embeddings | RPM + TPM (input only) |
/v1/fim/completions | RPM + TPM |
/v1/moderations | RPM |
Headers returned on every response:
x-ratelimit-limit-requests — your RPM cap
x-ratelimit-remaining-requests — remaining RPM
x-ratelimit-limit-tokens — your TPM cap
x-ratelimit-remaining-tokens — remaining TPM
Retry-After — seconds to wait (on 429 only)
Instructions
Step 1: Token-Aware Rate Limiter
class MistralRateLimiter {
private requestTimes: number[] = [];
private tokenBuckets: Array<{ time: number; tokens: number }> = [];
private readonly rpm: number;
: ;
() {
. = rpm;
. = tpm;
}
(: ): <> {
now = .();
windowStart = now - ;
. = ..( t > windowStart);
. = ..( b. > windowStart);
(.. >= .) {
waitMs = .[] - windowStart + ;
.();
( (r, waitMs));
}
currentTPM = ..( sum + b., );
(currentTPM + estimatedTokens > .) {
waitMs = .[]. - windowStart + ;
.();
( (r, waitMs));
}
..(.());
}
(: ): {
..({ : .(), tokens });
}
}