Regression: codex exec with -c flags to configure provider and settings for azure no longer work since 0.11.0

Resolved 💬 6 comments Opened Aug 2, 2025 by tmuskal Closed Aug 5, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.11.0

Which model were you using?

any

What platform is your computer?

any

What steps can reproduce the bug?

running

codex exec -c model=codex-mini -c model_provider=azure -c model_providers.azure.name=azure -c model_providers.azure.wire_api=responses -c model_providers.azure.base_url=https://my-azure-resource.openai.azure.com/openai -c model_providers.azure.env_key=AZURE_OPENAI_API_KEY -c model_providers.azure.query_params.api-version=2025-04-01-preview

What is the expected behavior?

as it was in 0.10.0 - it should run the agent and communicate with the azure hosted model

What do you see instead?

i see:


[2025-08-02T09:35:00] ERROR: Missing environment variable: `OPENAI_API_KEY`. Create an API key (https://platform.openai.com/) and export it as an environment variable.

and when trying to set the OPENAI_API_KEY with the value of AZURE_OPENAI_API_KEY - i get:

[2025-08-02T09:49:07] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 1/10 in 214ms…

[2025-08-02T09:49:07] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 2/10 in 277ms…

[2025-08-02T09:49:08] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 3/10 in 304ms…

[2025-08-02T09:49:08] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 4/10 in 436ms…

[2025-08-02T09:49:09] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 5/10 in 551ms…

[2025-08-02T09:49:09] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 6/10 in 800ms…

[2025-08-02T09:49:10] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 7/10 in 901ms…

[2025-08-02T09:49:11] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 8/10 in 1.244s…

[2025-08-02T09:49:13] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 9/10 in 1.782s…

[2025-08-02T09:49:15] stream error: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}; retrying 10/10 in 2.164s…

[2025-08-02T09:49:17] ERROR: unexpected status 404 Not Found: {"error":{"code":"404","message": "Resource not found"}}

Additional information

seems like it is related to the recent login module changes

View original on GitHub ↗

6 Comments

bolinfest collaborator · 1 year ago

^^ @pakrym-oai

blrchen · 1 year ago

I am experiencing same issue after upgrading to 0.11.0.

kingdomseed · 1 year ago

I'm having the same issue--resource no longer found.

# Default settings ── used when you run plain `codex`
model_provider = "azure"
model          = "codex-mini-latest"            # pick whatever you want as your day-to-day default

[model_providers.azure]
name         = "Azure OpenAI – JHD"
# NOTE: leave **only** the part up to /openai
base_url     = "https://jhdaihubservices.cognitiveservices.azure.com//openai"
env_key      = "AZURE_OPENAI_API_KEY"        # export this in ~/.zshrc
wire_api     = "responses"                   # o-series, GPT-4.1, etc. are Responses-only
query_params = { api-version = "2025-04-01-preview" }
jepio · 1 year ago

@pakrym-oai https://github.com/openai/codex/pull/1712 broke two assumption:

  1. model_provider.env_key is not consulted in load_auth, hardcodes OPENAI_API_KEY
  2. base_url for a responses URL doesn't include query_params, see this:
--- before      2025-08-04 16:58:20.008271160 +0200
+++ after       2025-08-04 17:02:07.542261507 +0200
@@ -1,4 +1,4 @@
-[core/src/client.rs:167:13] &req_builder = RequestBuilder {
+[core/src/client.rs:194:13] &req_builder = RequestBuilder {
     method: POST,
     url: Url {
         scheme: "https",
@@ -12,15 +12,13 @@
         ),
         port: None,
         path: "/openai/responses",
-        query: Some(
-            "api-version=2025-04-01-preview",
-        ),
+        query: None,
         fragment: None,
     },
     headers: {
-        "authorization": Sensitive,
         "openai-beta": "responses=experimental",
-        "session_id": "00ee87e7-045b-41cf-8652-89daeb91df87",
+        "session_id": "edb5bf34-5641-4b74-9097-9f6262ebac6a",
+        "authorization": Sensitive,
         "accept": "text/event-stream",
         "content-type": "application/json",
     },

this would be a fix:

diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs
index 10bf0d1c..2a8cdb5a 100644
--- a/codex-rs/core/src/client.rs
+++ b/codex-rs/core/src/client.rs
@@ -130,11 +130,11 @@ impl ModelClient {
 
         let store = prompt.store && auth.mode != AuthMode::ChatGPT;
 
-        let base_url = match self.provider.base_url.clone() {
-            Some(url) => url,
+        let url = match self.provider.base_url.as_ref() {
+            Some(_) => self.provider.get_full_url(),
             None => match auth.mode {
-                AuthMode::ChatGPT => "https://chatgpt.com/backend-api/codex".to_string(),
-                AuthMode::ApiKey => "https://api.openai.com/v1".to_string(),
+                AuthMode::ChatGPT => "https://chatgpt.com/backend-api/codex/responses".to_string(),
+                AuthMode::ApiKey => "https://api.openai.com/v1/responses".to_string(),
             },
         };
 
@@ -183,7 +183,7 @@ impl ModelClient {
 
             let req_builder = self
                 .client
-                .post(format!("{base_url}/responses"))
+                .post(&url)
                 .header("OpenAI-Beta", "responses=experimental")
                 .header("session_id", self.session_id.to_string())
                 .bearer_auth(&token)
bolinfest collaborator · 1 year ago

Fixed in 0.12.0! Available on npm; still waiting for Homebrew to pick it up.

bolinfest collaborator · 1 year ago

https://github.com/Homebrew/homebrew-core/pull/232370 is the PR to update Homebrew to 0.12.0. It's currently waiting for review, but I'm going to close this now.