Skip to content

fix: update ActionSearchSource type to support specialized API sources - #2742

Closed
yashwantbezawada wants to merge 1 commit into
openai:mainfrom
yashwantbezawada:fix/action-search-source-type-2736
Closed

yashwantbezawada wants to merge 1 commit into
openai:mainfrom
yashwantbezawada:fix/action-search-source-type-2736

Conversation

@yashwantbezawada

Copy link
Copy Markdown

Description

Fixes #2736

This PR updates the ActionSearchSource type definition to match the actual API response structure when using specialized OpenAI APIs (weather, sports, finance).

Problem

The current type definition only supports type: Literal["url"] and requires both type and url fields, but the actual API returns responses like:

ActionSearchSource(type='api', url=None, name='oai-weather')

This causes type checking failures and forces developers to use # type: ignore or create custom type definitions.

Solution

Updated both ActionSearchSource definitions (BaseModel and TypedDict versions) to:

  1. Support both source types: Changed type from Literal["url"] to Literal["url", "api"]
  2. Make url optional: Changed from required str to Optional[str] = None (present only when type='url')
  3. Add name field: Added Optional[str] for specialized API identifiers (e.g., 'oai-weather', 'oai-sports', 'oai-finance')

Files Changed

  • src/openai/types/responses/response_function_web_search.py (BaseModel version)
  • src/openai/types/responses/response_function_web_search_param.py (TypedDict version)

Testing

While I don't have access to test against the actual specialized APIs, the type changes are:

  • Backward compatible (url sources still work)
  • Aligned with the documented behavior in the tools web search guide
  • Based on the actual API response structure reported in the issue

Additional Context

This aligns with the documentation mentioning specialized domains labeled as oai-sports, oai-weather, or oai-finance.

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 openai#2736

Copy link
Copy Markdown
Contributor

Thanks for working on support for specialized web-search sources. The shared schema currently describes URL sources only, so a source such as {"type": "api", "name": "oai-weather"} needs an upstream definition that represents its fields without requiring an invented URL.

We’re closing this PR to keep the work together in openai/openai-openapi#573. Please follow that issue for the schema correction and generated SDK update; your proposed types remain useful references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActionSearchSource type definition incomplete - missing type='api' and name field

3 participants