feat(auth): support Codex rate limit reset credits in quota inspection and consumption - #475
Merged
SaladDay merged 1 commit intoSep 29, 2026
Conversation
…n and consumption - Query available rate limit reset credits from ChatGPT backend API during quota inspection - Integrate reset credits display into both textual and JSON provider/auth quota outputs - Add fail-closed redemption flow with dry-run default and mandatory --confirm safety gate - Add 'cc-switch auth reset-quota' subcommand and 'cc-switch provider quota <id> --reset' flag - Automatically select earliest expiring credit when credit_id is not specified - Re-inspect quota immediately upon successful redemption following CPA-Helper keeper rules
Owner
|
LGTM, THANKS |
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.
Summary
This PR adds support for querying and redeeming OpenAI / Codex server-side Rate Limit Reset Credits (Banked Resets) in
cc-switch.Background & Motivation
ChatGPT Pro and selected Team accounts receive periodic Rate Limit Reset Credits (Banked Resets) when hitting rate limit windows. Previously, users had to log into the web interface or run custom scripts to check or redeem reset credits. This change allows users to view available reset credits directly during quota inspection and safely redeem them via the CLI.
Features
Reset Credits Querying:
GET https://chatgpt.com/backend-api/wham/rate-limit-reset-creditsduring Codex quota inspection.reset_type == "codex_rate_limits",status == "available",is_supported_by_plan == true, non-emptygranted_at).expires_atso the optimal card is queued first.cc-switch provider quota <id>and JSON outputs.Safe Consumption Flow:
--confirmdisplays target credit metadata, expiration, available card count, and a warning that consumption is permanent and irreversible.--confirmflag required to execute consumption againstPOST https://chatgpt.com/backend-api/wham/rate-limit-reset-credits/consume.--credit-id <id>) or defaults to the earliest expiring credit.code: "reset"andcode: "already_redeemed"as success.CLI Interfaces:
cc-switch auth reset-quota [--account-id <id>] [--credit-id <id>] [--confirm] [--json]cc-switch provider quota <provider-id> --reset [--credit-id <id>] [--confirm] [--json]Testing
filter_and_sort_codex_reset_credits_applies_strict_rules).parse_codex_usage_with_reset_credits).auth reset-quotaandprovider quota --reset.cargo +1.91.1 test --lib services::subscription::tests(13 passed)cargo +1.91.1 test --lib cli::tests(110 passed)cargo +1.91.1 test --lib cli::commands::provider_inspect::tests(21 passed)cargo +1.91.1 check --bin cc-switch(clean, 0 errors)