Your app shouldn't die because Groq returned a 429.

llm-free-cascade sends one chat completion through every free-tier LLM provider you have a key for, and moves on when one is rate-limited, out of quota, slow or down. Zero dependencies, Node 18+.

npm install llm-free-cascade
const { LLMCascade } = require('llm-free-cascade');

const cascade = LLMCascade.fromEnv();   // GROQ_API_KEY, GEMINI_API_KEY, ...

const { text, provider, attempts } = await cascade.generate({
  system: 'You are a helpful assistant.',
  user: 'Explain photosynthesis in one sentence.',
});
// provider: who answered. attempts: who it skipped, and why.
groq (429, rests 58s)→ gemini (daily quota, rests until reset)→ gemini answers

What a plain retry loop doesn't do

Reset-aware cooldowns

Reads Retry-After and "try again in 2m59s". Per-minute limits rest a minute; per-day limits rest until the provider's reset.

Per-key and per-model rotation

Keys are round-robin. Limits are usually per model, so a 429 falls to the next model on the same key first.

Failure classification

A too-long prompt skips one provider for one call. Timeouts and 5xx trip a circuit breaker. A bad key leaves rotation alone.

Hard bounds

Per-attempt timeout (idle timeout for streams) and a whole-call deadlineMs.

Parse-and-retry

A response that fails your parse function counts as a provider failure and the next one is tried.

Visibility

stats(), onAttempt, probe() and a CLI answer "which key served what, and when does it reset?"

Use it from any OpenAI client

Not writing Node? Run the cascade as a local OpenAI-compatible endpoint and point any tool that takes a custom base URL at it: the Python openai SDK, LangChain, Open WebUI, Continue, Aider.

npx llm-free-cascade serve            # http://127.0.0.1:8787/v1
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8787/v1", api_key="unused")
client.chat.completions.create(model="cascade", messages=[{"role": "user", "content": "hi"}])

model: "cascade" uses the whole chain; a provider name such as "groq" pins one. Streaming, max_tokens and JSON mode are supported; tool calls and images return a clear 400. It listens on 127.0.0.1 only, and refuses any other address unless LLM_CASCADE_SERVER_KEY is set. Details.

Local fallback with Ollama

Ollama runs models on your own machine: no quota and no key, just slower. Add it as the last tier so the cascade never runs dry.

new LLMCascade({
  keys: { ... },
  custom: {
    ollama: {
      baseUrl: 'http://localhost:11434/v1',
      model: 'llama3.2',
      apiKey: 'ollama', // any non-empty value; a provider without a key is skipped
      tier: 5,          // after every free cloud provider
    },
  },
  providerTimeoutMs: { ollama: 120_000 },
});

Or set LLM_CUSTOM_PROVIDERS to the same object as JSON, which also works with serve. Details.

Providers

Generated from src/providers.json (version 0.11.0). Free tiers change without notice; read each provider's own console and terms before relying on a number here. Entries marked tracker or unverified come from third-party lists, not the provider's docs.

1 Fast, roomy2 Solid3 Tight or niche4 Trial / unverified5 Paid last resort

TierProviderModelsFree tierSign up
1 groq
GROQ_API_KEY
openai/gpt-oss-120b
qwen/qwen3.8-27b
openai/gpt-oss-20b
30 RPM, 1,000 req/day, 200,000 tokens/day · per model, per organization
per model: 30 RPM, 1K requests/day, 8K tokens/min, 200K tokens/day; limits are per organization, and each model has its own bucket
console.groq.com
checked 2026-10-07
1 gemini
GEMINI_API_KEY
gemini-3.6-flash per model, per project
limits are per Google Cloud project (not per key) and per model; Google no longer publishes a table, see AI Studio's rate-limit page; daily quota resets at midnight Pacific; free-tier prompts may be used to improve Google products
trains on prompts
aistudio.google.com
checked 2026-10-07
2 mistral
MISTRAL_API_KEY
mistral-small-latest 1 req/s · per organization
Experiment tier: ~1 request/sec and a large monthly token pool (one tracker says ~1B tokens/month, another a $10 monthly credit: check your console's limits page); needs a verified phone number and opting in to data training
phonetrains on promptslimits: tracker
console.mistral.ai
checked 2026-10-07
2 nvidia
NVIDIA_API_KEY
meta/llama-3.1-8b-instruct 40 RPM · per account
NVIDIA NIM trial: ~40 requests/min, no published daily cap; for prototyping, not production
phonelimits: tracker
build.nvidia.com
checked 2026-10-07
2 zhipu
ZHIPU_API_KEY
glm-4.7-flash
glm-4.5-flash
per account
GLM-4.7-Flash, GLM-4.5-Flash and GLM-4.6V-Flash are free with no expiry (concurrency-limited, can be slow); international Z.ai platform. A key from the China platform (open.bigmodel.cn) will not work here: set baseUrls: { zhipu: 'https://open.bigmodel.cn/api/paas/v4' } or ZHIPU_BASE_URL
China-hosted
z.ai
checked 2026-10-07
3 openrouter
OPENROUTER_API_KEY
openrouter/free
google/gemma-4-31b-it:free
google/gemma-4-26b-a4b-it:free
20 RPM, 50 req/day · per global
gateway; ':free' models: 20 RPM and 50 requests/day (1,000/day once you have bought $10+ credit), enforced globally per user: extra accounts or keys do NOT raise it. The free lineup churns, 'openrouter/free' picks one for you
openrouter.ai
checked 2026-10-07
3 siliconflow
SILICONFLOW_API_KEY
Qwen/Qwen2.5-7B-Instruct 1000 RPM · per account
a few small open models are free at high rate (tracker: 1,000 RPM / 50K TPM); the international site grants ~$1 starter credit; the China site (api.siliconflow.cn) needs phone + real-name verification. Which models are free changes: run `npm run check:providers`
China-hostedlimits: tracker
siliconflow.com
checked 2026-10-07
3 modelscope
MODELSCOPE_API_KEY
Qwen/Qwen3.5-35B-A3B 2,000 req/day · per model, per account
Alibaba's ModelScope API-Inference: ~2,000 requests/day total, at most ~500 per model (tracker); signup may need a phone number. Base URL and model id come from a tracker site, so verify them with `npm run check:providers`
phoneChina-hostedlimits: tracker
modelscope.cn
checked 2026-10-07
3 cloudflare
CLOUDFLARE_API_TOKEN
@cf/meta/llama-3.1-8b-instruct-fast per account
Workers AI: 10,000 neurons/day (a few hundred small calls); small 2-8K context windows; needs CLOUDFLARE_ACCOUNT_ID
limits: tracker
dash.cloudflare.com
checked 2026-10-07
3 cohere
COHERE_API_KEY
command-r7b-12-2024 20 RPM · per account
trial key: ~20 RPM and ~1,000 requests/month; NON-COMMERCIAL use only, do not use for a production product
non-commerciallimits: tracker
dashboard.cohere.com
checked 2026-10-07
4 pollinations
POLLINATIONS_API_KEY
openai-fast per ip
no signup required for anonymous/low-rate use (1 req/15s); a free token raises the limit
auth.pollinations.ai
checked 2026-10-07
4 opencode
OPENCODE_API_KEY
grok-code —
free tier available (a handful of free models, no card)
limits: unverified
opencode.ai
checked ?
4 ovh
OVH_AI_ENDPOINTS_API_KEY
Meta-Llama-3_3-70B-Instruct 12 RPM · per ip
EU-hosted open models; the API works without a key at a low rate (~12 RPM) but the cascade only uses providers it has a key for, so create a free account for a key. Model catalogue rotates
limits: tracker
endpoints.ai.cloud.ovh.net
checked 2026-10-07
5 deepseek
DEEPSEEK_API_KEY
deepseek-chat —
PAID after a small signup credit: the cheapest sensible paid fallback
triallimits: unverified
platform.deepseek.com
checked ?
5 anthropic
ANTHROPIC_API_KEY
claude-haiku-4-5-20251001 —
paid — intended as a last-resort tier, not free
console.anthropic.com
checked ?

Check your own setup

npx llm-free-cascade keys            # which providers you're missing, and where to sign up
npx llm-free-cascade status          # order, keys, models, limits, warnings
npx llm-free-cascade probe --watch 300   # live check of every key, every 5 minutes
npx llm-free-cascade serve           # OpenAI-compatible endpoint on 127.0.0.1:8787