You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macOS: Electron app cannot access AZURE_API_KEY from ~/.zshrc when using env_key in Codex CLI config #317
Bug: Electron app cannot read AZURE_API_KEY from shell environment when using Codex CLI config
Description
When using Codex CLI through the desktop app, the CLI configuration references an API key via an environment variable:
env_key = "AZURE_API_KEY"
However, the Electron desktop application cannot access environment variables defined in shell configuration files such as ~/.zshrc. As a result, Codex CLI fails with the error:
Missing environment variable: AZURE_API_KEY
This occurs even though the variable is correctly defined and works when running Codex CLI directly from the terminal.
Add the API key to the shell environment (e.g. ~/.zshrc):
export AZURE_API_KEY=your_key
Verify it works in the terminal:
echo $AZURE_API_KEY
Launch the Electron desktop app.
Run a Codex CLI action that uses the Azure provider.
Actual behavior
The CLI returns:
Missing environment variable: AZURE_API_KEY
Expected behavior
The desktop application should allow environment variables defined in the user environment to be available to the Codex CLI process, or provide a supported mechanism (e.g., .env support or environment variable configuration in the app settings).
Workarounds
Currently the issue can be bypassed by:
Option 1 — Using launchctl:
launchctl setenv AZURE_API_KEY <key>
Option 2 — Adding the API key directly in config.toml:
api_key = "your_key"
Minimal reproducible example
The issue can be reproduced with the following minimal configuration:
Starting it from a CLI which has the ENV variable allows you to actually use it. This however does not remove the authentication warning, even though it still works :D (this was tested on an azure foundry backend)
yup, same here, using env_key = "OPENAI_API_KEY" in my codex/config.toml - error says it cannot be read, even though it works when started from CLI or via Codex App.
Activity
olafhartong commentedon Mar 10, 2026
Starting it from a CLI which has the ENV variable allows you to actually use it. This however does not remove the authentication warning, even though it still works :D (this was tested on an azure foundry backend)
bbrzoska commentedon Mar 30, 2026
yup, same here, using
env_key = "OPENAI_API_KEY"in my codex/config.toml - error says it cannot be read, even though it works when started from CLI or via Codex App.randomUser00 commentedon May 20, 2026
is opening the app via the terminal using
open -na "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/Applications/T3 Code (Alpha).app"still the only solution?DarthGigi commentedon Jun 4, 2026
@randomUser00 You can add env vars per provider now, however, I'd still like a single source of truth solution
t3dotgg commentedon Aug 22, 2026
Note
🤖 GPT-5.6 Sol in Codex responding on behalf of Theo
Closing as resolved. Provider-specific environment variables solve the reported Azure key setup.