Missing environment variable: `OPENAI_API_KEY` - Codex
Quick fix
Delete the env_key entry from config.toml, or set OPENAI_API_KEY in Windows environment variables, and confirm the provider supports the native response format.
Symptom
Section titled “Symptom”Missing environment variable: `OPENAI_API_KEY`.On Windows, the config cc-switch generates for Codex may not be read correctly. An `env_key` entry in `config.toml` makes environment variable injection fail. On top of that, Codex currently only natively supports the OpenAI `response` format API, so an incompatible provider endpoint format (Azure, for example) also leaves the config ineffective.
Open the Codex `config.toml`, find and delete the `env_key` entry, save, and restart Codex.
config.toml env_key = "OPENAI_API_KEY"If it still does not apply after deleting it, set the environment variable in Windows by hand. Open a command line, replace `YOUR_API_KEY` with your API key, and run: `setx OPENAI_API_KEY "YOUR_API_KEY"`.
Confirm your provider endpoint natively supports the `response` format. If it does not, the current version cannot use it directly — wait for a later cc-switch version to add local proxy format conversion.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 3 real issues
- I configured the provider details and it still errors. Is that the provider?
- Not necessarily. Users confirm this comes from the config not being applied correctly, and deleting `env_key` from `config.toml` usually resolves it.
- Why does connecting Azure to Codex through cc-switch not work?
- Codex currently only recognises the native `response` format API. Azure and similar endpoint formats may be incompatible; cc-switch plans a local proxy feature in a later version to convert the format.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.