Skip to content

api keys and extra usage - #13

Merged
DexterStorey merged 9 commits into
mainfrom
api-keys-extra-usage
Jul 22, 2026
Merged

api keys and extra usage#13
DexterStorey merged 9 commits into
mainfrom
api-keys-extra-usage

Conversation

@DexterStorey

Copy link
Copy Markdown
Contributor

Fixes #10.

Accounts can now be API keys, and extra usage is visible everywhere it exists.

Extra usage. Both providers already report it on the endpoints we poll, so this costs no new requests. Claude's extra_usage and spend blocks and codex's credits block parse into one shape on the usage snapshot. When an account has it on, its row grows one cell: extra 25% against the monthly limit when the provider reports utilization, or the remaining balance. Colored by pressure like every other meter.

API key accounts. tokenmaxx login <codex|claude> --api-key [key] prompts for a key and a name, validates the key against the provider, and stores it in the Keychain like every other credential. Claude keys route to api.anthropic.com with x-api-key; OpenAI keys route to api.openai.com/v1 with a bearer header. A key account's row shows measured spend over the last 31 days, priced at list rates from our own token metering, since keys have no subscription windows.

Rotation. Each account gets one new choice, toggled with e on its row: at the threshold, switch accounts (today's behavior, still the default) or spill into extra usage. A spilling account holds through the threshold and through a full window while credits remain, and rotation resumes the moment the provider reports the spend limit reached. API key accounts are deliberately not auto-rotation targets in this pass, since rotating onto pay-per-token real money should be a person's explicit choice; they switch manually like any other account.

Scope notes, deliberately deferred: the analytics tab still prices everything at ≈ list rates rather than splitting real extra-usage dollars out, and the dashboard's add-account row still starts the OAuth flow only, with API keys added from the CLI.

Verified: 44 tests including wire-shape tests against captured payloads from real accounts, spill and exhaustion decisions, and header injection for both key types; fixture-driven TUI captures of the new cells at multiple widths.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

try this branch: bun add -g tokenmaxx@0.0.54-alpha.65

@DexterStorey
DexterStorey merged commit a971584 into main Jul 22, 2026
3 checks passed
@DexterStorey
DexterStorey deleted the api-keys-extra-usage branch July 22, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support api keys and extra usage

1 participant