Search GPT Preview : 'web_search_options' Error

Was running the search GPT API’s on Python.

Code as follows :

completion = client.chat.completions.create(
    model="gpt-4o-search-preview",
    web_search_options={
        "search_context_size": "low",
        "user_location": {
            "type": "approximate",
            "approximate": {
                "country": "GB",
                "city": "London",
                "region": "London",
            }
        },
    },
    messages=[
        {
            "role": "user",
        "content": "Give me trends in AI?",
        },
       ],
)

Keep getting this error :

TypeError: Completions.create() got an unexpected keyword argument ‘web_search_options’

Anybody know why?

When i remove the keyword it works just fine.

1 Like

Maybe an old version of the openai package?

1 Like

yeah this worked for me. they need to update the documentation

1 Like

Welcome, @travelmail26

Do you have a link to the wrong docs, by chance?