Bug Report
Import path of package in question
github.com/openai/openai-go/v3/azure
SDK version
v3.30.0 (Latest)
Go version
go version go1.25.0 linux/amd64
What happened?
When using the openai-go SDK with an Azure OpenAI endpoint for image generation, it is impossible to construct a request that Azure accepts. There is a conflict between how the SDK uses the Model field for routing and how Azure validates that same field in the JSON body.
- The 404 Case: If we set
ImageGenerateParams.Model to a canonical name (e.g., gpt-image-1.5), the SDK hits POST /images/generations. Azure returns 404 DeploymentNotFound because it requires the deployment name in the URL path.
- The 400 Case: If we set
ImageGenerateParams.Model to the Azure Deployment Name to trigger the Azure middleware's path rewriting, the URL becomes correct (/openai/deployments/<name>/images/generations), but the JSON body now contains "model": "<deployment-name>". Azure's image service rejects this with a 400 Bad Request, stating it only supports canonical names (like gpt-image-1.5) in the body.
What did you expect or want to happen?
The Azure middleware should support a configuration where the Deployment Name is injected into the URL path, but either:
- The
model field is stripped from the JSON body (as Azure image REST API does not require it).
- The
model field in the body remains a canonical identifier while a separate option provides the deployment name for the URL.
How can we reproduce it?
// 1. Initialize with Azure middleware
client := openai.NewClient(
azure.WithEndpoint("https://<your-resource>.openai.azure.com/", "<your-deployment-name>"),
azure.WithAPIKey("..."),
)
// 2. Attempt generation
// If Model = "gpt-image-1.5" -> 404 (Path is wrong)
// If Model = "<deployment-name>" -> 400 (Body is wrong)
_, err := client.Images.Generate(ctx, openai.ImageGenerateParams{
Prompt: openai.F("a cat"),
Model: openai.F("<deployment-name>"),
})
Technical References (Internal Bottlenecks)
The issue is a result of the high-level service implementation and the Azure middleware's dependency on the model field:
-
Hardcoded Path: The image service hardcodes the relative path, which the Azure middleware must intercept and rewrite:
vendor/github.com/openai/openai-go/v3/image.go:82
path := "images/generations"
-
Model Field Duality: The Model field is used both for JSON serialization and for the Azure middleware's routing logic. There is currently no way to decouple them:
vendor/github.com/openai/openai-go/v3/image.go:1189
Model ImageModel `json:"model,omitzero"`
-
Middleware Logic: The Azure middleware (likely in azure/azure.go) uses the model field to build the deployment path but does not modify the request body to remove the field that causes the 400 error in Azure.
Reference to Official Confirmation
This issue has been vetted and confirmed by Microsoft support staff as a limitation of the current SDK abstraction when interfacing with Azure's REST contract for images.
Anything we should know about your environment.
This occurs on Azure OpenAI GPT-Image-1.5 deployments. Direct REST calls work when the deployment is in the URL and the model field is absent from the body, proving the service works and the SDK's request construction is the bottleneck.
Bug Report
Import path of package in question
github.com/openai/openai-go/v3/azureSDK version
v3.30.0(Latest)Go version
go version go1.25.0 linux/amd64What happened?
When using the
openai-goSDK with an Azure OpenAI endpoint for image generation, it is impossible to construct a request that Azure accepts. There is a conflict between how the SDK uses theModelfield for routing and how Azure validates that same field in the JSON body.ImageGenerateParams.Modelto a canonical name (e.g.,gpt-image-1.5), the SDK hitsPOST /images/generations. Azure returns 404 DeploymentNotFound because it requires the deployment name in the URL path.ImageGenerateParams.Modelto the Azure Deployment Name to trigger the Azure middleware's path rewriting, the URL becomes correct (/openai/deployments/<name>/images/generations), but the JSON body now contains"model": "<deployment-name>". Azure's image service rejects this with a 400 Bad Request, stating it only supports canonical names (likegpt-image-1.5) in the body.What did you expect or want to happen?
The Azure middleware should support a configuration where the Deployment Name is injected into the URL path, but either:
modelfield is stripped from the JSON body (as Azure image REST API does not require it).modelfield in the body remains a canonical identifier while a separate option provides the deployment name for the URL.How can we reproduce it?
Technical References (Internal Bottlenecks)
The issue is a result of the high-level service implementation and the Azure middleware's dependency on the
modelfield:Hardcoded Path: The image service hardcodes the relative path, which the Azure middleware must intercept and rewrite:
Model Field Duality: The
Modelfield is used both for JSON serialization and for the Azure middleware's routing logic. There is currently no way to decouple them:Middleware Logic: The Azure middleware (likely in
azure/azure.go) uses themodelfield to build the deployment path but does not modify the request body to remove the field that causes the 400 error in Azure.Reference to Official Confirmation
This issue has been vetted and confirmed by Microsoft support staff as a limitation of the current SDK abstraction when interfacing with Azure's REST contract for images.
openai-goSDK's request-shaping creates a mismatch:Anything we should know about your environment.
This occurs on Azure OpenAI GPT-Image-1.5 deployments. Direct REST calls work when the deployment is in the URL and the
modelfield is absent from the body, proving the service works and the SDK's request construction is the bottleneck.