Expose organization API credit balance to statusLine scripts (and via Admin API)

Status Closed — not planned
Maintainer reply None cached
Activity 7 comments · opened Apr 13, 2026 · closed May 31, 2026

Summary

Pay-as-you-go API users have no programmatic way to see their remaining credit balance. The statusLine stdin payload includes model and rate_limits.{five_hour,seven_day}.used_percentage, but nothing about the actual money left in the account.

Why this matters

  • The 5h / 7d rate-limit bars measure throughput, not money. They tell me nothing about whether my next call will fail with credit balance is too low.
  • The console at console.anthropic.com shows the balance, but there is no public API endpoint for it. GET /v1/organizations/balance returns 404.
  • For people topping up credits manually (no auto-recharge), this means jobs can die mid-run with no warning. A statusLine bar would have warned me hours earlier.
  • I built a local approximation by parsing ~/.claude/projects/**/*.jsonl usage fields and applying per-token pricing — but that only covers Claude Code traffic, ignores SDK / MCP / direct API traffic, and drifts from reality. The org itself knows the real number.

Proposed solutions (either works)

Option A — statusLine stdin enrichment
Add an optional field to the JSON Claude Code pipes to statusLine commands:

{
  \"model\": { ... },
  \"rate_limits\": { ... },
  \"organization\": {
    \"credit_balance_usd\": 27.43,
    \"auto_recharge_enabled\": false
  }
}

This is the minimum-friction fix — every existing statusLine script can opt in.

Option B — Public Admin API endpoint
Expose GET /v1/organizations/me/balance (or similar) returning current credit balance + auto-recharge state. Then anyone (statusLine, dashboards, CI cost gates) can query it directly with their Admin API key.

Option A is enough for most users; Option B is the more general fix.

Acceptance

  • Some way for a script to read \"USD remaining in this account, right now\" without scraping the console.

View original on GitHub ↗

6 Comments

vfmatzkin · 4 months ago

+1. As a workaround I built a statusline script that tracks cost per session using the cost fields already in the JSON (total_cost_usd, total_api_duration_ms, total_lines_added, etc.). It persists each session's cost to disk and sums them against a configurable budget, so you get something like $232/300 in the status bar (plus the chat metrics before that)

Of course It's not a real balance, it only sees Claude Code traffic and drifts from the actual account, but it's meant to catch runaway sessions before they burn through everything. Repo: https://github.com/vfmatzkin/claude-statusline

<img width="739" height="37" alt="Image" src="https://github.com/user-attachments/assets/e6cdf1db-7179-4ce0-b10c-85a0201d744d" />

arpan-ghosh · 4 months ago

Made this the other day and prevents me from having to keep a browser window open and frantically refreshing. Not low-friction though, and is essentially calling non-official public endpoints and "scraping"/parsing values: https://github.com/arpan-ghosh/claude-spend-pulse

Feel free to give this a shot for the time being, until an official API endpoint is stood up (if ever).

github-actions[bot] · 3 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

suhinini · 1 month ago

Why is this closed? The issue is still there: you can't check if the balance is getting below X and react. No way I'm turning on an auto-topup mechanism on AI, so there needs to be an automated monitoring mechanism exposed.

elvisoliveira · 1 month ago

+1, a read-only credit balance endpoint would close a real gap for cost monitoring

m8-t · 1 month ago

Even outside the org/Admin-API angle, this would help individual Pro/Max subscribers too: once Extra Usage billing kicks in past the 5h/weekly limit, there's currently no way for a statusLine script to surface remaining extra-usage credit (the OAuth usage API reportedly has an extra_usage object with used_credits/monthly_limit/utilization, but it isn't exposed to statusLine). Would be useful to reconsider a read-only version of this for individual accounts, not just orgs.

Showing cached comments. Read the full discussion on GitHub ↗