What variant of Codex are you using?
CLI, App
What feature would you like to see?
/add-api-key while being signed in with a ChatGPT account.
- Fallback API key in cred store
- User uses codex as normal
- When limits run out, just switches to API key
- This feature can be extended to the App and it benefits app users as well.
Why?
- People using codex with an API key will likely have a ChatGPT account that they would prefer using before using API.
- This is a big pain point as it means having to constantly log out and log in. Often, it means having to generate a new key as you would copy/paste the key only once.
Additional information
Proposed Solution
-
New fallback API key in the cred store
Extend AuthDotJson (in codex-rs/login/src/auth/) to optionally store a secondary fallback_openai_api_key field alongside ChatGPT tokens. only used when the primary ChatGPT session hits a rate/usage limit.
-
New TUI slash command: /add-api-key <sk-…>
Add SlashCommand::AddApiKey to codex-rs/tui/src/slash_command.rs with supports_inline_args() = true. The dispatch arm in codex-rs/tui/src/chatwidget/slash_dispatch.rs would call a new AppEvent::AddFallbackApiKey { key }.
-
New app-server method: account/addFallbackApiKey
Add a new method to the app-server protocol (codex-rs/app-server-protocol/src/protocol/v2.rs) that stores the fallback key without touching the active ChatGPT session. distinct from account/login/start { type: "apiKey" }, as that replaces the session.
-
Automatic fallback in the model client
In codex-rs/protocol/src/error.rs (or the model client layer), when a UsageLimitReachedError is detected and a fallback API key is stored, the session should swap the active CodexAuth in-memory (without writing to disk) to CodexAuth::ApiKey for the remainder of the session
What variant of Codex are you using?
CLI, App
What feature would you like to see?
/add-api-key while being signed in with a ChatGPT account.
Why?
Additional information
Proposed Solution
New fallback API key in the cred store
Extend AuthDotJson (in codex-rs/login/src/auth/) to optionally store a secondary fallback_openai_api_key field alongside ChatGPT tokens. only used when the primary ChatGPT session hits a rate/usage limit.
New TUI slash command: /add-api-key <sk-…>
Add SlashCommand::AddApiKey to codex-rs/tui/src/slash_command.rs with supports_inline_args() = true. The dispatch arm in codex-rs/tui/src/chatwidget/slash_dispatch.rs would call a new AppEvent::AddFallbackApiKey { key }.
New app-server method: account/addFallbackApiKey
Add a new method to the app-server protocol (codex-rs/app-server-protocol/src/protocol/v2.rs) that stores the fallback key without touching the active ChatGPT session. distinct from account/login/start { type: "apiKey" }, as that replaces the session.
Automatic fallback in the model client
In codex-rs/protocol/src/error.rs (or the model client layer), when a UsageLimitReachedError is detected and a fallback API key is stored, the session should swap the active CodexAuth in-memory (without writing to disk) to CodexAuth::ApiKey for the remainder of the session