Skip to content

Getting the error 'Validation error at #/stream_options: Extra inputs are not permitted' when adding extra_body and stream options at the same time #2296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
Imaginarybandit opened this issue Apr 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Imaginarybandit
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

I am trying get the token usage of a streamed response. It has an extra_body to get info from a Azure Search Service index. When I use the stream_options={ "include_usage" : True} it works and returns the token usage and when i use the extra body with my Azure Search Service it returns an answer using the data. But when use both of them at the same time i get this error 'Validation error at #/stream_options: Extra inputs are not permitted'.

To Reproduce

To reproduce the error just run the code snippet below.

Code snippets

import os
import openai
import dotenv

dotenv.load_dotenv()

endpoint = ""
api_key = ""
deployment = ""

client = openai.AzureOpenAI(
    azure_endpoint=endpoint,
    api_key=api_key,
    api_version="2024-09-01-preview",
    
)

completion = client.chat.completions.create(
    model=deployment,
    messages=[
        {
            "role": "user",
            "content": "Demuestrame informacion sobre agricultura",
        },
    ],
    extra_body={
        "data_sources":[
            {
                "type": "azure_search",
                "parameters": {
                    "endpoint": "https://Search_Service_Endpoint.search.windows.net",
                    "index_name": "index",
                    "authentication": {
                        "type": "system_assigned_managed_identity",
                        
                    }
                }
            }
        ],  
    },
    stream=True,
    stream_options={ "include_usage" : True}
)

print(completion)

OS

Windows

Python version

Python v311.3

Library version

openai 1.72.0

@Imaginarybandit Imaginarybandit added the bug Something isn't working label Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant