azure models not working
What version of Codex is running?
0.1.2505172129
Which model were you using?
gpt-4.1
What platform is your computer?
Darwin 24.1.0 arm64 arm
What steps can reproduce the bug?
https://vscode.dev/github/openai/codex/blob/main/codex-cli/src/utils/model-utils.ts#L21
https://vscode.dev/github/openai/codex/blob/main/codex-cli/src/utils/config.ts#L115
is it not able to get providers data from ~/.codex/config.json. ?
nano ~/.codex/config.json
{
"model": "gpt-4.1",
"provider": "azure",
"providers": {
"openai": {
"name": "OpenAI",
"baseURL": "https://api.openai.com/v1",
"envKey": "Open AI API KEY"
},
"openrouter": {
"name": "OpenRouter",
"baseURL": "https://openrouter.ai/api/v1",
"envKey": "OPENROUTER_API_KEY"
},
"azure": {
"name": "AzureOpenAI",
"baseURL": "https://ynare-******-swedencentral.openai.azure.com",
"envKey": "3cmGTsoIUBRKNGRA0LkeI8OIeqlzgYcJzcJw1sfDRde****************",
"AZURE_BASE_URL": "https://ynare-*******-swedencentral.openai.azure.com",
"AZURE_API_KEY": "3cmGTsoIUBRKNGRA0LkeI8OIeqlzgYcJzcJw1sfD************""
},
What is the expected behavior?
it should take api_key from nano ~/.codex/config.json
providers --> azure --> envKey
( or )
providers --> azure --> AZURE_API_KEY
https://vscode.dev/github/openai/codex/blob/main/codex-cli/src/utils/config.ts#L124
What do you see instead?
---------- error log -----
Error: No API key configured for provider: azure
at z$e (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:658:4320)
at wC (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:658:4608)
at file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:669:4055
at file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:669:4293
at Nm (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:112:27792)
at L4e (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:125:13596)
at B4e (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:125:13340)
at k4e (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:125:13246)
at O4e (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:125:13122)
at RIe (file:///Users/yarramsettinaresh/.npm/_npx/5010de4b76d2184a/node_modules/@openai/codex/dist/cli.js:129:11814)
Additional information
_No response_
9 Comments
You should place the API key content in the “~/.zshrc” file, not in the config.json file.
The config.json file should look like this:
and the following line will be included in your “~/.zshrc” file
thanks @mahmutdemr
it working with AZURE_OPENAI_API_KEY adding to ~/.zshrc
now it not raising any error, but not using Azure model.
Surprising I am not able to see logs in openAI platform dashboard, but but credits use got drained https://platform.openai.com/logs
-------- I things this it RCA -----
{"model": "gpt-4.1",
"provider": "AzureOpenAI",
"providers": {
"openai": {
"name": "OpenAI",
"baseURL": "https://api.openai.com/v1",
"envKey": "OPENAI_API_KEY"
},
"openrouter": {
"name": "OpenRouter",
"baseURL": "https://openrouter.ai/api/v1",
"envKey": "OPENROUTER_API_KEY"
},
"azure": {
"name": "AzureOpenAI",
"baseURL": "https://nbmbb.openai.azure.com/",
"envKey": "2kJHa2A0bQMFCtg1ObyGIXqASFZGLIbfIybgGp2RVgbJ2GpNpKyJQQJ99BEACYeBjFXJ3w3AAABACOGelEB"
}
"provider": "AzureOpenAI",
but in openai-client.ts#L35 and agent-loop.ts#L334 . it's checking "azure" but in the config it;s allowing "AzureOpenAI"
please check the below two line
if (config.provider?.toLowerCase() === "azure") {return new AzureOpenAI({
apiKey: getApiKey(config.provider),
baseURL: getBaseUrl(config.provider),
apiVersion: AZURE_OPENAI_API_VERSION,
timeout: OPENAI_TIMEOUT_MS,
defaultHeaders: headers,
});
}
I'm having a similar issue. API is set correctly. Model endpoint and API are checked and verified as working. Codex even launches and shows the the following:
However, the /model selector shows no modals available and is only set manually by adding --model gpt-4.1 and test connection or any other text always returns the following:
When I test with a basic curl command I can send and receive from my enpoint with the API key in terminal but codex is having issues using it.
I discovered that the baseURL was not getting set by the yaml configuration but was set when using
exportNow I've got a new error unrelated to this issue. But I think the OPs issue still stands--some how config values are not getting picked up and the env file is not loading correctly. It only works when I export to shell.
not working too
The configuration file is not read at all,
Related: https://github.com/openai/codex/issues/1552
I think this issue is no longer relevant, so I'm closing it out. If you have related questions, please feel free to post to the discussion forum. Or feel free to open a new bug report.