Usage and quota
Where to look when an account runs out, which window each provider reports, how cooldowns and retention work, and how to adjust prices.
DurinDoor keeps two sets of numbers, and it helps to keep them apart:
- Usage is what this install counted: requests, tokens, latency, and an estimated cost. It lives on Dashboard → Usage (
/dashboard/usage). Monitoring usage covers that page. - Quota is what the provider says is left on the account. It lives on Dashboard → Quota Tracker (
/dashboard/quota), and routing reads it. Quota tracking covers how snapshots and preflight work.
Resetting usage never touches upstream quota, and the provider's own dashboard is still the billing authority.
When an account runs out
Open Quota Tracker and find the connection. A row that is exhausted or cooling down shows when it resets.
If the numbers look stale, use the account's Refresh (bypass cache) action. The dashboard calls GET /api/usage/{connectionId}?refresh=1, which skips the fresh quota cache but still honors provider 429 cooldowns. The existing ?force=1 API flag remains supported.
If the provider supports quota preflight and you have another eligible account, routing can skip the exhausted connection. Otherwise add a connection or put the model in a combo with a fallback member.
A provider without a usage fetcher shows Usage API not implemented for <provider>. That is expected; see the table below.
What each provider reports
These providers have a usage fetcher. The window names are the ones the Quota Tracker shows.
| Provider | Windows |
|---|---|
| Claude Code | session (5h), weekly (7d), per-model weekly rows |
| OpenAI Codex | session, weekly, and a review family for *-review models |
| GitHub Copilot | chat, completions, premium interactions; monthly quotas otherwise |
| Cursor | Included spend, Auto mode, API usage, On-demand (individual and team pool), per-model rows |
Antigravity, agy | per-model rows, Gemini Weekly, Claude & GPT Weekly |
| Kimi | Weekly, Rolling 5-hour |
| MiniMax, MiniMax CN | per-model 5-hour and weekly |
| DeepSeek | account balance in currency |
| OpenCode Go | weekly, monthly |
| Grok CLI | Credits, On-demand, Prepaid, Monthly |
Also covered, with provider-specific rows: Gemini CLI, Kiro, Qoder, Qwen, Bailian Coding Plan, iFlow, Ollama, GLM, GLM CN, Vercel AI Gateway, CodeBuddy CN, xAI, and Grok Web. xAI falls back to 30 days of local history when its API has nothing.
Being in this list does not mean routing uses the number. Preflight only reads providers that have a quota policy; the list is on Quota tracking. Everything else relies on the upstream returning 429.
Per-provider notes: Claude Code, OpenAI Codex, Cursor, Antigravity, Kiro.
You can hide individual reported rows per connection in the limits view if a provider reports buckets you do not care about. The choice is stored per connection. Claude model-scoped weekly windows omitted by an account appear as muted — / not reported placeholders when a sibling on the current page reports that window. These placeholders cannot be hidden and do not imply available or exhausted quota; they are excluded from totals and routing. See Claude Code quota.
Cooldowns
For retryable upstream failures, DurinDoor temporarily locks the account or model and tries another eligible connection. Terminal errors stop the request. Some provider capacity or setup errors have special handling.
| Trigger | Lock |
|---|---|
| 429 or a rate-limit or capacity message | Exponential: BACKOFF_BASE_MS (2000) doubled per level, capped at BACKOFF_MAX_MS (300000) and BACKOFF_MAX_LEVEL (15) |
| 401, 403, 404 | Two minutes |
| 402 | Two minutes, and the error is terminal for that request |
| Provider reset hint (for example Antigravity's reset timestamp, Kiro's monthly reset) | Until that time |
A 429 sent to the client carries Retry-After when the cooldown is known. The full behaviour is on Troubleshooting. The backoff variables are on Environment variables.
Retention
Nothing is pruned by default. Turn on Auto-clean old data under Profile → Observability to delete usage history, request details, timeline traces, and quota snapshots older than the window you pick (30 days unless you change it; presets 7, 15, 30, 60, or 90, or a custom value from 1 to 3650). The sweep runs hourly, starting a minute after boot. Clean now runs it at once. Over HTTP it is GET and POST /api/data-retention.
There is no CSV export for usage. Download Backup under Profile → Data & Backups saves portable configuration JSON, including API-key lifetime totals, but not request usage history, request details, or timeline events. To preserve that history, use an engine-level backup: the SQLite database or a PostgreSQL dump. See Data management.
Prices
Estimated cost uses the built-in model prices. Override a model's price on Settings → Pricing (/dashboard/settings/pricing) or through /api/pricing (GET, PATCH, DELETE to reset). New requests use the new price. Rows already stored keep their original estimate. Compare estimates with provider billing before using them for financial decisions.
Successful media operations preserve provider USD receipts when available, including explicit zero. Without a receipt, supported builtin audio rates or explicitly configured native tariffs can produce an estimate; otherwise native costs remain unknown. Token price overrides alone do not define per-image, per-second, or per-job prices. An unpriced or subscription-backed model is not automatically free. Chat token pricing is an estimate, and its configured rates may differ from subscription billing.
Dollar budgets (policy.maxCostUsd and monthlyBudget) compare recorded numeric spend only, and they deny the next request once that spend reaches the limit. Each model class behaves differently:
| Model | Recorded cost | Effect on a dollar budget |
|---|---|---|
| Provider returned a USD receipt, including zero | The receipt, costStatus: "known" | Adds the receipt. It outranks every price and override. |
| Built-in or overridden token price | Estimate, costStatus: "estimated" | Adds the estimate. |
| Free model with a built-in zero price | Estimated zero | Adds nothing. It is a price of zero, not an unknown price. |
| Subscription-backed model | Token-value estimate, not your subscription invoice | Adds the estimate, so a budget can run out while the subscription still has quota. Override the price with zeros to stop that. |
| Unpriced model or missing native quantity | cost: null, costStatus: "unknown" | Adds nothing and never denies. The event counts in unknownCostRequests, which the Est. cost card and the key's committed usage line show when it is above zero. |
A zero dollar total therefore does not prove free usage, and a dollar budget is not a hard spending cap for unpriced work. Set an override on Settings → Pricing for any model a budgeted key can reach. Unknown-cost requests still count toward request and token limits when reported. Failed or denied requests do not consume successful-use allowances. A chat stream that fails or is cancelled partway keeps its partial usage, because the provider can bill it. MCP gateway tool calls record zero cost; a successful call counts toward the key's request limits, and a failed one does not.
An async image job the provider accepted can still bill even if DurinDoor never sees it finish: the client aborted during polling, polling timed out, or a status check or result fetch failed or returned an unreadable body. DurinDoor records these with status: "accepted", costStatus: "unknown", costSource: "accepted-job" and meta.jobState: "accepted". They count as one request and one unknown-cost request, add no dollars and no tokens, and are not priced by a native tariff because no output was measured. A job the provider reports as failed, or a submission it refused, records nothing. After an accepted job, DurinDoor does not retry the request on another account of the same provider, because that would start a second billable job. Check the provider's dashboard for the actual charge. After an accepted job, DurinDoor also stops a combo from trying its next model, because that could start a second billable job. The caller gets the error, and the response carries x-durindoor-accepted-job: 1.
Asynchronous video (/v1/videos) and music (Suno, Udio) jobs get the same accepted row as soon as the provider returns a job id, so a job nobody polls again still appears in usage. When a poll later observes completion, DurinDoor updates that row in place with the provider's receipt or measured units: the request is not counted twice, and its unknown-cost count moves to known or estimated spend. A job the provider reports as failed, cancelled or expired removes the row, and it consumes no request allowance. If usage history was pruned or reset in between, the completion still corrects the key's lifetime totals.
Restoring or importing a database starts a new billing epoch. A request admitted before the restore whose provider call finishes after it is not recorded in the new epoch. Chat usage from such a request is dropped. Media and other non-chat routes fail the response with a usage-accounting error (USAGE_ACCOUNTING_FAILED) even though the provider already did the work, and the gateway does not retry the call. Avoid restoring while paid requests are in flight.
The unknown-cost count is a lifetime counter for the key. When DurinDoor rebuilds the per-key totals from retained usage history, which happens after a legacy import or when the totals table is missing, it reconstructs that count from the history it still holds. Retained history is only a lower bound: pruning, a history reset, or a restored backup can leave fewer rows than the lifetime count, so a rebuild raises the count to what the retained history supports and never lowers it. Migration 026 seeded the count on the first upgrade, and migration 028 repairs a count that an older rebuild dropped. A count that was seeded too high is not corrected downward.
Native-unit rate overrides
Operators can configure one flat native rate for an exact provider/model through authenticated PATCH /api/pricing. Rates are USD per unit, separate from the existing token rates in USD per million tokens. For example, the following illustrative operator tariff estimates $0.25 for each returned image; it is not a vendor price recommendation:
{ "openrouter": { "your-exact-image-model": { "native": { "unit": "image", "rate": 0.25 } } } }| Unit | Measured quantity | Supported usage |
|---|---|---|
image | nativeUnits.images | Returned image artifacts, including edits |
audio_second | nativeUnits.audioSeconds | Reported transcription, speech or music duration |
video_second | nativeUnits.videoSeconds | Reported completed video duration |
video_job | nativeUnits.videoJobs | One successfully completed asynchronous video job |
character | nativeUnits.characters | Characters measured by the speech handler |
Rates and quantities must be finite nonnegative numbers. Image, character and job quantities must be integers; durations may be fractional seconds. Requested image counts, requested duration, prompts and unfinished polls are not substituted for missing output measurements. A zero rate with a measured quantity is an estimated zero; a missing quantity remains unknown even when the configured rate is zero.
There is one native tariff per exact provider/model, without alias or pattern inheritance. It replaces an unknown or estimated native valuation. An authoritative numeric provider USD receipt, including zero, takes precedence. Native tariffs never become token rates or add a second charge to the same event. Without a native tariff, existing receipt/builtin behavior is preserved. Configure a flat tariff only when it applies to every measured unit for that model. Per-size, quality, resolution and tiered native tariffs are not supported: extra tariff fields are rejected, and no such dimensions or prices are guessed.
GET /api/pricing returns saved native tariffs alongside token pricing; token edits preserve native fields in the returned document. PATCH replaces the supplied model's override object, so include its native field when retaining it. The existing model/provider/all reset endpoints remove the relevant native overrides too. The dashboard's token-rate editor is not a native-tariff editor.
The first successful ledger commit snapshots the selected native rate, unit, measured quantity, provider/model and override origin in meta.pricing, with costStatus: "estimated" and costSource: "native-pricing". Later edits, resets, duplicate polls and process reopen do not reprice committed events. Numeric estimates feed the same lifetime and monthly dollar-budget counters as provider charges; unknown costs remain separately counted. Subscription-equivalent token prices and configured native prices are estimates, not proof of a provider invoice.
Media response bodies and any provider usage fields remain provider evidence. DurinDoor does not add a native-cost response header or rewrite binary/streaming bodies with ledger estimates. The ledger and usage analytics identify the operator estimate through the provenance above.
For chat responses, a generated usage.cost_usd carries cost_details.status: "estimated", source: "builtin", the builtin rate snapshot and basis: "response_token_counts". Those client token counts may include the existing response buffer. The accounting ledger uses recorded counts and applicable operator overrides, so its estimate can differ. A provider USD receipt is retained without replacing it with this builtin estimate. Do not treat a generated response estimate as a provider invoice or as proof of the ledger's exact committed amount.
Migration 028 holds database locks from before reconstruction until its repair transaction completes. SQLite acquires the database writer lock without changing any rows. PostgreSQL locks history, lifetime totals and API keys in SHARE ROW EXCLUSIVE mode, which conflicts with ordinary writers across connections and processes, including inserts for keys without a totals row. PostgreSQL requires READ COMMITTED isolation; other isolation levels abort the migration so a snapshot taken before the locks cannot supply stale history. If a lock cannot be acquired, the repair makes no partial change and the migration remains unapplied for retry. A writer waiting behind the repair adds its increment to the repaired count. Retried repairs and history pruning never lower that count. This serialization applies to migration 028; it does not add locking to other rebuild helpers.