diff --git a/src/openai/types/responses/response_function_web_search.py b/src/openai/types/responses/response_function_web_search.py index de6001e146..de26acccb6 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. One of `url` or `api`.""" - url: str - """The URL of the source.""" + name: Optional[str] = None + """The source name, used for non-URL providers such as internal APIs.""" + + url: Optional[str] = None + """The URL of the source when the source type is `url`.""" 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 15e313b0d3..529ce0bd32 100644 --- a/src/openai/types/responses/response_function_web_search_param.py +++ b/src/openai/types/responses/response_function_web_search_param.py @@ -20,11 +20,14 @@ class ActionSearchSource(TypedDict, total=False): """A source used in the search.""" - type: Required[Literal["url"]] - """The type of source. Always `url`.""" + type: Required[Literal["url", "api"]] + """The type of source. One of `url` or `api`.""" - url: Required[str] - """The URL of the source.""" + name: str + """The source name, used for non-URL providers such as internal APIs.""" + + url: str + """The URL of the source when the source type is `url`.""" class ActionSearch(TypedDict, total=False): diff --git a/tests/test_models.py b/tests/test_models.py index 588869ee35..217fe09cb2 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -10,6 +10,7 @@ from openai._utils import PropertyInfo from openai._compat import PYDANTIC_V1, parse_obj, model_dump, model_json from openai._models import DISCRIMINATOR_CACHE, BaseModel, construct_type +from openai.types.responses.response_function_web_search import ActionSearchSource as ResponseActionSearchSource class BasicModel(BaseModel): @@ -961,3 +962,11 @@ def __getattr__(self, attr: str) -> Item: ... assert model.a.prop == 1 assert isinstance(model.a, Item) assert model.other == "foo" + + +def test_response_function_web_search_source_allows_api_sources() -> None: + source = parse_obj(ResponseActionSearchSource, {"type": "api", "name": "oai-weather"}) + + assert source.type == "api" + assert source.name == "oai-weather" + assert source.url is None