Share via

I cannot perform image generation with model gpt-image-1.5 with github.com/openai/openai-go/v3 latest version

Abhay Tiwari 20 Reputation points
2026-04-01T20:06:07.08+00:00

as i am using this go sdk's feature (https://pkg.go.dev/github.com/openai/openai-go/v3@v3.0.0#ImageService.Generate)
i am facing an issue where i am reciving error in response as
2026/04/02 00:43:44 ERROR: POST "https://eastus2.api.cognitive.microsoft.com/openai/images/generations?api-version=2024-12-01-preview": 404 Not Found {"code":"DeploymentNotFound","message":"The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again."}
but when i override my deployment while constructing post url in vendor side in your function (https://github.com/openai/openai-go/blob/cbf83a69541f646ec84071a0040f3ca524c2238f/azure/azure.go#L191)

"/images/generations" 
to 
"/openai/deployments/<my deployment name here>/images/generations"

this is working fine
so the conclusion from my side is that this final constructing curl is wrong (without custom deployment ) and azure accepts deployment in post curl which openai-go sdk is not doing properly
version used by me

github.com/openai/openai-go/v3 v3.30.0
go 1.25.0 (not related to error mostly)

Azure OpenAI Service
Azure OpenAI Service

An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.


Answer accepted by question author
  1. Karnam Venkata Rajeswari 1,650 Reputation points Microsoft External Staff Moderator
    2026-04-07T19:14:14.8266667+00:00

    Hello Abhay Tiwari,

    Thank you for your patience and the detailed breakdown for validating the behavior against a direct REST call.

    For Azure OpenAI image generation, the officially supported guidance is that requests are routed entirely via the deployment name in the URL path, in the form of

    /openai/deployments/<deployment-name>/images/generations

    The documented guidance below for GPT‑Image‑1 and GPT‑Image‑1.5 explicitly documents this deployment‑scoped REST pattern, and all working examples construct requests where the deployment appears in the URL while the request body contains only image parameters such as prompt, size, n, and `quality.

    With reference to the same guidance below , at the REST level, Azure OpenAI does not require the deployment identifier to be repeated as the model field in the JSON body for image generation, and sending no model field at all is a valid and supported request shape when the deployment is specified in the path. This matches the behavior observed with the known‑good curl request.

    How to Use Image Generation Models from OpenAI - Microsoft Foundry | Microsoft Learn

    With respect to Go SDKs, there is currently no official Microsoft‑published Go example that mirrors this exact REST shape using openai-go/v3 image helpers. The ImageService.Generate surface in openai-go is designed around OpenAI‑style semantics where:

    • The request path is always images/generations
    • The model field serves dual purposes for routing and validation.

    So this is creating a mismatch for image generation, where

    • The routing must be deployment‑based via the URL
    • The model field is validated strictly against canonical image model names (gpt-image-1, gpt-image-1-mini, gpt-image-1.5) rather than deployment identifiers.

    As a result, currently there is no supported configuration in openai-go/v3 that simultaneously forces deployment‑scoped routing for images and omits or neutralizes the model field in the request body to exactly match the Azure REST documented guidance.

    The only fully supported and documented pattern available today for Azure GPT image deployments is

    • using direct REST calls as documented
    • using SDKs whose API surfaces expose deployment routing explicitly and independently of the request body

    Please review them in the same documented reference below -

    How to Use Image Generation Models from OpenAI - Microsoft Foundry | Microsoft Learn

    The deployment itself is healthy and correctly configured.The divergence is at the SDK request‑shape level rather than a service or configuration issue.

    Thank you

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Karnam Venkata Rajeswari 1,650 Reputation points Microsoft External Staff Moderator
    2026-04-02T10:17:36.56+00:00

    Hello Abhay Tiwari,

    Welcome to Microsoft Q&A .Thank you for reaching out.

    The image generation request using the Go SDK fails with a 404 error because the request is not being routed to a specific Azure OpenAI deployment. Azure OpenAI processes inference requests through deployment‑based routing, which means every runtime request must be associated with a deployed model. When a request is sent without referencing a deployment, the service cannot determine where to route it and responds with DeploymentNotFound.

    In this scenario, the Go SDK call is constructed against a generic image generation path. As a result, the request is sent to an endpoint that does not include the deployment context. When the same request is manually adjusted to include the deployment name in the URL, the request succeeds. This behavior confirms that the deployment itself is valid and the issue is related to request routing rather than model availability or permissions.

    Azure OpenAI differs from the public OpenAI API in how models are accessed. Instead of addressing models by their canonical model names, Azure OpenAI requires requests to be routed through deployment names created in the Azure OpenAI resource. This routing pattern applies consistently across inference APIs, including image generation.

    To avoid modifying vendor code, the Go SDK should be initialized using Azure‑specific configuration options so that requests are correctly constructed for Azure OpenAI. The supported approach is to configure the client with the Azure OpenAI resource endpoint, API version, and authentication, allowing the SDK to generate Azure‑compatible requests.

    Please try the configuration steps below:

    1. Ensure the Azure OpenAI resource endpoint follows the documented format: https://<resourcename>.openai.azure.com
    2. Initialize the Go client using Azure configuration helpers:
      • Set the Azure OpenAI endpoint
      • Specify the target API version
      • Provide authentication using an API key or Entra ID
    3. Confirm that the deployed image model (for example, GPT‑Image‑1.5) is referenced through its deployment name, not the canonical model identifier.

    Additionally, the following troubleshooting steps can help:

    1. Verifying that the image model is successfully deployed and in a ready state.
    2. Please confirm that the deployment name used matches the exact name created in the Azure OpenAI resource.
    3. Then ,validate if the client is configured with the Azure OpenAI resource endpoint (not a regional cognitive endpoint).
    4. Ensure that the API version used supports image generation for the deployed model.
    5. Please avoid overriding SDK internals or vendor files; use supported Azure configuration options instead.

    The following references might be helpful , please check them out

    Thank you

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the response was helpful. This will be benefitting other community members who face the same issue.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.