You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cloud provider balances: one status the controller exposes and the desktop panel shows #21
Owner request (2026-11-16): see the remaining balance of every cloud provider in one place, including the oxc panel on the desktop.
What each provider offers with an ordinary API key (checked today):
OpenRouter: GET /api/v1/key returns limit_remaining (null when the key has no limit), usage and daily usage; GET /api/v1/credits returns the account's total credits and total usage (remaining = the difference). On a refused request the error body carries error.metadata.limit_source, which says whether the key limit or the account credit was hit.
Anthropic: no balance endpoint for an API key. An exhausted account answers HTTP 400 with 'Your credit balance is too low'. State can only be 'ok', 'out of credit' (from that error, remembered) or 'unknown'.
OpenAI API: no balance endpoint for an API key. Show the spend recorded in our own ledger against a credit figure the owner enters, and 'insufficient_quota' when that error is seen.
ChatGPT subscription: signed in or not; rate-limit state from the last response (limited until when), no money balance.
Wanted, in the Rust controller (the Python one is legacy):
A provider-level balance() with a typed result: remaining_usd (if known), source (provider API, own ledger estimate, unknown), state (ok, low, out_of_credit, rate_limited_until, signed_out), checked_at. Cached, refreshed at most every few minutes and after any budget or credit refusal; never on the request path; keys never logged.
Refusals classified once: credit exhausted, key limit, rate limit, with OpenRouter's limit_source kept. A run that hits 'out of credit' stops with that typed reason (last night a task retried into it).
One status surface: oxa ctl status (or the gateway's status call) lists providers with balance and state plus today's spend from the ledger and the remaining daily budget; a warning threshold per provider in settings.
The desktop panel shows that list: provider, remaining or state, today's spend; a provider that is out of credit or signed out is marked.
Until this exists the orchestrator uses a small script that reads the same endpoints.
Owner decision (2026-11-16): same rule as for models (#628): balances are read live from the providers by the controller, nothing hand-entered or hand-kept. Drop the 'credit figure the owner enters' idea for OpenAI above: where a provider offers no balance for the key, show the state honestly as 'not reported by the provider' plus our own ledger spend, and the typed out-of-credit state when the provider refuses. The orchestrator's script is a stopgap only and is removed when this lands.
Provider parity, researched from the official docs and the open-source Codex CLI, plus live probes with ordinary keys (2026-11-16). This replaces the rough list in the issue text.
Remaining balance
Spend so far
Rate-limit state
Refusal classes
OpenRouter
GET /api/v1/key: limit_remaining, effective_budget.remaining_usd, budgets[]; GET /api/v1/credits: total_credits - total_usage (docs say management key; an ordinary key answered in our probe: treat as optional)
/key: usage, usage_daily/weekly/monthly; per response usage.cost
none on success; Retry-After on 429/503 and some 402
credit exhausted: HTTP 400 invalid_request_error, message 'Your credit balance is too low…', x-should-retry: false (seen live); 429 rate_limit_error (with error.details.error_code = enforced_spend_limit_reached for the tier spend cap, no retry-after); 400 'You have reached your specified API usage limits'; 529 overloaded_error
OpenAI API
not offered (the old credit-grants endpoint is browser-session only)
GET /v1/organization/costs and /organization/usage/completions: need the api.usage.read scope (an ordinary project key gets 403 naming that scope)
x-ratelimit-{limit,remaining,reset}-{requests,tokens} on every response
branch on error.code: credit_balance_exhausted, organization_spend_limit_exceeded, project_spend_limit_exceeded, organization_usage_limit_exceeded (all 429, type may read insufficient_quota); slow_down; 503 server_is_overloaded
ChatGPT subscription
GET /backend-api/wham/usage: credits.{has_credits,unlimited,balance}, spend_control
same call: rate_limit.{primary_window,secondary_window}.{used_percent,reset_at}, plan_type
429 with error.type = usage_limit_reached (plan_type, resets_at in Unix seconds) or usage_not_included
Consequences for the design:
One typed result for all four: remaining (money, or percent of a window for the subscription), spend, limits (last seen), state, source, checked_at. 'Not reported by the provider' is a first-class value, never a guess.
Rate-limit state is taken passively from response headers and cached per provider and model: no extra calls.
Optional second credential per provider for spend: an Anthropic Admin key, an OpenAI key with api.usage.read. Without it: our own ledger, labelled as this gateway's spend only.
The subscription route is a private, unversioned interface: every field optional, parse defensively.
The classifier above is the single place refusals are typed; a run that meets a non-retryable class stops with it.
codex-queue / #25 audit: status.rs card/conversions and refresh.rs throttle have only internal test callers on current main. rust-cloud confirms neither is an S7/provider dependency and permits cleanup after helper check (331 comment6915526942). Owning helpers: any committed integration depends on these modules? Propose deleting unused presentation/scheduler rather than retaining speculative APIs; keep rate_limits.rs for concrete oxstack/ox-llm#680 client. No credential/runtime/ledger edits.
Triage 2026-11-19: this issue is now tracked in #158 (Cluster: Usage, budgets and the desktop panel, priority P1), planned PR 1: "Status envelope and usage". It will be fixed there together with its related issues, not one by one.
Activity
n0rpan commentedon Nov 16, 2026
Owner decision (2026-11-16): same rule as for models (#628): balances are read live from the providers by the controller, nothing hand-entered or hand-kept. Drop the 'credit figure the owner enters' idea for OpenAI above: where a provider offers no balance for the key, show the state honestly as 'not reported by the provider' plus our own ledger spend, and the typed out-of-credit state when the provider refuses. The orchestrator's script is a stopgap only and is removed when this lands.
🤖 Generated with Claude Code
n0rpan commentedon Nov 16, 2026
Provider parity, researched from the official docs and the open-source Codex CLI, plus live probes with ordinary keys (2026-11-16). This replaces the rough list in the issue text.
GET /api/v1/key:limit_remaining,effective_budget.remaining_usd,budgets[];GET /api/v1/credits:total_credits - total_usage(docs say management key; an ordinary key answered in our probe: treat as optional)/key:usage,usage_daily/weekly/monthly; per responseusage.costRetry-Afteron 429/503 and some 402error.metadata.limit_source:openrouter_credits,openrouter_in_flight_budget(402);openrouter_key_limit,openrouter_guardrail_budget,openrouter_workspace_budget(403, withlimit_usd,spend_usd,resets_at); upstreamprovider_overloaded/provider_unavailableGET /v1/organizations/cost_reportand/usage_report/messages(about 5 minutes fresh): Admin key only (needs an organization); an ordinary key gets 401anthropic-ratelimit-{requests,tokens,input-tokens,output-tokens}-{limit,remaining,reset},retry-afterinvalid_request_error, message 'Your credit balance is too low…',x-should-retry: false(seen live); 429rate_limit_error(witherror.details.error_code = enforced_spend_limit_reachedfor the tier spend cap, no retry-after); 400 'You have reached your specified API usage limits'; 529overloaded_errorGET /v1/organization/costsand/organization/usage/completions: need theapi.usage.readscope (an ordinary project key gets 403 naming that scope)x-ratelimit-{limit,remaining,reset}-{requests,tokens}on every responseerror.code:credit_balance_exhausted,organization_spend_limit_exceeded,project_spend_limit_exceeded,organization_usage_limit_exceeded(all 429, type may readinsufficient_quota);slow_down; 503server_is_overloadedGET /backend-api/wham/usage:credits.{has_credits,unlimited,balance},spend_controlrate_limit.{primary_window,secondary_window}.{used_percent,reset_at},plan_typex-codex-{primary,secondary}-{used-percent,window-minutes,reset-at},x-codex-credits-*error.type = usage_limit_reached(plan_type,resets_atin Unix seconds) orusage_not_includedConsequences for the design:
remaining(money, or percent of a window for the subscription),spend,limits(last seen),state,source,checked_at. 'Not reported by the provider' is a first-class value, never a guess.api.usage.read. Without it: our own ledger, labelled as this gateway's spend only.🤖 Generated with Claude Code
n0rpan commentedon Nov 16, 2026
codex-queue / #25 audit: status.rs card/conversions and refresh.rs throttle have only internal test callers on current main. rust-cloud confirms neither is an S7/provider dependency and permits cleanup after helper check (331 comment6915526942). Owning helpers: any committed integration depends on these modules? Propose deleting unused presentation/scheduler rather than retaining speculative APIs; keep rate_limits.rs for concrete oxstack/ox-llm#680 client. No credential/runtime/ledger edits.
n0rpan commentedon Nov 19, 2026
Triage 2026-11-19: this issue is now tracked in #158 (Cluster: Usage, budgets and the desktop panel, priority P1), planned PR 1: "Status envelope and usage". It will be fixed there together with its related issues, not one by one.