openrouter-cost-controls
Skill by jeremylongshore
Implements cost controls for OpenRouter API usage. It helps set budgets, prevent overspend and manage per-key credit limits for developers running LLM traffic through OpenRouter.
Install openrouter-cost-controls
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-cost-controls ~/.claude/skills/openrouter-cost-controlsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install openrouter-cost-controls 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-cost-controls ~/.gemini/antigravity-cli/skills/openrouter-cost-controlsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install openrouter-cost-controls in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill covers how to keep OpenRouter API spending under control. It shows how to check the credit balance and limits on an API key with the auth endpoint. It also shows how to create keys with a dollar limit through the management API and review usage per key.
The skill includes a Python budget enforcement class. Its check_budget method rejects requests whose estimated cost exceeds a per-request or daily cap. Its record_cost method books actual spend from the generation endpoint. The skill also covers cheaper model variants such as :floor and :free, a task-based routing table, and a cron-style shell script that alerts when credits drop below a threshold. It is aimed at developers and teams who call OpenRouter from their own applications.
Written from the project's SKILL.md and checked against it.
What it can do
- Check credit balanceReads credits used, the key limit, remaining balance, free-tier status and rate limit for the active key.
- Per-key credit limitsCreates scoped API keys with a dollar limit and lists keys with their usage against limits.
- Budget enforcement middlewareRejects requests whose pre-flight cost estimate exceeds per-request or daily caps.
- Cost tracking per requestRecords actual spend from the generation endpoint into a running daily total.
- Cost-saving model variantsUses :floor for the cheapest provider and :free where available, with task-based model routing.
- Budget alert scriptShell script that flags when remaining credits fall below a set threshold.
What you need
- OpenRouter API key
- OpenRouter management key for provisioning per-key limits
- Python 3.8 or later with the OpenAI SDK and requests
- Node.js 18 or later for the TypeScript cost logger
- curl, jq and bc for the balance check and alert script
Try asking
- Check how many OpenRouter credits are left on my current key.
- Create a new OpenRouter key named backend-prod with a $50 limit.
- Add a budget check that blocks requests over $1 per request.
Good to know
- Pre-flight cost estimates use representative rates hardcoded in the example, not live pricing.
- Per-key limits require an OpenRouter management key.
- The alert script has a placeholder for Slack or PagerDuty and does not send alerts by itself.
- The daily spend tracker is kept in memory in the example class.
Security check
B- Allowed to use Write, Edit without limitsIn
SKILL.md
Checked automatically: skills/.curated/openrouter-cost-controls/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
Allowed tools: ReadWriteEditGrepBash(python3:*)Bash(node:*)Bash(curl:*)Bash(jq:*)Bash(bc:*)
Alternatives to openrouter-cost-controls
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-cost-controls: common questions
How do I stop OpenRouter spending going over a set amount?
The skill sets a dollar limit on each API key through the management API. A client-side BudgetEnforcer also rejects requests above per-request or daily caps.
Can I see the exact cost of an OpenRouter request?
Yes. The skill queries the generation endpoint with the request ID to get the total cost after each request.
What happens when OpenRouter credits run out?
The error table lists a 402 Payment Required response for exhausted credits. The suggested fixes are to top up credits or use a :free model.
How do I install openrouter-cost-controls?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is openrouter-cost-controls free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is openrouter-cost-controls 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-cost-controls?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
