Overview
Yes — you can issue one API key per end user and cap each key's spend, all programmatically. OpenRouter's Management API is built for exactly this: a SaaS app creates a unique key per customer, sets a credit limit on it, and lets OpenRouter meter and deduct usage. You don't maintain your own pricing table.
How it works
First create a Management API key at openrouter.ai/settings/management-keys. That key only manages other keys — it can't make inference calls. Then use the /api/v1/keys endpoints (create, list, get, update, delete) to provision and control per-user keys.
When you create a key you can set:
limit— a spending cap for that key, in USD.limit_reset—daily,weekly,monthly, ornullfor no reset. Resets run automatically at midnight UTC (weeks are Monday–Sunday).include_byok_in_limit— whether usage on your own provider keys counts toward the limit.expires_at— an optional expiry date.
See the Management API Keys docs for full request/response examples in TypeScript, Python, and fetch.
Answers to the common questions
- Is one managed key per end user supported? Yes. Creating a unique key per customer instance is a documented use case.
- Is there a limit on how many keys I can create? There's no published cap on the total number of keys. Key creation through the Management API is rate-limited, and the list endpoint returns 100 keys per page (use the
offsetparameter to paginate). - When a key hits its limit, is the request blocked before upstream spend? Yes. Once a key reaches its limit, further requests on that key are rejected before they're sent to the provider, so they don't incur upstream cost. Because the check runs per request, a burst of simultaneous requests can slightly overshoot the limit.
- Are monthly resets available on pay-as-you-go? Yes — set
limit_resettomonthly(or daily/weekly). It resets at midnight UTC. - Can I rely on OpenRouter's pricing and credit deduction? Yes. OpenRouter meters each request and deducts from your account balance at the listed per-endpoint price, and tracks each key's spend against its limit. You don't need your own model pricing table.
One thing to keep in mind
All your keys draw from the same account credit balance. The per-key limit caps how much each individual key can spend; the account balance is the shared pool behind them. So set a per-key limit to enforce a hard per-user cap, and keep enough credits (or Auto Top-Up) on the account to cover all active keys.