Agent/MCP Audit Sprint

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.

Audit dashboard visual showing review rows and status bands
Credits/api/v1/credits is account-level purchased and used credits
Key/api/v1/key is current key limit, remaining limit, reset, and usage
Usage/api/v1/generation is per-generation tokens, usage, cost, provider, and model
GateAdmission control needs a reservation before dispatch and refund after actual usage
FailureZero balance confused with unavailable balance
FailureStale credits snapshot allows a costly retry loop
FailureBYOK usage mixed into shared-key budget
FailureGeneration cost arrives after the UI already says safe

Review 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.

State contract: available, unconfigured, unauthorized, rate-limited, stale, unavailable, and zero-credit states are distinct.
Reservation ledger: the next call reserves worst-case cost before dispatch, then records actual usage after completion.
Error policy: 401, 403, 429, timeout, malformed payload, and stale cache all block or degrade predictably.
Scope policy: BYOK usage, shared keys, workspace budgets, and user-level caps do not overwrite each other.
Audit trail: logs keep model, provider, token counts, and cost while stripping prompts, keys, account ids, and customer data.

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.

USD $99: quick review for one balance display, key-limit state, or launch-pricing sanity check.
USD $299: focused review for one OpenRouter-backed agent or SaaS workflow with recurring cost, stale-balance, or actual-cost reconciliation risk.
USD $1,000: emergency sprint when daily burn, retries, or model-routing drift already need containment.
Actual-cost reconciliation: compare product display with usage.cost or generation total_cost when the provider dashboard disagrees.
Start rule: Payment only after written scope acceptance. No private prompts, secrets, or raw customer traces in public issues.

Useful intake evidence

A sanitized packet is enough to start scoping. Keep private data out of GitHub issues and use summarized counts where possible.

Workflow URL or product page, plus where OpenRouter calls happen.
Model ids, monthly request estimate, average input and output tokens, cache-read share, and retry rate.
Current balance or key-limit behavior, including stale, unauthorized, and rate-limited screenshots with account details removed.
One example generation id only if it is safe to share, otherwise a redacted cost summary.