Install any skill in seconds. Free to start, no credit card required.
Get Started Free →jeremylongshore/langchain-rate-limits
Rate-limit LangChain 1.0 calls correctly across multi-worker deployments — Redis-backed limiters, asyncio.Semaphore, narrow exception whitelists, and provider-specific throttle handling.
Passed 19 of 22 test cases with the skill, and 14 of 22 without it.
and 5 more in the full report
7 fixed13 passed either way1 still failing2 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
We are migrating a LangChain service to Google Gemini (`ChatGoogleGenerativeAI`). Our current volume exceeds Gemini's free tier limits and causes `ResourceExhausted` errors. What rate limiting parameter and retry configuration should we apply when instantiating `ChatGoogleGenerativeAI` for production?
| Checked | Without skill | With skill |
|---|---|---|
| Sets max_retries to 2 on ChatGoogleGenerativeAI. | Missed | Passed |
| Attaches a rate limiter instance to ChatGoogleGenerativeAI. | Passed | Passed |
The instructions your model reads when the skill loads.
A team deploys 10 Cloud Run workers. Each worker initializes its ChatAnthropic
with InMemoryRateLimiter(requests_per_second=10) — they read the docs, they
picked a safe-looking number, they shipped. Thirty seconds later the dashboard
lights up with 429s: the cluster is pushing 100 RPS to Anthropic's 50 RPM
tier-1 ceiling, not the 10 RPS they configured. The name is the fix —
InMemoryRateLimiter is in-process. Each worker has its own counter. Ten
workers × 10 RPS = 100 RPS to the provider. This is pain-catalog entry P29
and it lands on every team that scales past one pod.
Three more traps wait on the same code path:
.with_fallbacks([backup]) defaults exceptions_to_handle=(Exception,),
which on Python <3.12 swallows KeyboardInterrupt. Ctrl+C during a 429
retry storm silently falls through to the backup chain and keeps billing.ChatOpenAI and ChatAnthropic default max_retries=6. That is
retries, not attempts: 7 total requests per logical call on flaky
networks. One .invoke() can bill 7x.This skill covers measuring demand before picking a limit; the
InMemoryRateLimiter vs Redis-backed limiter vs asyncio.Semaphore decision
tree; the narrow exceptions_to_handle whitelist; max_retries=2 math; and
the provider-specific limit taxonomy (RPM, ITPM, OTPM, concurrent,
cached-vs-uncached). Pin: langchain-core 1.0.x, langchain-anthropic 1.0.x,
langchain-openai 1.0.x. Pain-catalog anchors: P07, P08, P29, P30, P31.
For .batch(max_concurrency=...) tuning, see the sibling skill
langchain-performance-tuning — this skill is about provider-facing rate caps.
KeyboardInterrupt half of P07)langchain-core >= 1.0, < 2.0pip install langchain-anthropic langchain-openairedis >= 4.5 client and a Redis server reachable from every workertest cases passed, vs 14 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.