OpenRouter spend control
OpenRouter Balance Guardrail
A practical checklist for teams exposing OpenRouter balance, key limits, and model spend inside an agent or SaaS workflow. The useful gate is not the raw balance number. It is a clear stale-state policy, a pre-dispatch reservation, and an actual-usage refund path.
Separate credits, limits, and usage
OpenRouter exposes account credits, current key details, and generation metadata as different API surfaces. A product guardrail should keep those meanings separate so a cached credits snapshot never becomes a false permission to dispatch an expensive run.
/api/v1/credits is account-level purchased and used credits/api/v1/key is current key limit, remaining limit, reset, and usage/api/v1/generation is per-generation tokens, usage, cost, provider, and modelReview shape
The review is scoped around one OpenRouter-backed workflow: UI balance display, budget guard, retry behavior, cache-read assumptions, and logs that prove cost without exposing prompts or API keys.
Package routing
Use the free calculator for rough monthly exposure. Use the paid review when the workflow is live, confusing users, or already close to a budget edge.
usage.cost or generation total_cost when the provider dashboard disagrees.Useful intake evidence
A sanitized packet is enough to start scoping. Keep private data out of GitHub issues and use summarized counts where possible.