From 939303641b5c4a4e78537889521c1e5498c7c8b6 Mon Sep 17 00:00:00 2001 From: Rishab Motgi Date: Wed, 20 May 2026 13:04:40 -0700 Subject: [PATCH] fix ActionSearchSource to accept type='api' and optional url/name fields The API returns type='api' for built-in OpenAI data sources (oai-weather, oai-sports, oai-finance). The type Literal only had 'url', causing Pydantic validation errors. Also make url optional and add name for api sources. Fixes #2736 --- .../types/responses/response_function_web_search.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/openai/types/responses/response_function_web_search.py b/src/openai/types/responses/response_function_web_search.py index de6001e146..68b7777fb7 100644 --- a/src/openai/types/responses/response_function_web_search.py +++ b/src/openai/types/responses/response_function_web_search.py @@ -19,11 +19,14 @@ class ActionSearchSource(BaseModel): """A source used in the search.""" - type: Literal["url"] - """The type of source. Always `url`.""" + type: Literal["url", "api"] + """The type of source. `url` for a web page, `api` for a built-in OpenAI data source.""" - url: str - """The URL of the source.""" + url: Optional[str] = None + """The URL of the source. Present when type is `url`.""" + + name: Optional[str] = None + """The name of the built-in data source (e.g. `oai-weather`). Present when type is `api`.""" class ActionSearch(BaseModel):