Skip to content

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

@Maximgitman

Description

@Maximgitman

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

The type definition for ActionSearchSource in the OpenAI Python SDK (v2.7.1) doesn't match the actual API response structure when using specialized OpenAI APIs (weather, sports, finance).

Current SDK Type Definition:

# From: src/openai/types/responses/response_function_web_search_param.py
class ActionSearchSource(BaseModel):
    type: Literal["url"]
    """The type of source. Always `url`."""
    
    url: str
    """The URL of the source."""

Actual API Response:

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

Expected Type Definition:

class ActionSearchSource(BaseModel):
    type: Literal["url", "api"]
    """The type of source. Can be 'url' for web sources or 'api' for specialized OpenAI APIs."""
    
    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')."""

Impact:

This causes type checking failures when working with actual API responses, forcing developers to use # type: ignore or create custom type definitions.

Related:

This aligns with the documentation mentioning specialized domains labeled as oai-sports, oai-weather, or oai-finance (https://platform.openai.com/docs/guides/tools-web-search).

To Reproduce

  1. Create a response with web search enabled and include=["web_search_call.action.sources"]
  2. Make a query that triggers a specialized API (e.g., "What's the weather in NYC?")
  3. Examine the ActionSearchSource in the response
  4. Observe that the type is 'api' instead of 'url', and there's a name field that doesn't exist in the type definition

Code snippets

from openai import OpenAI

client = OpenAI()
response = client.responses.create(
    model="gpt-5-2025-08-07",
    tools=[{"type": "web_search"}],
    include=["web_search_call.action.sources"],
    input="What's the weather in NYC today?"
)

# Response contains:
# ActionSearchSource(type='api', url=None, name='oai-weather')
# But types expect: type must be "url" and url must be a string

OS

macOS

Python version

Python 3.12.2

Library version

openai==2.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions