openrouter-cost-controls

Featured

Implement cost controls for OpenRouter API usage. Use when setting budgets, preventing overspend, or managing per-key limits. Triggers: 'openrouter budget', 'openrouter cost limit', 'openrouter spending', 'control openrouter cost'.

AI & Automation 2,266 stars 315 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# OpenRouter Cost Controls ## Overview OpenRouter provides per-key credit limits, a credit balance API, and per-generation cost queries. Combined with client-side budget middleware, you can enforce hard spending caps at the key level and soft caps in your application. This skill covers key-level limits, per-request cost tracking, budget enforcement middleware, and alert systems. ## Check Credit Balance ```bash # Current balance and limits curl -s https://openrouter.ai/api/v1/auth/key \ -H "Authorization: Bearer $OPENROUTER_API_KEY" | jq '{ credits_used: .data.usage, credit_limit: .data.limit, remaining: ((.data.limit // 0) - .data.usage), is_free_tier: .data.is_free_tier, rate_limit: .data.rate_limit }' ``` ## Per-Key Credit Limits ```python import os, requests MGMT_KEY = os.environ["OPENROUTER_MGMT_KEY"] # Management key # Create a key with a $50 credit limit resp = requests.post( "https://openrouter.ai/api/v1/keys", headers={"Authorization": f"Bearer {MGMT_KEY}"}, json={"name": "backend-prod", "limit": 50.0}, ) new_key = resp.json()["data"]["key"] # sk-or-v1-... # List all keys with their limits and usage keys = requests.get( "https://openrouter.ai/api/v1/keys", headers={"Authorization": f"Bearer {MGMT_KEY}"}, ).json() for k in keys.get("data", []): print(f"{k['name']}: ${k.get('usage', 0):.4f} / ${k.get('limit', 'unlimited')}") ``` ## Budget Enforcement Middleware ```python import os, time, requests from openai i...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
7 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

openrouter-team-setup

Configure OpenRouter for multi-user teams with per-user keys, budget controls, and usage attribution. Triggers: 'openrouter team', 'openrouter multi-user', 'openrouter organization', 'team api keys openrouter'.

2,266 Updated today
jeremylongshore
API & Backend Listed

openrouter-usage

Query OpenRouter API costs, credits, and usage breakdown by model, provider, and date. This skill should be used when checking API spending, auditing costs, or generating usage reports for the last 30 days.

33 Updated yesterday
tdimino
AI & Automation Featured

openrouter-rate-limits

Understand and handle OpenRouter rate limits. Use when hitting 429 errors, building high-throughput systems, or implementing retry logic. Triggers: 'openrouter rate limit', 'openrouter 429', 'openrouter throttle', 'rate limiting openrouter'.

2,266 Updated today
jeremylongshore
AI & Automation Featured

openrouter-usage-analytics

Track and analyze OpenRouter API usage patterns, costs, and performance. Use when building dashboards, optimizing spend, or reporting on AI usage. Triggers: 'openrouter analytics', 'openrouter usage', 'openrouter metrics', 'track openrouter spend'.

2,266 Updated today
jeremylongshore
AI & Automation Featured

openrouter-pricing-basics

Understand OpenRouter pricing, calculate costs, and optimize spend. Use when budgeting, comparing model costs, or tracking spend. Triggers: 'openrouter pricing', 'openrouter cost', 'model pricing', 'openrouter budget', 'how much does openrouter cost'.

2,266 Updated today
jeremylongshore