Skip to content

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

Closed

Description

@adhishthite

📓 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

Activity

  1. tibo-openai commented on Apr 17, 2025

    @tibo-openai
    Collaborator

    There is an open PR here:
    #92

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

  2. added
    enhancement
    on Apr 17, 2025
  3. adhishthite commented on Apr 17, 2025

    @adhishthite
    Author

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

  4. piyushptiwari1 commented on May 30, 2025

    @piyushptiwari1

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

  5. vishal9483 commented on Jun 22, 2025

    @vishal9483

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

  6. codex-maintainers commented on Aug 7, 2025

    @codex-maintainers

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions