Track LLM costs per request, model, and key
LLM cost tracking at the gateway means every model call is metered as it happens, priced at the posted model rate, and attributed to the API key that made it — instead of arriving as one undifferentiated invoice line at month end. On Router One each request writes a trace carrying the model, input and output tokens, computed cost, latency and status; usage rolls up per model and per key, and each key can carry a spend cap (maxSpend) on what it charges to your wallet. One prepaid wallet, 30+ models, and a ledger you can reconcile against your own billing.
What gets tracked
A cost trace per request
Customer Logs shows the model, request ID, input and output tokens, settled cost or a pending label, total time (plus time to first token on streamed requests that produced output), status, and any sanitized error for recorded calls. Internal providers and service routes are not disclosed.
Per-model breakdowns
Usage rolls up by model over time, so you can see which families drive spend, compare cost per workload, and catch a quiet shift toward an expensive model before it compounds. The dashboard overview also ranks the last 7 days' spend by model and links each model to its logs.
Per-key attribution
Give each app, environment, or agent its own API key and spend attributes cleanly. No more guessing which integration burned the budget — the ledger says exactly which key did.
Per-key spend caps
Each key can carry its own maxSpend cap and expiry. A runaway loop or leaked key hits its cap instead of draining the wallet; requests your plan covers use the plan quota instead. Its rate limit (rateLimit) and per-minute token ceiling (tokenLimitTpm) run at platform defaults and can be raised on request.
A prepaid wallet ledger
Spend draws down from a prepaid wallet at the pay-as-you-go token line of each model's posted rate; FX and channel fees stay visible at checkout, separate from the token line.
Hard stop at zero
When usable credit runs out, calls your plan does not cover return HTTP 402 instead of accruing surprise debt. Top up — with a card or Alipay through one hosted checkout, or with USDT/USDC on six chains — and requests resume immediately.
A ledger, not a guess
Direct provider calls scatter your spend across dashboards that update on their own schedules. A gateway puts one ledger in the request path: cost is computed per call at posted rates, attributed to a key, and aggregated in real time. That changes cost work from forensic reconstruction at month-end to a live number you can query while the workload is still running — and act on with per-key caps before the bill grows.
Point your stack at the gateway
Cost tracking starts working the moment your traffic flows through the gateway. Change the base URL, keep your code, and every request after that lands in the ledger.
# Every request after this lands in the ledger export OPENAI_BASE_URL=https://api.router.one/v1 export OPENAI_API_KEY=sk-your-router-one-key
FAQ
How is the cost of each request computed?
Each request is priced at the pay-as-you-go token line of the model's posted rate — input and output tokens times the per-1M-token price listed on the models page. FX and payment-channel fees are shown at checkout and kept separate from the token line.
Can I cap spend per API key?
Yes. Every Router One API key can carry its own maxSpend cap. A key's spend cap (maxSpend) limits what that key can charge to your wallet: once its cumulative wallet charges reach the cap, its wallet-billed requests return HTTP 402. Requests covered by your plan's quota draw from the account's shared plan quota and do not count toward any key's cap. The rest of the account keeps working, and each key's rate limit and per-minute token ceiling (tokenLimitTpm) run at platform defaults and can be raised on request. If a key has leaked or an agent is running away, /blog/llm-api-key-leak-spend-cap covers what actually stops the bill and what to do in the first hour.
Where do I see usage and costs?
Dashboard → Logs shows per-request traces and filters by model, API key, status and date; Dashboard → Usage ranks API keys by spend, tokens and requests. The filtered Logs and the wallet ledger export to CSV for reconciliation. A trace normally appears within moments of completion; a record still awaiting pricing can be briefly absent, and pending never means free.
What happens when my balance runs out?
API calls return HTTP 402 until the wallet is topped up or plan coverage applies. There is no silent overage — spend can never exceed what you have prepaid plus your plan. Before that point, the dashboard overview estimates how many days the balance lasts at your average pay-as-you-go spend over the last 7 days (plan-covered requests are not counted) and flags it when that drops under 3 days; to alert from a server, poll GET /v1/balance (reference: /docs/account/getBalance).
Do you store my prompts to compute costs?
Cost metering uses token counts and metadata; the trace records model, tokens, cost, latency, and status. Router One does not retain prompt or model-response bodies from direct API calls. It records request metadata for billing, usage tracking, and troubleshooting. Playground saves conversation history so users can revisit and continue their chats.
Does this work for Claude Code and Codex CLI?
Yes. CLI agents route through the same gateway, so every coding-agent request gets the same per-request cost trace, and its wallet charges count against the same per-key caps as your application traffic.
Related
- Cache usage and billing checks
- LLM observability
- Pricing methodology
- LLM API gateway
- Pricing
- LLM cost calculator
- Spend-capped keys for your customers
- LLM cost attribution: one API key per app, agent and environment
- Why Claude Code burns tokens (and how to cap it)
- LlamaIndex setup guide: a cost trace on every RAG call
Know what every model call costs — as it happens.
Get your API key