Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

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.

  • Score 76
  • 3k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

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-controls

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install openrouter-cost-controls in Claude Code

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 →

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.

openrouter-cost-controls Install

Add to stack

Loading.