Share via

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

Abhay Tiwari 0 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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Karnam Venkata Rajeswari 1,310 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.