Skip to content

Sign in with API key via environment variable cannot be used if ChatGPT subscription login is active #3286

Description

@gh640

What version of Codex is running?

codex-cli 0.30.0

Which model were you using?

gpt-5

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

  1. Install Codex CLI 0.30.0
  2. Set a valid environment variable OPENAI_API_KEY
  3. Run codex --config preferred_auth_method='chatgpt'
    • Login with ChatGPT Plus, Pro or Team plan account and close the session.
  4. Run codex --config preferred_auth_method='apikey'
  5. Select 2. Provide your own API key

What is the expected behavior?

Codex CLI is usable with API key even with ChatGPT subscription login is active.

What do you see instead?

The message "To use Codex with the OpenAI API, set OPENAI_API_KEY in your environment" continues to be displayed even with OPENAI_API_KEY is set and codex session doesn't start.

Additional information

Related issues

I confirmed this occurs with the latest 0.30.0 in my environment.

Metadata

Metadata

Assignees

Labels

authIssues related to authentication and accountsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions