Repository navigation
Closed
Labels
enhancementNew feature or requestproviderProvider adapters, OpenAI-compat presets, upstream API quirks
Description
Area
Provider adapters
What are you trying to accomplish?
Show, per provider and per organization, the remaining API credit balance and the time it was last read, so an operator can tell whether an API-key pool can still serve requests. Where a provider does not expose a balance, the dashboard and ocx account list --quota should say so and show UNKNOWN, never 0 and never a guessed value.
What prevents this today?
ocx account list <provider> --quota --jsonon an API-key account returnsquotaMode: unsupportedand no balance field. A reader cannot tell "no balance source" from "balance is zero".- The provider documentation we checked exposes spend, not remaining balance, through admin APIs:
- Anthropic: the usage and cost report endpoints (organization level, admin key required).
- OpenAI: the organization costs and usage endpoints (admin key required).
- We did not find a public endpoint that returns prepaid credit grants or a remaining balance for either provider, so the balance value itself could not be confirmed from docs alone.
- Admin keys are a different credential type from inference keys, so an inference-key pool cannot read these endpoints. For most users the gap is silent.
- Related but different open issues: [Feature]: Surface rate-limit headroom from response headers for API-key providers (OpenAI, Anthropic API, xAI, Groq, Mistral) #8291 (passive rate-limit headers for API-key providers), [Feature]: Show Mistral API and Vibe budget usage from /v1/billing/budget #8290 (Mistral budget endpoint), Preserve decimal precision for WorkBuddy quota aggregation #8324 (WorkBuddy quota precision). None of them asks for organization-level balance with a read timestamp.
What should OpenCodex do?
- For each provider, state which balance or usage sources it supports: none, passive response headers, an admin cost or usage API, or a documented balance endpoint. Show the list in
ocx account list --quotaand in the dashboard. - For each organization that has a balance source, show the remaining balance with its currency as reported by the provider, the source name, and the timestamp of the last successful read. Mark the value stale after a configurable age.
- If a provider or organization has no source, or the source needs a credential the pool does not hold, show UNKNOWN with the reason.
- Do not store admin keys, raw response bodies, or organization identifiers in logs or state files. Store only the figures, the source name, and the read time.
Example usage or interface
$ ocx account list openai-api --quota
OpenAI org <org-label> balance 42.10 USD source: credit balance API read 3 min ago
OpenAI org <org-label-2> balance UNKNOWN reason: no admin key in pool
Anthropic org <org-label> balance UNKNOWN reason: provider exposes cost report only
The <org-label> values are placeholders for user-chosen names.
Alternatives or workarounds
- Enter a starting balance by hand and subtract spend from an admin cost report. This drifts when spend is not reported in real time and needs an admin key.
- Read the provider dashboard by hand. This is not automatic and does not work for unattended runs.
Additional context
Checks performed by the reporter before filing:
- Searched open and closed issues for balance, credit, quota, billing and usage terms. The closest matches are [Feature]: Surface rate-limit headroom from response headers for API-key providers (OpenAI, Anthropic API, xAI, Groq, Mistral) #8291 and [Feature]: Show Mistral API and Vibe budget usage from /v1/billing/budget #8290, which cover other data sources (headers and a Mistral budget endpoint).
- Provider documentation consulted for this report (not verified against live calls in this issue): Anthropic usage and cost API reference, and the OpenAI organization usage and credit-grant pages.
Reacted by coderabbitai
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestproviderProvider adapters, OpenAI-compat presets, upstream API quirks
Activity
coderabbitai commentedon Nov 8, 2026
🔗 Related PRs
#7581 - feat(quota): read Abliteration credit balance from /v1/credits [merged]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
lidge-jun commentedon Nov 10, 2026
Triage against current
dev(df0e6cc), read-only. Not implemented in this pass: it needs a product decision about credential types and sources.What exists today: API-key accounts report one of three
quotaModevalues (probe,passive,unsupported;src/providers/quota/vendor-probes-key.tsaround line 1566 andsrc/providers/quota/account-cache.ts).probeproviders already read a documented balance with the inference key: OpenRouter (/api/v1/key), DeepSeek (/user/balance), Ollama Cloud (/api/balance), Moonshot/Kimi (/v1/users/me/balance), Venice (/api/v1/billing/balance) and Abliteration (#7581). OpenAI and Anthropic inference keys have no balance source, so they reportunsupportedwith no reason. #8297 is open for passive rate-limit headroom, which is a different figure.Options:
quotaModeand add a closed reason forunsupported(for exampleno_balance_source), shown as UNKNOWN with that reason inocx account list --quotaand the dashboard. No new credential, no new traffic.probereaders, which already carry a read time.Recommendation: option 1 now, plus surfacing the existing read time for
probeproviders (the per-provider part of option 3). Option 2 needs a maintainer decision because it adds a new credential class and still would not yield a remaining balance.Decision needed: whether admin-key sources are in scope at all.
lidge-jun commentedon Nov 11, 2026
Owner decision: step 1 only. When a balance is unknown,
ocx account list --quotaand the dashboard show the reason and the read time; values appear only for providers that already have a balance probe. Admin-key organization cost APIs are out of scope. Implementing now.pr-assets: API key balance last-read line (#8397)
fix(quota): name an empty balance read, and keep listings alive on a …
feat(quota): say why an API-key balance is unknown and when it was la…