Azure OpenAI integration: 401 and 429 errors with o4-mini deployment (valid key/endpoint)
What version of Codex is running?
0.1.2505172129
Which model were you using?
o4-mini
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Summary
I am unable to connect to my Azure OpenAI "o4-mini" deployment using Codex. I encounter a 401 ("invalid subscription key or wrong endpoint") when my environment variable and endpoint appear correct, and after changes, now get a 429 ("too many requests") error.
Steps to Reproduce
- Azure resource: YOUR-Project-name-eastus2
- Model deployed as:
o4-mini - Codex config:
{
"model": "o4-mini",
"provider": "azure",
"providers": {
"azure": {
"name": "AzureOpenAI",
"baseURL": "https://YOUR-Project-name-eastus2.openai.azure.com/openai",
"envKey": "AZURE_OPENAI_API_KEY",
"deployment": "o4-mini",
"apiVersion": "2025-01-01-preview"
}
}
}
- AZURE_OPENAI_API_KEY is set to my actual resource key.
- Using endpoint as above.
- When I start Codex with this config, and send a simple message (“hi”), I get the following errors (at different times):
401 Access denied due to invalid subscription key or wrong API endpoint.
OR
429 Too Many Requests (after changing config as suggested)
What is the expected behavior?
When I configure the Azure OpenAI provider in Codex with my valid deployment name, endpoint, API key, and API version, I expect to be able to send chat requests and receive responses from my Azure OpenAI deployment (in my case, the o4-mini model). There should be no authorization (401) or quota (429) errors as long as my credentials and usage are correct. Instead, Codex should return response completions from my Azure OpenAI model as expected.
What do you see instead?
Instead of receiving a response from my Azure OpenAI deployment, I encounter error messages. At first, I received a 401 Access denied due to invalid subscription key or wrong API endpoint error, even though I verified that my API key and endpoint were correct. After making adjustments to my configuration, I now receive a 429 Too Many Requests error, even when the usage should be well within quota limits. As a result, I am unable to get any chat completion responses from my deployment.
- I checked on the azure dashboard no calls to o4-mini were made
Additional information
What I’ve Tried
- Double-checked my key matches the portal ("Keys and Endpoint" section).
- Verified the endpoint matches my Azure resource and regional deployment.
- Confirmed deployment name is correct (“o4-mini”).
- Waited and retried in case of capacity or quota issues.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗