Enable user to add API Key while being signed in.

Resolved 💬 2 comments Opened May 3, 2026 by divyamagrawal06 Closed May 3, 2026

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

  1. 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.

  1. 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 }.

  1. 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.

  1. 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

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗