How to use Azure provider

Resolved 💬 13 comments Opened Jul 24, 2025 by ken19980727 Closed Aug 5, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

Hi everyone,

I installed Codex CLI using the following command:

npm i -g @openai/codex

The installed version is codex-cli 0.9.0.

After installation, I followed an online example that uses Azure as the provider.
However, when I ran the command below, the system gave me an error:

error: unexpected argument '--provider' found

  tip: a similar argument exists: '--profile'

Usage: codex-x86_64-unknown-linux-musl --profile <CONFIG_PROFILE> [PROMPT]

For more information, try '--help'.

I noticed that the documentation mentions using --profile,
but I'm not sure how to properly use it in this case.

Could someone please point out what I'm doing wrong, or provide a working example?
Thanks in advance!

View original on GitHub ↗

13 Comments

vitatea2023 · 12 months ago
Hi everyone, I installed Codex CLI using the following command: `` npm i -g @openai/codex ` The installed version is codex-cli 0.9.0. After installation, I followed an online example that uses Azure as the provider. However, when I ran the command below, the system gave me an error: ` error: unexpected argument '--provider' found tip: a similar argument exists: '--profile' Usage: codex-x86_64-unknown-linux-musl --profile <CONFIG_PROFILE> [PROMPT] For more information, try '--help'. ` I noticed that the documentation mentions using --profile`, but I'm not sure how to properly use it in this case. Could someone please point out what I'm doing wrong, or provide a working example? Thanks in advance!

ask grok4

bolinfest collaborator · 12 months ago

@ken19980727 The example that you found is out of date. Please see:

https://github.com/openai/codex/blob/main/codex-rs/config.md#model_providers

ken19980727 · 12 months ago
@ken19980727 The example that you found is out of date. Please see: https://github.com/openai/codex/blob/main/codex-rs/config.md#model_providers

Hi @bolinfest,
First of all, thank you so much for your reply, I really appreciate it!

I've updated my model_providers section.
Here is my ~/.codex/config.toml:

[model_providers.azure]
name = "Azure"
base_url = "https://xxxxxxx.cognitiveservices.azure.com"
env_key = "xxxxxxxxxx4jNr"
query_params = { api-version = "2025-01-01-preview" }
wire_api = "responses"

However, when I run the codex command,
it still prompts me to run codex login.

Did I miss something?

jepio · 12 months ago

Check this thread: https://github.com/openai/codex/issues/1461

This variable is not supposed to be the value of the API key but the name of the env variable that the API key is fetched from:

env_key = "xxxxxxxxxx4jNr"
ken19980727 · 11 months ago
Check this thread: #1461 This variable is not supposed to be the value of the API key but the name of the env variable that the API key is fetched from: `` env_key = "xxxxxxxxxx4jNr" ``

Hi @jepio,
Thank you for sharing!

After updating my ~/.codex/config.toml, the file looks like this:

profile = "codex"

[model_providers.azure]
name = "Azure"
base_url = "https://xxxxx.cognitiveservices.azure.com"
env_key = "AZURE_OPENAI_API_KEY"
params = { api-version = "2025-01-01-preview" }
wire_api = "responses"

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

Then I ran:

codex

But it returned the following error:

Error loading configuration: config profile `codex` not found

It seems like it's unable to locate the codex profile.

Did I misconfigure something? I would really appreciate any guidance. Thank you!

jepio · 11 months ago

You defined a profile called "o4" but set the default profile name to "codex" - make those two match and it'll work. (an LLM could have helped with this problem 😄)

martrdev · 11 months ago

Hello! I have a very similar problem, I cannot make the azure model work.
This is what my "config.toml" looks like:

model_provider = "azure"
model = "gpt-4o"

[model_providers.azure]
name = "Azure"
# Make sure you set the appropriate subdomain for this URL.
base_url = "https://xxxxxxxxxxx.cognitiveservices.azure.com/"
env_key = "AZURE_OPENAI_API_KEY"
# Newer versions appear to support the responses API, see https://github.com/openai/codex/pull/1321
query_params = { api-version = "2024-10-21" }
# wire_api = "responses"

However when I run "codex", this is what I see:

<img width="701" height="281" alt="Image" src="https://github.com/user-attachments/assets/b12933d1-de7a-425e-b038-923afa03bc45" />

I also tried setting a profile with o4-mini and o3, or to uncomment wire_api, but the error stayed the same. I know for a fact that the service exists, because I use it for other applications too. Can you please help?

jepio · 11 months ago
Hello! I have a very similar problem, I cannot make the azure model work. This is what my "config.toml" looks like: `` model_provider = "azure" model = "gpt-4o" [model_providers.azure] name = "Azure" # Make sure you set the appropriate subdomain for this URL. base_url = "https://xxxxxxxxxxx.cognitiveservices.azure.com/" env_key = "AZURE_OPENAI_API_KEY" # Newer versions appear to support the responses API, see https://github.com/openai/codex/pull/1321 query_params = { api-version = "2024-10-21" } # wire_api = "responses" `` However when I run "codex", this is what I see: <img alt="Image" width="701" height="281" src="https://private-user-images.githubusercontent.com/193937905/471515654-b12933d1-de7a-425e-b038-923afa03bc45.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTM3MTEzMTAsIm5iZiI6MTc1MzcxMTAxMCwicGF0aCI6Ii8xOTM5Mzc5MDUvNDcxNTE1NjU0LWIxMjkzM2QxLWRlN2EtNDI1ZS1iMDM4LTkyM2FmYTAzYmM0NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNzI4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDcyOFQxMzU2NTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kOTZhZWM1Y2QxNGM2OTk4NDJiM2FlOTA4ZmIxMTBlYzk1MTllZWQ0MjkwYzFjMzU2OTZlNDMzY2RmMWVkZmVlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.II0HJdunhZdNobAuUpj___QiAb3XVP0T7BiRc5YYwcc"> I also tried setting a profile with o4-mini and o3, or to uncomment wire_api, but the error stayed the same. I know for a fact that the service exists, because I use it for other applications too. Can you please help?

You have two options:
wire_api=chat:

  • base_url must contain deployment name (model name is ignored): https://xxxxxxxxxxx.cognitiveservices.azure.com/openai/deployments/gpt-4.1

wire_api=responses:

  • base_url must end in /openai: https://xxxxxxxxxxx.cognitiveservices.azure.com/openai
  • api-version should be 2025-04-01-preview or newer
  • model name must match deployment name

Try:

model_provider = "azure"
model = "gpt-4o"


[model_providers.azure]
name = "Azure"
# Make sure you set the appropriate subdomain for this URL.
base_url = "https://xxxxxxxxxxx.cognitiveservices.azure.com/openai"
env_key = "AZURE_OPENAI_API_KEY"
# 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"
martrdev · 11 months ago

Fantastic, I can confirm that setting the api-version to 2025-04-01-preview worked.
To clarify, I already tried in the past to add "/openai" at the end of the base_url but nothing changed so that was not the (sole) reason. However, having this setting you proposed, worked 🎉

I suggest you guys add the example of the Azure endpoint being
base_url = "https://YOUR_PROJECT_NAME.cognitiveservices.azure.com/openai"
aside to the current example
base_url = "https://YOUR_PROJECT_NAME.openai.azure.com/openai"
and make sure to highlight that the api-version needs to be set up as 2025-04-01-preview or newer.
I personally believe this will help.

My current config.toml file is as follows:

model_provider = "azure"
model = "gpt-4o"

[model_providers.azure]
name = "Azure"
# Make sure you set the appropriate subdomain for this URL.
base_url = "https://XXXXXXXXXX.cognitiveservices.azure.com/openai" 
env_key = "AZURE_OPENAI_API_KEY"
# 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"

Thanks!

abazabaaa · 11 months ago

In case any else finds this.. this doesn't work if your company uses a special proxy for azure. You need to do this, which isn't well documented:

model_provider = "azure"
model = "o3"

[model_providers.azure]
name = "Azure"
base_url = "https://xxxxxxxxx.xxxx.com/openai/deployments/o3"
query_params = { api-version = "2025-04-01-preview" }
wire_api = "chat"
# Use env_http_headers to set the api-key header (Azure doesn't use Bearer auth)
env_http_headers = { api-key = "AZURE_OPENAI_API_KEY" }

[profiles.o3]
model = "o3"
model_provider = "azure"
ken19980727 · 11 months ago
> Hello! I have a very similar problem, I cannot make the azure model work. This is what my "config.toml" looks like: > `` > model_provider = "azure" > model = "gpt-4o" > > [model_providers.azure] > name = "Azure" > # Make sure you set the appropriate subdomain for this URL. > base_url = "https://xxxxxxxxxxx.cognitiveservices.azure.com/" > env_key = "AZURE_OPENAI_API_KEY" > # Newer versions appear to support the responses API, see https://github.com/openai/codex/pull/1321 > query_params = { api-version = "2024-10-21" } > # wire_api = "responses" > ` > > > > > > > > > > > > However when I run "codex", this is what I see: > <img alt="Image" width="701" height="281" src="https://private-user-images.githubusercontent.com/193937905/471515654-b12933d1-de7a-425e-b038-923afa03bc45.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTM3MTEzMTAsIm5iZiI6MTc1MzcxMTAxMCwicGF0aCI6Ii8xOTM5Mzc5MDUvNDcxNTE1NjU0LWIxMjkzM2QxLWRlN2EtNDI1ZS1iMDM4LTkyM2FmYTAzYmM0NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNzI4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDcyOFQxMzU2NTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kOTZhZWM1Y2QxNGM2OTk4NDJiM2FlOTA4ZmIxMTBlYzk1MTllZWQ0MjkwYzFjMzU2OTZlNDMzY2RmMWVkZmVlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.II0HJdunhZdNobAuUpj___QiAb3XVP0T7BiRc5YYwcc"> > I also tried setting a profile with o4-mini and o3, or to uncomment wire_api, but the error stayed the same. I know for a fact that the service exists, because I use it for other applications too. Can you please help? You have two options: wire_api=chat: * base_url must contain deployment name (model name is ignored): https://xxxxxxxxxxx.cognitiveservices.azure.com/openai/deployments/gpt-4.1 wire_api=responses: * base_url must end in /openai: https://xxxxxxxxxxx.cognitiveservices.azure.com/openai * api-version should be 2025-04-01-preview or newer * model name must match deployment name Try: ` model_provider = "azure" model = "gpt-4o" [model_providers.azure] name = "Azure" # Make sure you set the appropriate subdomain for this URL. base_url = "https://xxxxxxxxxxx.cognitiveservices.azure.com/openai" env_key = "AZURE_OPENAI_API_KEY" # 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" ``

Hi @jepio , thanks again for your guidance!

I’ve updated my config.toml as follows:

model_provider = "azure"
model = "gpt-4.1-mini"

[model_providers.azure]
name = "Azure"
base_url = "https://xxxx.openai.azure.com/openai/deployments/gpt-4.1-mini"
env_key = "AZURE_OPENAI_API_KEY"
params = { api-version = "2025-01-01-preview" }
wire_api = "chat"

As you can see, I’ve switched the model_provider to azure, and pointed the base URL to the correct deployment endpoint.

However, the response still shows a 404 Not Found error.

<img width="1517" height="414" alt="Image" src="https://github.com/user-attachments/assets/bb6c8a82-2965-4bcd-88e7-b5ea89c274ba" />

Could you help me identify what might be going wrong?

Thanks in advance!

jepio · 11 months ago
I’ve updated my config.toml as follows: `` model_provider = "azure" model = "gpt-4.1-mini" [model_providers.azure] name = "Azure" base_url = "https://xxxx.openai.azure.com/openai/deployments/gpt-4.1-mini" env_key = "AZURE_OPENAI_API_KEY" params = { api-version = "2025-01-01-preview" } wire_api = "chat" ``

params is not the right field, you need query_params.

 model_provider = "azure"
 model = "gpt-4.1-mini"
 
 [model_providers.azure]
 name = "Azure"
 base_url = "https://xxxx.openai.azure.com/openai/deployments/gpt-4.1-mini"
 env_key = "AZURE_OPENAI_API_KEY"
-params = { api-version = "2025-01-01-preview" }
+query_params = { api-version = "2025-04-01-preview"}
 wire_api = "chat"
ken19980727 · 11 months ago

@jepio Thanks!
it finally worked