groq-rate-limits
Groq Rate Limits
Overview
Handle Groq rate limits using the retry-after header, exponential backoff, and request queuing. Groq enforces limits at the organization level with both RPM (requests/minute) and TPM (tokens/minute) constraints -- hitting either one triggers a 429.
The workflow builds up in five composable layers: parse the rate-limit headers, wrap calls in retry-with-backoff, gate concurrency through a queue, monitor remaining capacity proactively, and fall back across models when one pool is exhausted. Read SKILL.md for the high-level flow, then drill into the full implementation for every code block and the reference tables + worked examples for header definitions and composed clients.
Prerequisites
- A Groq API key (
GROQ_API_KEY) — get one at console.groq.com. groq-sdkinstalled:npm install groq-sdk.- For queuing (Step 3):
p-queueinstalled:npm install p-queue. - Node.js 18+ (for native
fetchand the SDK). - Know your plan's limits — check console.groq.com/settings/limits.
Rate Limits at a Glance
Groq applies RPM, RPD, TPM, and TPD limits simultaneously — you must stay under every one, and either RPM or TPM can trip a 429. Every response (even a success) carries x-ratelimit-* headers describing remaining capacity and reset timing; 429 responses add a retry-after header. Full header and constraint tables: reference.md.