Skip to content

[Feature]: Show per-organization API balance and read time for API-key providers, or UNKNOWN with reason #8397

Closed

Description

@vibewriter-hand

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?

What should OpenCodex do?

  1. 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 --quota and in the dashboard.
  2. 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.
  3. If a provider or organization has no source, or the source needs a credential the pool does not hold, show UNKNOWN with the reason.
  4. 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:

Activity

  1. coderabbitai commented on Nov 8, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7581 - feat(quota): read Abliteration credit balance from /v1/credits [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    enhancement
    provider
    on Nov 8, 2026
  3. lidge-jun commented on Nov 10, 2026

    @lidge-jun
    Owner

    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 quotaMode values (probe, passive, unsupported; src/providers/quota/vendor-probes-key.ts around line 1566 and src/providers/quota/account-cache.ts). probe providers 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 report unsupported with no reason. #8297 is open for passive rate-limit headroom, which is a different figure.

    Options:

    1. Make the absence explicit: keep quotaMode and add a closed reason for unsupported (for example no_balance_source), shown as UNKNOWN with that reason in ocx account list --quota and the dashboard. No new credential, no new traffic.
    2. Admin-key cost or usage sources for OpenAI and Anthropic. These report spend, not remaining prepaid balance, and need a separate admin credential type with its own storage, scope and review. The value for "can this pool still serve" is indirect.
    3. A per-organization balance with a read timestamp and staleness, generalized from the existing probe readers, which already carry a read time.

    Recommendation: option 1 now, plus surfacing the existing read time for probe providers (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.

  4. lidge-jun commented on Nov 11, 2026

    @lidge-jun
    Owner

    Owner decision: step 1 only. When a balance is unknown, ocx account list --quota and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementprovider

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions