Codex CLI uses OPENAI_API_KEY instead of logged-in session
Resolved 💬 2 comments Opened Aug 24, 2025 by abdulmunimjundurahman Closed Oct 28, 2025
What version of Codex is running?
codex-cli 0.23.0
Which model were you using?
gpt5
What platform is your computer?
Linux 6.8.0-52-generic x86_64 x86_64
What steps can reproduce the bug?
- Log in with codex login successfully.
- Run a Codex CLI command (e.g., codex run ...).
- Notice that the CLI attempts to use OPENAI_API_KEY from the environment instead of the logged-in session.
What is the expected behavior?
Codex CLI should use the logged-in session token when a user is authenticated via codex login, even if an OPENAI_API_KEY is set.
What do you see instead?
Codex ignores the login session and tries to use OPENAI_API_KEY, which may cause authentication errors or unexpected behavior.
Additional information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗