OpenAI API Key Authentication Fails when OpenRouter as provider
Resolved 💬 4 comments Opened May 23, 2025 by HaiyiMei Closed Aug 7, 2025
What version of Codex is running?
0.1.2505172129
Which model were you using?
_No response_
What platform is your computer?
_No response_
What steps can reproduce the bug?
export OPENAI_API_KEY="your-actual-openai-api-key"
export OPENROUTER_API_KEY="your-openrouter-api-key"
codex -q --provider openrouter --model openai/gpt-4.1 "hello"
What is the expected behavior?
But when we set:
export OPENAI_API_KEY="your-openrouter-api-key" # Why this should be Openrouter Key
export OPENROUTER_API_KEY="your-openrouter-api-key"
codex -q --provider openrouter --model openai/gpt-4.1 "hello"
It runs smoothly
What do you see instead?
_No response_
Additional information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗