-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Feature: Claude usage source via minimal inference call reading anthropic-ratelimit-unified-* headers (multi-account with setup-tokens / user:inference) #1894
Copy link
Copy link
Closed as not planned
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.help wantedExtra attention is neededExtra attention is neededimpact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.This issue is about auth, provider routing, model choice, or SecretRef resolution.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Description
Metadata
Metadata
Assignees
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.help wantedExtra attention is neededExtra attention is neededimpact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.This issue is about auth, provider routing, model choice, or SecretRef resolution.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Summary
Add a Claude usage source that reads live 5h/weekly limits from the
anthropic-ratelimit-unified-*response headers of a minimalPOST /v1/messagescall. This works with long-livedclaude setup-tokencredentials (scopeuser:inference) and would enable multiple persistent Claude accounts in the menu bar without browser cookies — a concrete mechanism for #1756 / #1843 / #1268.Problem
For people running several Claude subscription accounts via a multi-account switcher (e.g.
claude-switch, which mints one ~1‑yearclaude setup-tokenper account), CodexBar currently has no clean way to show all of them live at once:GET /api/oauth/usage) requires scopeuser:profile.setup-tokens areuser:inferenceonly → 403 (measured). A full/logintoken hasuser:profile, but its refresh token rotates and doesn't stay valid — which is exactly why these users switched to setup-tokens.sessionKeyis revoked on logout, so switching accounts in one browser kills the previously-harvested account's data.Net result: no durable way to show N long-lived Claude accounts (cf. #1756, #1843, #1268; and token-loss reports like #1823).
Discovery (measured on CodexBar 0.37.2 / macOS)
A minimal inference call with a
user:inferencesetup-token returns HTTP 200 and carries the same unified limits in the response headers:Response headers:
Notes:
GET /api/oauth/usagewith the same token returns 403 (user:profilerequired) — the dedicated usage endpoint is unavailable, but the headers carry the equivalent 5h/weekly data.POST /v1/messages/count_tokensdoes not include these headers, so it must be a real (max_tokens:1) messages call. Cost ≈ 1 output token per poll.Proposed feature
For a Claude
tokenAccountwhose token is ansk-ant-oat…with onlyuser:inference(or as an automatic fallback when/api/oauth/usagereturns 403), obtain quota by issuing one tiny inference call and mapping headers:unified-5h-utilization/-reset→ session (5h) windowunified-7d-utilization/-reset→ weekly windowThis lets tokenAccounts backed by setup-tokens show live per-account quota without browser cookies (no logout fragility) and without
user:profile— i.e. genuine multi-account overview with durable ~1‑year tokens.Why it's attractive
Caveats / open questions
modelid must be a currently-available model → keep a small fallback list.Happy to provide more header captures, and I can attempt a PR if this direction is welcome. Thanks for CodexBar — it's genuinely great.