Execute understand OpenRouter pricing and cost estimation. Use when budgeting or optimizing costs. Trigger with phrases like 'openrouter pricing', 'openrouter costs', 'openrouter budget', 'openrouter token pricing'.
OpenRouter charges per token with separate rates for prompt (input) and completion (output) tokens. Prices are listed per token in the models API (multiply by 1M for per-million rates). Credits are prepaid with a 5.5% processing fee ($0.80 minimum). Free models are available for testing and low-volume use.
Prerequisites
An OpenRouter API key (sk-or-v1-...) exported as OPENROUTER_API_KEY — see the openrouter-install-auth skill for setup
curl and jq for the model-pricing and credit-balance queries
Python 3.8+ with the OpenAI SDK plus the requests package for the cost-calculation and generation-endpoint snippets
Prepaid credits for paid models — the public models/pricing endpoint needs no auth, but real completions require credits or a :free model
Instructions
Read How Pricing Works: prepaid credits (5.5% fee, $0.80 minimum) are drawn down per request as (prompt_tokens * prompt_rate) + (completion_tokens * completion_rate).
Query per-token rates via GET /api/v1/models per Query Model Pricing, and place candidate models in the Cost Tiers table (free → premium).
Estimate spend before committing: run estimate_cost() from Calculate Request Cost with your expected prompt/completion token counts.
After sending real traffic, fetch the exact charge with GET /api/v1/generation?id= per Track Actual Cost Per Request.
Watch the balance via GET /api/v1/auth/key per Check Credit Balance, and enable auto-topup for production keys.
Cut costs with the :floor and :free variants per Save Money with Variants, and check Special Pricing for reasoning tokens, image inputs, per-request fees, and BYOK.
A per-model pricing record from the models API: prompt_per_M, completion_per_M, context (e.g. $3 / $15 per 1M tokens for anthropic/claude-3.5-sonnet)
A pre-request dollar estimate from estimate_cost() and the exact post-request figures from the generation endpoint: total_cost, tokens_prompt, tokens_completion
A credit-balance snapshot from /api/v1/auth/key: credits_used, credit_limit, remaining, is_free_tier
Estimating first keeps surprises out: 1,000 prompt + 500 completion tokens on anthropic/claude-3.5-sonnet comes to roughly $0.0105 via estimate_cost(), and the generation endpoint then confirms the exact charge. More worked examples: references/examples.md.