From b7586f254208a56f5a4f525d90d5a4910d925c35 Mon Sep 17 00:00:00 2001 From: Yashwant Bezawada Date: Sat, 8 Nov 2025 16:03:41 -0600 Subject: [PATCH] fix: update ActionSearchSource type to support specialized API sources The ActionSearchSource type definition was incomplete and didn't match the actual API response structure when using specialized OpenAI APIs (weather, sports, finance). Changes: - Updated type field to support both "url" and "api" literals - Made url field optional (present only when type='url') - Added optional name field for specialized API identifiers This allows proper type checking when working with responses from specialized domains labeled as 'oai-sports', 'oai-weather', or 'oai-finance' as documented in the tools web search guide. Fixes #2736 --- .../types/responses/response_function_web_search.py | 11 +++++++---- .../responses/response_function_web_search_param.py | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/openai/types/responses/response_function_web_search.py b/src/openai/types/responses/response_function_web_search.py index f3e80e6a8f..b77c7bd28f 100644 --- a/src/openai/types/responses/response_function_web_search.py +++ b/src/openai/types/responses/response_function_web_search.py @@ -10,11 +10,14 @@ class ActionSearchSource(BaseModel): - type: Literal["url"] - """The type of source. Always `url`.""" + type: Literal["url", "api"] + """The type of source. Can be 'url' for web sources or 'api' for specialized OpenAI APIs.""" - url: str - """The URL of the source.""" + url: Optional[str] = None + """The URL of the source (present when type='url').""" + + name: Optional[str] = None + """The name/identifier of the specialized API (e.g., 'oai-weather', 'oai-sports', 'oai-finance').""" class ActionSearch(BaseModel): diff --git a/src/openai/types/responses/response_function_web_search_param.py b/src/openai/types/responses/response_function_web_search_param.py index fc019d3eb7..317bc8bc17 100644 --- a/src/openai/types/responses/response_function_web_search_param.py +++ b/src/openai/types/responses/response_function_web_search_param.py @@ -16,11 +16,14 @@ class ActionSearchSource(TypedDict, total=False): - type: Required[Literal["url"]] - """The type of source. Always `url`.""" + type: Required[Literal["url", "api"]] + """The type of source. Can be 'url' for web sources or 'api' for specialized OpenAI APIs.""" - url: Required[str] - """The URL of the source.""" + url: str + """The URL of the source (present when type='url').""" + + name: str + """The name/identifier of the specialized API (e.g., 'oai-weather', 'oai-sports', 'oai-finance').""" class ActionSearch(TypedDict, total=False):