Azure OpenAI Python SDK works, but codex CLI fails with 404
Resolved 💬 5 comments Opened Apr 17, 2025 by adhishthite Closed Aug 7, 2025
📓 Context
I’m able to successfully connect to Azure OpenAI using the Python SDK with the following code:
import os
from openai import AzureOpenAI
endpoint = "https://REDACTED.openai.azure.com/"
deployment = "o4-mini"
subscription_key = "REDACTED"
api_version = "2025-03-01-preview"
client = AzureOpenAI(
api_version=api_version,
azure_endpoint=endpoint,
api_key=subscription_key,
)
response = client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "I am going to Paris, what should I see?"}
],
max_completion_tokens=100000,
model=deployment
)
print(response.choices[0].message.content)
This works as expected and returns a valid completion from the o4-mini deployment.
---
❗ Issue
However, when I attempt to use the Codex CLI with the following environment variables:
export OPENAI_API_KEY="REDACTED"
export OPENAI_API_TYPE="azure"
export OPENAI_BASE_URL="https://REDACTED.openai.azure.com/"
export OPENAI_API_VERSION="2025-03-01-preview"
and run:
codex
and ask a question, I get this:
⚠️ OpenAI rejected the request. Error details:
Status: 404, Code: 404, Type: unknown,
Message: 404 Resource not found. Please verify your settings and try again.
I also tried setting these values in .codex/config.yaml but still got the same error.
---
🔍 Ask
Could someone help confirm:
- Is Codex CLI compatible with Azure OpenAI?
- If yes, what’s the correct way to configure it for a custom deployment like o4-mini?
- Is there a different env var required for specifying the deployment name?
Would appreciate a quick fix or workaround here—blocking usage on our end. Thanks!
<img width="794" alt="Image" src="https://github.com/user-attachments/assets/8ddcb0f0-68d7-451a-9f34-7be1c5c71e0f" />
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗