gpt-image-1 using openai SDK?

Amit Gelber 0 Reputation points
2025-05-28T11:35:20.2566667+00:00

Hi,
How are we expected to work with GPT-Image-1 with Azure?

seems there is no support on AzureOpenAI SDK, and there are auth issues with using OpenAI SDK directly.

Please share examples.

Thank you.

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
{count} votes

3 answers

Sort by: Most helpful
  1. SRILAKSHMI C 11,215 Reputation points Microsoft External Staff Moderator
    2025-05-28T12:19:12.8766667+00:00

    Hello @Amit Gelber,

    If you're trying to work with image inputs using GPT-Image-1 (also referred to as gpt-4o or gpt-4-vision-preview) on Azure, it's important to know that Azure OpenAI Service does not currently support vision models. This includes both the Azure OpenAI SDK and the REST API endpoints exposed by Azure. This limitation is the primary reason you're encountering issues when trying to use these models.

    You might have attempted to use the OpenAI SDK (available from OpenAI directly) with your Azure OpenAI resource. Unfortunately, this won’t work due to authentication differences. The OpenAI SDK requires OpenAI-issued API keys, which are not interchangeable with Azure resource keys. If you try to use an Azure key with the OpenAI SDK, you’ll get authentication errors. This is a known limitation and expected behavior.

    If you're facing auth issues using the OpenAI SDK directly, make sure that you've correctly set up your Azure OpenAI resource and that you are using the right keys. Ensure that you’ve configured the signed headers correctly if applicable.
    The Azure OpenAI SDK currently does not support any models with image input capabilities, such as gpt-4o. Even though gpt-4o is in public preview, the image input feature is not yet available on Azure.

    At this time, Microsoft has not announced a specific timeline for when vision-enabled models will be available through the Azure OpenAI Service. You can monitor their progress and announcements via the Azure OpenAI release notes and the Azure Updates portal.

    Practical examples are available on the Azure SDK for [JavaScript GitHub repository], which can help you understand how to implement the functionality you require.

    I Hope this helps. Do let me know if you have any further queries.


    If this answers your query, please do click Accept Answer and Yes for was this answer helpful.

    Thank you!

    0 comments No comments

  2. Sina Salam 26,666 Reputation points Volunteer Moderator
    2025-05-28T16:04:35.5233333+00:00

    Hello SriLakshmi C,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are having issue with your gpt-image-1 using openai SDK.

    You can use GPT-Image-1 - GPT-4o on Azure via Azure AI Studio or REST API. SDKs like openai are not compatible with Azure due to auth differences. Use REST as shown below or try the Chat Playground in Azure AI Studio - https://oai.azure.com. For automation, follow the GitHub sample project - https://github.com/Azure-Samples/openai-chat-vision-quickstart and ensure your model is correctly deployed and accessible. And for API Version Reference - https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

    A. Use Azure AI Studio - Low-Code

    • Go to: https://oai.azure.com/
    • Use "Chat Playground" and choose:
      • Model: GPT-4o or GPT-4 Turbo with Vision
      • Deployment: Ensure it's enabled in your Azure OpenAI resource
      • Upload an image and chat interactively
    1. Use Azure REST API - This is a python example;Use Azure REST API - This is a python example;
         import requests
         import base64
         # Load and encode the image
         with open - "image.jpg", "rb" as image_file:
         base64_image = base64.b64encode - image_file.read - .decode - "utf-8"
         # Replace with your Azure details
         endpoint = "https://<your-resource-name>.openai.azure.com/openai/deployments/<deployment-name>/chat/completions?api-version=2024-02-15-preview"
         api_key = "<your-azure-api-key>"
         headers = {
         "Content-Type": "application/json",
         "api-key": api_key
         }
         data = {
         "messages": 
         {"role": "system", "content": "You are a helpful assistant."},
         {
             "role": "user",
             "content": 
                 {"type": "text", "text": "What’s in this image?"},
                 {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}}
             
         }
         ,
         "max_tokens": 1000
         }
         response = requests.post - endpoint, headers=headers, json=data
         print - response.json 
         
      

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


  3. Amit Gelber 0 Reputation points
    2025-06-10T06:21:54.29+00:00

    We're primarily interested in GPT-image-1's image capabilities for editing purposes, both with and without masking. While I understand that GPT-4o supports some level of image generation, there's clearly a reason why OpenAI and Microsoft introduced a dedicated model like GPT-image-1.

    From what I gather in this thread, GPT-image-1 with with input image support is currently only accessible via OpenAI directly, and not yet available through Azure — is that correct?

    0 comments No comments

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.