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_
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I reviewed all the shared above issues link however non of them were able to solve the issue
Any update or Acknowledgement on the issue?
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.
<project>part from the base url but still same error.<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?
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!
I had to drop the
wire_apiand include thequery_paramsto make this work: