Skip to content

Default web search to type="approximate" #3180

@davidgilbertson

Description

@davidgilbertson

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

Currently, if a user passes tools=[{"type": "web_search"}] to client.responses.create, it's get turned into this (on the OpenAI server side) with the country set to US:

{
    "type": "web_search",
    "search_context_size": "medium",
    "user_location": {
        "city": None,
        "country": "US",  # <- note this line
        "region": None,
        "timezone": None,
        "type": "approximate",
    },
}

And apparently this is by design.

But I would say that this is NOT what the developer wants or expects.

The workaround is to pass tools=[{"type": "web_search", "user_location": {"type": "approximate"}}] (which is what the OpenAI playground does - I guess they agree that defaulting to the US is a bad idea).

I would suggest that if the server-side isn't going to change, then defaulting to this in the SDKs will better align with user/developer expectation.

At the very least, if defaulting to the USA really is the intended behaviour in the backend and for the client SDKs, it would be nice to say so in the docs, so it's not a hidden surprise.

Something like:

Note that if you pass tools=[{"type": "web_search"}] without specifying a location, then the following string will be injected into the system prompt: "The user is in an estimated location of United States."

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions