Environment variables for custom providers are not getting picked up
Resolved 💬 9 comments Opened Apr 25, 2025 by KiBk Closed Aug 7, 2025
💡 Likely answer: A maintainer (LuciNyan, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
0.1.2504221401
Which model were you using?
any
What platform is your computer?
Darwin 24.3.0 arm64 arm
What steps can reproduce the bug?
Define variables for a custom provider with a key and baseurl export PROXY_API_KEY="abc" && export PROXY_BASE_URL="abc" && codex --provider proxy
What is the expected behavior?
Connect to my API proxy
What do you see instead?
$ codex --provider proxy
Missing proxy API key.
Set the environment variable PROXY_API_KEY and re-run this command.
You can create a PROXY_API_KEY in the proxy dashboard.
Additional information
It does seem like the environment variables aren't being picked up
Thank you in advance!
9 Comments
I am experiencing this same issue. Tried your approach of setting environment variables and using a .env file to define the api key, and I get the same error with each approach.
I have the following:
but it gets ignored:
I have tried all approaches, and nothing worked:
Hi @diegorusso 👋. You can try modifying the provider's name.
okay, I know what happened now.
"envKey": "XXXAI_API_KEY" in config.json is literally "XXXAI_API_KEY", not the api key you have to replace with.
Thank you @LuciNyan, I updated to 0.1.2504251709 and your config.json worked great!
@ttchin
jajajaja xD. I think the key is to replace
"provider": "openai"with"provider": "any other AI". I suspect there’s special handling for theopenaivalue. I haven’t had a chance to dig into the code yet, but that’s my guess. 👀Btw, your avatar is pretty cool!!
After upgrade to 0.1.2504251709, it picks the configuration details. I have only one provider and it is chose automatically.
Thank you for the feedback! Please try again using the latest version of Codex CLI. If the issue persists, feel free to report it on the
codex-rs/implementation.