openrouter-load-balancing
Skill by jeremylongshore
Distributes OpenRouter API requests across multiple keys and models for higher throughput. Built for developers scaling past single-key rate limits or building high-availability systems.
Install openrouter-load-balancing
Built from the published package, never by AI.
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.claude/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-load-balancing ~/.claude/skills/openrouter-load-balancingRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install openrouter-load-balancing in Claude Code
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-load-balancing ~/.gemini/antigravity-cli/skills/openrouter-load-balancingAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install openrouter-load-balancing in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
The openrouter-load-balancing skill covers distributing OpenRouter requests across multiple API keys to scale beyond single-key rate limits. It provides a round-robin KeyPool that skips keys after three consecutive errors and recovers them after a 60 second cooldown. A balanced_completion() helper retries on RateLimitError with the next healthy key.
It also covers concurrent batch requests with an asyncio.Semaphore, provider-level routing through OpenRouter's provider order and fallback options, and per-key quota checks via the auth key endpoint. The skill notes that OpenRouter offers server-side load balancing via provider routing and the :nitro variant. It is aimed at developers building high-throughput or high-availability systems on OpenRouter. It assumes Python with the OpenAI SDK and requests installed.
Written from the project's SKILL.md and checked against it.
What it can do
- KeyPoolRound-robin API key rotation with a circuit breaker and 60 second recovery cooldown.
- balanced_completion()Sends chat requests and retries with the next healthy key on RateLimitError.
- parallel_completions()Processes multiple prompts concurrently, capped by an asyncio.Semaphore.
- Provider-level load balancingPasses a provider order and allow_fallbacks so OpenRouter can spread a model across providers.
- check_rate_limits()Reads rate limit and credit usage for each key from GET /api/v1/auth/key.
What you need
- Two or more OpenRouter API keys
- OPENROUTER_API_KEY for the concurrent processing pattern
- Python 3.8+
- OpenAI SDK and requests packages
- Adequate credits on every key in the pool
Try asking
- Set up a key pool and send my chat requests across it.
- Run these 20 prompts concurrently with a concurrency limit of 3.
- Check the rate limit and credit usage for each of my OpenRouter keys.
Good to know
- Round-robin rotation does not account for in-flight requests, according to the error table.
- If all keys are unhealthy, the pool returns a key anyway.
- Code examples are in Python.
Security check
B- Allowed to use Write, Edit without limitsIn
SKILL.md
Checked automatically: skills/.curated/openrouter-load-balancing/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
Allowed tools: ReadWriteEditGrepBash(python3:*)
Alternatives to openrouter-load-balancing
All alternatives →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
Compare with agent-reproduce-align, google_contacts or m06-error-handling
openrouter-load-balancing: common questions
Does this need more than one OpenRouter key?
The KeyPool pattern is built around two or more keys. The source says each key gets its own quota, so more keys raise the effective rate limit.
What happens when a key keeps failing?
After 3 errors the key is marked unhealthy. It recovers after a 60 second cooldown.
Does it cover provider routing?
Yes. It passes a provider order with allow_fallbacks so OpenRouter can spread a model across providers such as Anthropic, AWS Bedrock and GCP Vertex.
How do I install openrouter-load-balancing?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is openrouter-load-balancing free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is openrouter-load-balancing safe to use?
It scores 76 of 100. Grades: maintenance A, licence A, quality A. Security check: grade B (allowed to use write, edit without limits). Review the code before you install. How grades work.
What are alternatives to openrouter-load-balancing?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
