Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Azure OpenAI - `model` parameter in request body causes failures when deployment name differs from model name

Offen
#2,892 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@fengjikui arbeitet bereits daran.

Seit 24.6.2026.

  • #2905 von @giulio-leone — ohne Merge geschlossen
  • #2910 von @giulio-leone — ohne Merge geschlossen
  • #2972 von @alvinttang — ohne Merge geschlossen
  • #3437 von @fengjikui — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
azure, python
Bereich
api, backend

Rechercherichtung

Beginnen Sie in openai/lib/azure.py bei AzureOpenAI._build_request und prüfen Sie, wie _deployments_endpoints und options.json_data behandelt werden. Reproduzieren Sie die images.generate-Anfrage mit verschiedenen Deployment- und Modellnamen und verifizieren Sie anschließend, dass das Deployment-Routing weiterhin funktioniert und der Anfrage-Body den Erwartungen der Azure OpenAI REST API entspricht.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug
Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

When using AzureOpenAI client, the SDK sends the model parameter in the request body even though Azure OpenAI uses URL-based routing (/deployments/{deployment-id}/...). This causes failures when the deployment name doesn't match the model name exactly.

This is particularly problematic for gpt-image-1.5 because:

  1. Azure resource naming rules prohibit periods (dots) in deployment names
  2. The model name contains a dot: gpt-image-1.5
  3. Therefore, deployment name can never match model name (e.g., must use gpt-image-1-5)

The Azure backend validates the body's model field against actual model names, rejecting valid deployment names.

To Reproduce

Steps to Reproduce

from openai import AzureOpenAI

client = AzureOpenAI(
    azure_endpoint="https://<resource>.openai.azure.com/",
    api_key="<key>",
    api_version="2024-10-21"
)

# Deployment name: "gpt-image-1-5" (dashes, due to Azure naming rules)
# Model name: "gpt-image-1.5" (dot)

response = client.images.generate(
    model="gpt-image-1-5",  # deployment name
    prompt="A sunset over mountains",
    size="1024x1024",
    n=1
)

Expected Behavior

Request succeeds because URL routing correctly targets the deployment:

POST /openai/deployments/gpt-image-1-5/images/generations

Actual Behavior

Request fails with:

{
    "error": {
        "message": "Model not supported with Responses API. Supported models are: ['gpt-image-1', 'gpt-image-1-mini', 'gpt-image-1.5']",
        "type": "invalid_request_error"
    }
}

The Azure backend is validating "model": "gpt-image-1-5" in the request body against model names, not deployment names.


Root Cause

In openai/lib/azure.py, the _build_request method uses model from the body to construct the URL but doesn't remove it from the body:

def _build_request(self, options, *, retries_taken=0):
    if options.url in _deployments_endpoints and is_mapping(options.json_data):
        model = options.json_data.get("model")
        if model is not None and "/deployments" not in str(self.base_url.path):
            options.url = f"/deployments/{model}{options.url}"
            # BUG: model is still in options.json_data

    return super()._build_request(options, retries_taken=retries_taken)

The Azure OpenAI REST API spec does not include model in the request body for deployment-based endpoints - model selection is done entirely via the URL path.

Code snippets

OS

Linux (Ubuntu)

Python version

3.12

Library version

2.7.1 (also tested against latest)

Vorherrschende Sprache
Python
Sterne
31.8k
Forks
8k
Ø Merge
22 Std. 23 Min.
Gemergte PRs (30 T.)
148

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus openai/openai-python

Alle Issues in openai/openai-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.