Azure Open AI not supported(?)

Resolved 💬 4 comments Opened May 17, 2025 by brentwc Closed Aug 7, 2025

What version of Codex is running?

0.1.2505161243

Which model were you using?

gpt-4o-mini

What platform is your computer?

linux | x64 | 5.15.167.4-microsoft-standard-WSL2

What steps can reproduce the bug?

cat <<EOF > .env
AZURE_OPENAI_API_KEY=`<key.value>`
AZURE_OPENAI_API_VERSION=`<api.version>`
EOF
cat <<EOF > ~/.codex/config.yaml
model: gpt-4o-mini
provider: azure
providers:
  azure:
    name: AzureOpenAI
    baseURL: https://`<project.name>`.openai.azure.com/openai
    envKey: AZURE_OPENAI_API_KEY
approvalMode: suggest
fullAutoErrorMode: ask-user
notify: true
EOF
codex 'say hello'

What is the expected behavior?

"Hello."

What do you see instead?

╭──────────────────────────────────────────────────────────────╮
│ ● OpenAI Codex (research preview) v0.1.2505161243            │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ localhost session: 799947181fe549c0973432efcf8157de          │
│ ↳ workdir: ~/workspace/`<parent>`/`<child>`                  │
│ ↳ model: gpt-4o-mini                                         │
│ ↳ provider: azure                                            │
│ ↳ approval: suggest                                          │
╰──────────────────────────────────────────────────────────────╯
user
say hello

    system
    ⚠️  OpenAI rejected the request. Error details: Status: 401, Code: 401, Type: unknown, Message: 401 Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource..
     Please verify your settings and try again.

Additional information

The composition of Azure OpenAI API URL's may be in appropriately assembled by the codex package as this pattern worked for me; while codex refused.

curl https://`<project.name>`.openai.azure.com/openai/deployments/`<deployment-id>`/chat/completions?api-version=`<api.version>` \
  -H "Content-Type: application/json" \
  -H "api-key: `<key.value>`" \
  -d '{
    "messages": [{"role": "user", "content": "Say Hello"}],
    "temperature": 0,
    "max_tokens": 50
  }'

View original on GitHub ↗

4 Comments

BillWang-dev · 1 year ago

I have the same issue.
$ codex --provider deepseek --model deepseek-chat
╭──────────────────────────────────────────────────────────────╮
│ ● OpenAI Codex (research preview) v0.1.2505161243 │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ localhost session: 8786dd859c574a439ee73a038d033caf │
│ ↳ workdir: ~/Desktop/JS-123456 │
│ ↳ model: deepseek-chat │
│ ↳ provider: deepseek │
│ ↳ approval: suggest │
╰──────────────────────────────────────────────────────────────╯
user
hello

system
⚠️ OpenAI rejected the request. Error details: Status: 401, Code:
invalid_request_error, Type: authentication_error, Message: 401 Authentication Fails,
Your api key: ****Tv0A is invalid. Please verify your settings and try again.

breakstring · 1 year ago

#891

bdschaap · 1 year ago

The last version I was able to get the Azure provider to work on was 0.1.2505160811. A change in 0.1.2505161129 seems to have broken it.

codex-maintainers · 1 year ago

Thank you for the feedback! Please try again with the latest version of Codex CLI. If the issue persists, we'd appreciate further details or a PR to the codex-rs/ implementation. You can find more information about our focus on the Rust implementation here: https://github.com/openai/codex/discussions/1174.