← All releases
v0.5· Release

v0.5 — Credit safety: reserve + settle

Every request reserves credits before the call, settles against real cost after, and releases the hold on failure. Negative balances blocked in the database.

nRouter Team3 min read
creditsbillingsafety

Credits are the product. If we lose track of them, we don't have a business. v0.5 closes the last gap in the credit ledger — the gap between "we accepted the request" and "the provider billed us".

The old way (broken)

Old code path: deduct an estimated cost before the call. If the call failed mid-flight, the deduction stayed and the user got a free refund only if our cleanup script noticed. If the call succeeded but the real cost was higher, we under-charged. If the user fired two parallel requests with $0.001 balance each costing $0.0008, both passed the pre-flight check, both billed, balance went negative. None of this was acceptable.

The new way (reserve + settle)

Three operations, all atomic under database row locks in the Rust gateway:

  1. reserve_credits — place a pre-flight reservation sized to the request's maximum plausible completion cost. If available credits (balance - active_holds) cannot cover it, refuse immediately with HTTP 402 before any provider call.
  2. Make the LLM call.
  3. settle_credits — debit the served model's exact published list-price cost against the reservation and release any unused remainder back to available balance.

Pre-call refusals (auth, ACLs, rate limits, budgets, and pre-call guardrail blocks) never take a reservation and spend $0.00. Upstream transport failures, pre-first-byte timeouts, and provider refusals release the entire reservation cleanly (release_reservation). Post-call guardrail blocks withhold the unsafe response while settling the upstream tokens the provider already generated, and mid-stream client disconnects settle tokens generated before disconnect.

Database invariants

  • credit_balances.balance >= 0 — negative USD balances are rejected by a hard database CHECK constraint. No application bug can produce one.
  • credit_transactions is append-only. Reservations, settlements, releases, top-ups, and refunds are each recorded as immutable ledger rows.
  • Reconciliation: settled credit_transactions per organization reconcile against credit_balances.balance to the sub-cent.

What you see

A 402 with error.code = insufficient_credits (x-nr-limit-source: budget) when available balance cannot cover the hold. No partial bills, no overdrafts, no after-the-fact "we forgot to charge you" emails. Top up at /{org}/billing or configure Owner-managed Auto Top-Up to keep the balance above your floor.

Platform release verification & compatibility standards

All nRouter release notes reflect changes deployed across our global edge routing infrastructure. Below is our baseline deployment architecture and verification criteria.

Zero-Downtime Rolling Delivery

Releases deploy via immutable container digests with automated health verification. Existing streaming responses complete uninterrupted while new requests seamlessly route to updated instances.

Drop-In API Backward Compatibility

Our interface remains strictly compatible with standard OpenAI client SDKs and wire formats. Enhancements degrade gracefully or fail open with explicit error reporting to protect calling workloads.

How can engineering teams verify capabilities in this release?

Teams can inspect currently supported capabilities and active model deployments programmatically via the authenticated /capabilities endpoint, or review live latency profiles at /models.

Where can edge cases or regressions be reported?

If your team experiences unexpected response behavior, report the issue with the relevant x-nr-request-id header to support@nrouter.ai or via the community Slack at /community.