GR

groq-rate-limits

Tools and patterns for managing Groq API 429 rate limit errors and optimizing request throughput.

Install

mkdir -p .claude/skills/groq-rate-limits && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/7261" && unzip -o skill.zip -d .claude/skills/groq-rate-limits && rm skill.zip

Installs to .claude/skills/groq-rate-limits

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Implement Groq rate limit handling with backoff, queuing, and header
68 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Parse x-ratelimit headers into typed information
  • Gate requests using concurrency control queues
  • Monitor remaining capacity proactively
  • Execute model-aware fallback strategies

How it works

The skill implements a client wrapper that combines request queuing, proactive monitoring of rate limit headers, and exponential backoff logic.

Inputs & outputs

You give it
API request parameters and current rate limit status
You get back
A transparently retried API response or handled throttling event

When to use groq-rate-limits

  • Implementing exponential backoff for 429 errors
  • Setting up request concurrency queues
  • Parsing Groq rate limit headers
  • Building model fallback strategies
  • Monitoring API capacity

About this skill

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-sdk installed: npm install groq-sdk.
  • For queuing (Step 3): p-queue installed: npm install p-queue.
  • Node.js 18+ (for native fetch and 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.

Instructions

Compose these five steps into one client wrapper (queue → monitor → retry). Each step's complete, copy-pasteable code is in implementation.md.

Step 1: Parse Rate Limit Headers

Read the x-ratelimit-* headers off every response into a typed RateLimitInfo so downstream logic can reason about remaining capacity. Groq reports reset times as strings like "1.2s" or "120ms" — normalize them to milliseconds.

Step 2: Exponential Backoff with Retry-After

Wrap each API call in a retry loop. Prefer Groq's retry-after header when present; otherwise back off exponentially with jitter, capped at maxDelayMs. Retry only 429 and 5xx — other 4xx errors are not retryable.

Step 3: Request Queue with Concurrency Control

Gate all requests through a p-queue sized to your plan's RPM (intervalCap over a 60s interval) so bursts never exceed the limit in the first place.

Step 4: Proactive Rate Limit Monitor

Track remaining requests/tokens from response headers and pause before hitting zero (shouldThrottle()waitIfNeeded()), instead of reacting to 429s after the fact.

Step 5: Model-Aware Rate Limit Strategy

Different models draw from different limit pools. When the preferred model is throttled, fall back to another model to keep making progress without waiting for a reset.

Output

Applying this skill produces:

  • A withRateLimitRetry() wrapper that transparently retries 429/5xx with retry-after-aware backoff.
  • A RateLimitMonitor that surfaces live status (getStatus()"Requests: N remaining | Tokens: M remaining") and throttles proactively.
  • A p-queue-backed client that caps throughput to your RPM so 100 fan-out calls complete without tripping the limit.
  • Console diagnostics on every backoff/throttle event (e.g. Rate limited (attempt 2/5). Waiting 1.4s...).

The observable end state: sustained request volume that stays under RPM/TPM with zero unhandled 429s.

Error Handling

ScenarioSymptomSolution
Burst of requestsMany 429s in quick successionUse queue with p-queue interval limiting (Step 3)
Large prompts burn TPM429 on tokens, not requestsReduce max_tokens, compress prompts
Free tier too restrictiveConstant 429sUpgrade to Developer plan at console.groq.com
Multiple services sharing keyCascading 429sUse separate API keys per service
retry-after absent on 429Retries hammer too fastFall back to exponential backoff + jitter (Step 2)

Examples

Start from this minimal 429 handler, then graduate to the composed client (queue + monitor + retry) in reference.md:

try {
  await groq.chat.completions.create({ model, messages });
} catch (err) {
  if (err instanceof Groq.APIError && err.status === 429) {
    const retryAfter = parseInt(err.headers?.["retry-after"] || "0");
    console.log(`Rate limited. retry-after says wait ${retryAfter}s.`);
    // -> feed retryAfter into withRateLimitRetry (Step 2)
  }
}
  • Full five-step implementation (every code block, verbatim): implementation.md
  • Composed client + header/limit tables + a 100-request fan-out: reference.md

Resources

Next Steps

For security configuration, see the groq-security-basics skill in this pack, which covers API key storage, rotation, and request signing to complement the throughput handling above.

When not to use it

  • When handling non-retryable 4xx errors
  • When ignoring organization-level RPM or TPM constraints

Prerequisites

Groq API keygroq-sdk installedp-queue installedNode.js 18+

Limitations

  • Requires p-queue for concurrency control
  • Requires knowledge of specific plan limits

How it compares

This approach proactively manages throughput using queues and header parsing rather than reacting only after receiving 429 errors.

Compared to similar skills

groq-rate-limits side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
groq-rate-limits (this skill)124dNo flagsIntermediate
chrome-devtools417moReviewIntermediate
python-performance-optimization272moNo flagsIntermediate
analyzing-logs1425dReviewBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

Search skills

Search the agent skills registry