Does Azure Open AI GPT 4 Vision model supports stream options in the request ?

Supraja Narra 0 Reputation points
2025-04-10T09:02:33.66+00:00

Hi,

I am working with the Azure OpenAI Service using the Azure Open AI GPT 4 Vision model. When I include the stream options parameter in my API request (along with "stream: true") I receive the following error

"error": {

    "message": "1 validation error for Request\nbody -> stream_options\n  extra fields not permitted (type=value_error.extra)",

    "type": "invalid_request_error",

    "param": null,

    "code": null

}

The same request works correctly if I remove the stream options field.

Please suggest if any solution.

Thanks,Supraja

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,933 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Manas Mohanty 3,125 Reputation points Microsoft External Staff
    2025-04-11T10:49:36.9333333+00:00

    Hi Supraja Narra

    I am able to get streamed response with api_version = '2024-12-01-preview' and another chunking approach

    
    import os
    import json
    import requests
    import time
    from openai import AzureOpenAI
    
    api_base = 'https://resourcename.openai.azure.com/' # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
    api_key="<apikey>"
    deployment_name = 'gpt-4'
    api_version = '2024-12-01-preview' # this might change in the future
    
    client = AzureOpenAI(
        api_key=api_key,  
        api_version=api_version,
        base_url=f"{api_base}openai/deployments/{deployment_name}",
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[
            { "role": "system", "content": "You are a helpful assistant." },
            { "role": "user", "content": [  
                {
                    "type": "text",
                    "text": "Describe this picture:"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://th.bing.com/th/id/OIP.JQEaFD6izhB9jFmJlO1_NgHaFL?rs=1&pid=ImgDetMain"
                    }
                }
            ] }
        ],
        stream=True
       # stream_options={"include_usage": True}
    )
     
    for i in response:
        if len(i.choices)==0:
            continue
        print(i.choices[0].delta.content)
     
    
    
    

    Output

    None The image shows a close -up photograph of vibrant pink flowers , possibly dah lias , None
    
    
    

    Hope it helps

    Thank you.

    0 comments No comments

Your answer

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