api keys and extra usage - #13
Merged
Merged
Conversation
|
try this branch: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_usageandspendblocks and codex'screditsblock 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 toapi.anthropic.comwithx-api-key; OpenAI keys route toapi.openai.com/v1with 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
eon 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.