How to configure codex@native with AZURE?

Resolved 💬 7 comments Opened Jun 2, 2025 by misteral Closed Nov 30, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What is the type of issue?

Documentation is missing

What is the issue?

I try to use standard openai configuration with AZURE openai endpoint, but it not work. Please help me configure it

Where did you find it?

_No response_

View original on GitHub ↗

7 Comments

linegel · 1 year ago

It's not just with native, it doesn't work with azure endpoint on latest and all versions in between native and latest too

At least include you config json/toml + logs

misteral · 1 year ago

Hi @linegel , I try it with codex, installed by npm i -g @openai/codex@native it does'n work.

config.toml:

```config.toml
#model = "o4-mini"
profile = "azure"
sandbox_permissions = [
"disk-full-read-access",
"disk-write-platform-user-temp-folder",
"disk-write-platform-global-temp-folder",
"disk-write-cwd",
]

[model_providers.openai-chat-completions]
name = "azure"
base_url = "https://ai-albssdsdsdsds.openai.azure.com/"
env_key = "token"
wire_api = "chat"

[profiles.azure]
model = "o4-mini"
model_provider = "openai-chat-completions"
approval_policy = "on-failure"

------
But it work for me if It installed by `npm install -g @openai/codex`

working config.json

{
"model": "o4-mini",
"provider": "AzureOpenAI",
"providers": {
"azure": {
"name": "AzureOpenAI",
"baseURL": "https://ai-albssdsdsdsds.openai.azure.com/",
"envKey": "token"
}
}
}

linegel · 1 year ago

I can see the issue

envKey in config is wrong place for token - it's just a name of encryption variable from which you will get token, AZURE_API_KEY could be set as envKey

And then you should have AZURE_API_KEY with your token as value, so echo $AZURE_API_KEY shows your token

Once you update config it should start to work ;)

doggy8088 · 1 year ago

I can't run either.

$ codex exec --profile o4-mini hi
[2025-07-11T22:04:06] OpenAI Codex v0.5.0 (research preview)
--------
workdir: /home/user/projects/Learn-Git-in-30-days
model: o4-mini
provider: azure
approval: Never
sandbox: read-only
reasoning effort: medium
reasoning summaries: auto
--------
[2025-07-11T22:04:06] User instructions:
hi
[2025-07-11T22:04:08] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 1/10 in 200ms…
[2025-07-11T22:04:09] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 2/10 in 252ms…
[2025-07-11T22:04:11] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 3/10 in 315ms…
[2025-07-11T22:04:12] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 4/10 in 436ms…
[2025-07-11T22:04:14] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 5/10 in 573ms…
[2025-07-11T22:04:16] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 6/10 in 691ms…
[2025-07-11T22:04:18] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 7/10 in 870ms…
[2025-07-11T22:04:20] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 8/10 in 1.305s…
[2025-07-11T22:04:22] stream error: error sending request for url (https://res-name.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 9/10 in 1.642s…

Here is my ~/.codex/config.toml:

model_provider = "azure"

[model_providers.azure]
name = "Azure"
# Make sure you set the appropriate subdomain for this URL.
base_url = "https://res-name.openai.azure.com/openai"
env_key = "AZURE_OPENAI_API_KEY"  # Or "OPENAI_API_KEY", whichever you use.
# Newer versions appear to support the responses API, see https://github.com/openai/codex/pull/1321
query_params = { api-version = "2025-04-01-preview" }
wire_api = "responses"

[profiles.o4-mini]
model = "o4-mini"
model_provider = "azure"

[profiles.o3]
model_provider = "azure"
model = "o3"

[profiles.mistral]
model_provider = "ollama"
model = "mistral"

The AZURE_OPENAI_API_KEY is already set.

What else I can try?

graceleeis · 12 months ago

same error here, cannot use AOAI foundry model codex-mini

doggy8088 · 10 months ago
etraut-openai contributor · 7 months ago

Closing in favor of #2480