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!
13 Comments
ask grok4
@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_providerssection.Here is my
~/.codex/config.toml:However, when I run the
codexcommand,it still prompts me to run
codex login.Did I miss something?
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:
Hi @jepio,
Thank you for sharing!
After updating my
~/.codex/config.toml, the file looks like this:Then I ran:
But it returned the following error:
It seems like it's unable to locate the
codexprofile.Did I misconfigure something? I would really appreciate any guidance. Thank you!
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 😄)
Hello! I have a very similar problem, I cannot make the azure model work.
This is what my "config.toml" looks like:
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?
You have two options:
wire_api=chat:
https://xxxxxxxxxxx.cognitiveservices.azure.com/openai/deployments/gpt-4.1wire_api=responses:
/openai:https://xxxxxxxxxxx.cognitiveservices.azure.com/openai2025-04-01-previewor newerTry:
Fantastic, I can confirm that setting the api-version to
2025-04-01-previewworked.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-previewor newer.I personally believe this will help.
My current
config.tomlfile is as follows:Thanks!
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:
Hi @jepio , thanks again for your guidance!
I’ve updated my
config.tomlas follows:As you can see, I’ve switched the
model_providertoazure, and pointed the base URL to the correct deployment endpoint.However, the response still shows a
404 Not Founderror.<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!
paramsis not the right field, you needquery_params.@jepio Thanks!
it finally worked