codex icon indicating copy to clipboard operation
codex copied to clipboard

Azure OpenAI Python SDK works, but codex CLI fails with 404

Open adhishthite opened this issue 1 year ago • 5 comments

📓 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:

  1. Is Codex CLI compatible with Azure OpenAI?
  2. If yes, what’s the correct way to configure it for a custom deployment like o4-mini?
  3. 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!

Image

adhishthite avatar Apr 17 '25 03:04 adhishthite

There is an open PR here: https://github.com/openai/codex/pull/92

Could you try it and comment there if it doesn't work?

tibo-openai avatar Apr 17 '25 03:04 tibo-openai

@tibo-openai Done! :) Looking forward to getting this integrated soon!

adhishthite avatar Apr 17 '25 03:04 adhishthite

Hi @adhishthite Is your issue resolved? I am also facing the same issue

piyushptiwari1 avatar May 30 '25 11:05 piyushptiwari1

I am also facing same issue. Anyone has any update on this?

vishal9483 avatar Jun 22 '25 16:06 vishal9483

Thank you for the detailed feedback! Please try using the latest version of Codex CLI, as we're actively working on improvements and fixes. If the issue persists, we'd appreciate it if you could try contributing a fix to the codex-rs/ implementation. More details on our project update can be found here.

codex-maintainers avatar Aug 07 '25 18:08 codex-maintainers