Azure OpenAI Integration fails with stream error: unexpected status 404 Not Found

Open 💬 7 comments Opened Oct 14, 2025 by hegdeashwin
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What is the type of issue?

Documentation is missing, Example code is not working

What is the issue?

~/.codex/config.toml

model_provider = "azure"
model = "gpt-5"

[model_providers.azure]
name = "Azure"
base_url = "https://<resource>.<my-company>.com/<project>/openai"
wire_api = "responses"
env_key  = "AZURE_OPENAI_API_KEY"

[profiles.azure]
model_provider = "azure"
model = "gpt-5"

[projects."/Users/ashegde/Documents/pp/adk-samples"]
trust_level = "trusted"

export AZURE_OPENAI_API_KEY="<TOKEN>"

When i run following command:

codex --profile azure -m "gpt-5" "hello from device code"

I see stream error: unexpected status 404 Not Found: { "statusCode": 404, "message": "Resource not found" }; retrying 1/5 in 190ms… error.

Here is how I'm generating the token for Azure OpenAI:

from azure.identity import DefaultAzureCredential, get_bearer_token_provider
import os

print(os.getenv("AZURE_CLIENT_ID"))
print(os.getenv("AZURE_TENANT_ID"))
print(os.getenv("AZURE_CLIENT_SECRET"))

credential = DefaultAzureCredential()
scope = "https://cognitiveservices.azure.com/.default"

# Get the token provider (it's a callable)
token_provider = get_bearer_token_provider(credential, scope)

# Call it to get the actual token
token = token_provider()  # Returns the bearer token string

print(f"Token: {token}")

The token is valid because I'm able to use the same token to query LLM that is deployed on the Azure OpenAI. Also GPT-5 model do exist in https://<resource>.<my-company>.com/<project>/openai"

Where did you find it?

_No response_

View original on GitHub ↗

7 Comments

github-actions[bot] contributor · 9 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #5079
  • #4480
  • #3920
  • #3786

Powered by Codex Action

hegdeashwin · 9 months ago

I reviewed all the shared above issues link however non of them were able to solve the issue

hegdeashwin · 9 months ago

Any update or Acknowledgement on the issue?

TreeOfLearning · 9 months ago

Have you tried removing the <project> part from the base url? I don't have this in my config and it's working fine. My url is formatted: https://<blah>.cognitiveservices.azure.com/openai/

URL and API key can both be found on the Azure OpenAI foundry page:

<img width="191" height="326" alt="Image" src="https://github.com/user-attachments/assets/a363e06c-b55e-4c88-9bbe-4d40406f3893" />

Of course, your setup may be different.

hegdeashwin · 9 months ago
  1. I removed the <project> part from the base url but still same error.
  2. I logged into Azure Portal > Azure AI Foundary > Overview, under which I see Azure OpenAI > Endpoint which I tried as well but results into same issue. However, I see a message under on Azure UI - API Key authentication is disabled.

<img width="982" height="640" alt="Image" src="https://github.com/user-attachments/assets/652d7bff-e1ef-4133-a89e-d7e7f677e08d" />

Would that be causing the issue?

jfreemanwbd · 9 months ago

Hi, I came upon this post and found that I was able to get it working in my environment after adding the following to my config.toml

query_params = { api-version = "2025-04-01-preview" }

I am using a gpt-5-codex model deployment so your mileage may vary.

Good luck!

humphd · 3 months ago

I had to drop the wire_api and include the query_params to make this work:

model = "gpt-5.2-codex"
model_provider = "azure"
model_reasoning_effort = "medium"

[model_providers.azure]
name = "Azure OpenAI"
base_url = "https://<resource>.cognitiveservices.azure.com/openai"
query_params = { api-version = "2025-04-01-preview" }
env_key = "AZURE_ACCESS_TOKEN"