Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Explains how to rate-limit LangChain 1.0 calls across multiple workers using Redis, semaphores, and provider-specific limits.
65% 87%+22 ptsof test cases passed
Passed 20 of 23 test cases with the skill, and 15 of 23 without it.
I am writing a standalone Python script that executes on a single local process for testing ChatAnthropic. I want to limit the outbound request rate to stay well within Anthropic's tier limits. How should I attach a rate limiter directly to the ChatAnthropic model instance?
Sets max_retries to 2 on ChatAnthropic.
This test ran on v1. v2 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
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 workerSkills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.