Skip to content

Commit af5f9c4

Browse files
feat(api): add web search filters
1 parent 3f21bcd commit af5f9c4

File tree

10 files changed

+178
-11
lines changed

10 files changed

+178
-11
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 119
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-ddbdf9343316047e8a773c54fb24e4a8d225955e202a1888fde6f9c8898ebf98.yml
3-
openapi_spec_hash: 9802f6dd381558466c897f6e387e06ca
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-8517ffa1004e31ca2523d617629e64be6fe4f13403ddfd9db5b3be002656cbde.yml
3+
openapi_spec_hash: b64dd8c8b23082a7aa2a3e5c5fffd8bd
44
config_hash: fe0ea26680ac2075a6cd66416aefe7db

src/openai/resources/conversations/conversations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def create(
6767
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
6868
) -> Conversation:
6969
"""
70-
Create a conversation with the given ID.
70+
Create a conversation.
7171
7272
Args:
7373
items: Initial items to include in the conversation context. You may add up to 20 items
@@ -244,7 +244,7 @@ async def create(
244244
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
245245
) -> Conversation:
246246
"""
247-
Create a conversation with the given ID.
247+
Create a conversation.
248248
249249
Args:
250250
items: Initial items to include in the conversation context. You may add up to 20 items

src/openai/resources/conversations/items.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ def list(
163163
include: Specify additional output data to include in the model response. Currently
164164
supported values are:
165165
166+
- `web_search_call.action.sources`: Include the sources of the web search tool
167+
call.
166168
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
167169
in code interpreter tool call items.
168170
- `computer_call_output.output.image_url`: Include image urls from the computer
@@ -391,6 +393,8 @@ def list(
391393
include: Specify additional output data to include in the model response. Currently
392394
supported values are:
393395
396+
- `web_search_call.action.sources`: Include the sources of the web search tool
397+
call.
394398
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
395399
in code interpreter tool call items.
396400
- `computer_call_output.output.image_url`: Include image urls from the computer

src/openai/resources/responses/responses.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def create(
136136
include: Specify additional output data to include in the model response. Currently
137137
supported values are:
138138
139+
- `web_search_call.action.sources`: Include the sources of the web search tool
140+
call.
139141
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
140142
in code interpreter tool call items.
141143
- `computer_call_output.output.image_url`: Include image urls from the computer
@@ -377,6 +379,8 @@ def create(
377379
include: Specify additional output data to include in the model response. Currently
378380
supported values are:
379381
382+
- `web_search_call.action.sources`: Include the sources of the web search tool
383+
call.
380384
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
381385
in code interpreter tool call items.
382386
- `computer_call_output.output.image_url`: Include image urls from the computer
@@ -611,6 +615,8 @@ def create(
611615
include: Specify additional output data to include in the model response. Currently
612616
supported values are:
613617
618+
- `web_search_call.action.sources`: Include the sources of the web search tool
619+
call.
614620
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
615621
in code interpreter tool call items.
616622
- `computer_call_output.output.image_url`: Include image urls from the computer
@@ -1524,6 +1530,8 @@ async def create(
15241530
include: Specify additional output data to include in the model response. Currently
15251531
supported values are:
15261532
1533+
- `web_search_call.action.sources`: Include the sources of the web search tool
1534+
call.
15271535
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
15281536
in code interpreter tool call items.
15291537
- `computer_call_output.output.image_url`: Include image urls from the computer
@@ -1765,6 +1773,8 @@ async def create(
17651773
include: Specify additional output data to include in the model response. Currently
17661774
supported values are:
17671775
1776+
- `web_search_call.action.sources`: Include the sources of the web search tool
1777+
call.
17681778
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
17691779
in code interpreter tool call items.
17701780
- `computer_call_output.output.image_url`: Include image urls from the computer
@@ -1999,6 +2009,8 @@ async def create(
19992009
include: Specify additional output data to include in the model response. Currently
20002010
supported values are:
20012011
2012+
- `web_search_call.action.sources`: Include the sources of the web search tool
2013+
call.
20022014
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
20032015
in code interpreter tool call items.
20042016
- `computer_call_output.output.image_url`: Include image urls from the computer

src/openai/types/conversations/item_list_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class ItemListParams(TypedDict, total=False):
1919
2020
Currently supported values are:
2121
22+
- `web_search_call.action.sources`: Include the sources of the web search tool
23+
call.
2224
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
2325
in code interpreter tool call items.
2426
- `computer_call_output.output.image_url`: Include image urls from the computer

src/openai/types/responses/response_create_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class ResponseCreateParamsBase(TypedDict, total=False):
5151
5252
Currently supported values are:
5353
54+
- `web_search_call.action.sources`: Include the sources of the web search tool
55+
call.
5456
- `code_interpreter_call.outputs`: Includes the outputs of python code execution
5557
in code interpreter tool call items.
5658
- `computer_call_output.output.image_url`: Include image urls from the computer

src/openai/types/responses/response_function_web_search.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Union
3+
from typing import List, Union, Optional
44
from typing_extensions import Literal, Annotated, TypeAlias
55

66
from ..._utils import PropertyInfo
77
from ..._models import BaseModel
88

9-
__all__ = ["ResponseFunctionWebSearch", "Action", "ActionSearch", "ActionOpenPage", "ActionFind"]
9+
__all__ = ["ResponseFunctionWebSearch", "Action", "ActionSearch", "ActionSearchSource", "ActionOpenPage", "ActionFind"]
10+
11+
12+
class ActionSearchSource(BaseModel):
13+
type: Literal["url"]
14+
"""The type of source. Always `url`."""
15+
16+
url: str
17+
"""The URL of the source."""
1018

1119

1220
class ActionSearch(BaseModel):
@@ -16,6 +24,9 @@ class ActionSearch(BaseModel):
1624
type: Literal["search"]
1725
"""The action type."""
1826

27+
sources: Optional[List[ActionSearchSource]] = None
28+
"""The sources used in the search."""
29+
1930

2031
class ActionOpenPage(BaseModel):
2132
type: Literal["open_page"]

src/openai/types/responses/response_function_web_search_param.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
from __future__ import annotations
44

5-
from typing import Union
5+
from typing import Union, Iterable
66
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

8-
__all__ = ["ResponseFunctionWebSearchParam", "Action", "ActionSearch", "ActionOpenPage", "ActionFind"]
8+
__all__ = [
9+
"ResponseFunctionWebSearchParam",
10+
"Action",
11+
"ActionSearch",
12+
"ActionSearchSource",
13+
"ActionOpenPage",
14+
"ActionFind",
15+
]
16+
17+
18+
class ActionSearchSource(TypedDict, total=False):
19+
type: Required[Literal["url"]]
20+
"""The type of source. Always `url`."""
21+
22+
url: Required[str]
23+
"""The URL of the source."""
924

1025

1126
class ActionSearch(TypedDict, total=False):
@@ -15,6 +30,9 @@ class ActionSearch(TypedDict, total=False):
1530
type: Required[Literal["search"]]
1631
"""The action type."""
1732

33+
sources: Iterable[ActionSearchSource]
34+
"""The sources used in the search."""
35+
1836

1937
class ActionOpenPage(TypedDict, total=False):
2038
type: Required[Literal["open_page"]]

src/openai/types/responses/tool.py

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
from typing import Dict, List, Union, Optional
44
from typing_extensions import Literal, Annotated, TypeAlias
55

6+
from . import web_search_tool
67
from ..._utils import PropertyInfo
78
from ..._models import BaseModel
89
from .custom_tool import CustomTool
910
from .computer_tool import ComputerTool
1011
from .function_tool import FunctionTool
11-
from .web_search_tool import WebSearchTool
1212
from .file_search_tool import FileSearchTool
1313

1414
__all__ = [
1515
"Tool",
16+
"WebSearchTool",
17+
"WebSearchToolFilters",
18+
"WebSearchToolUserLocation",
1619
"Mcp",
1720
"McpAllowedTools",
1821
"McpAllowedToolsMcpToolFilter",
@@ -29,6 +32,61 @@
2932
]
3033

3134

35+
class WebSearchToolFilters(BaseModel):
36+
allowed_domains: Optional[List[str]] = None
37+
"""Allowed domains for the search.
38+
39+
If not provided, all domains are allowed. Subdomains of the provided domains are
40+
allowed as well.
41+
42+
Example: `["pubmed.ncbi.nlm.nih.gov"]`
43+
"""
44+
45+
46+
class WebSearchToolUserLocation(BaseModel):
47+
city: Optional[str] = None
48+
"""Free text input for the city of the user, e.g. `San Francisco`."""
49+
50+
country: Optional[str] = None
51+
"""
52+
The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
53+
the user, e.g. `US`.
54+
"""
55+
56+
region: Optional[str] = None
57+
"""Free text input for the region of the user, e.g. `California`."""
58+
59+
timezone: Optional[str] = None
60+
"""
61+
The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
62+
user, e.g. `America/Los_Angeles`.
63+
"""
64+
65+
type: Optional[Literal["approximate"]] = None
66+
"""The type of ___location approximation. Always `approximate`."""
67+
68+
69+
class WebSearchTool(BaseModel):
70+
type: Literal["web_search", "web_search_2025_08_26"]
71+
"""The type of the web search tool.
72+
73+
One of `web_search` or `web_search_2025_08_26`.
74+
"""
75+
76+
filters: Optional[WebSearchToolFilters] = None
77+
"""Filters for the search."""
78+
79+
search_context_size: Optional[Literal["low", "medium", "high"]] = None
80+
"""High level guidance for the amount of context window space to use for the
81+
search.
82+
83+
One of `low`, `medium`, or `high`. `medium` is the default.
84+
"""
85+
86+
user_location: Optional[WebSearchToolUserLocation] = None
87+
"""The approximate ___location of the user."""
88+
89+
3290
class McpAllowedToolsMcpToolFilter(BaseModel):
3391
read_only: Optional[bool] = None
3492
"""Indicates whether or not a tool modifies data or is read-only.
@@ -245,13 +303,14 @@ class LocalShell(BaseModel):
245303
Union[
246304
FunctionTool,
247305
FileSearchTool,
248-
WebSearchTool,
249306
ComputerTool,
307+
WebSearchTool,
250308
Mcp,
251309
CodeInterpreter,
252310
ImageGeneration,
253311
LocalShell,
254312
CustomTool,
313+
web_search_tool.WebSearchTool,
255314
],
256315
PropertyInfo(discriminator="type"),
257316
]

src/openai/types/responses/tool_param.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
__all__ = [
1616
"ToolParam",
17+
"WebSearchTool",
18+
"WebSearchToolFilters",
19+
"WebSearchToolUserLocation",
1720
"Mcp",
1821
"McpAllowedTools",
1922
"McpAllowedToolsMcpToolFilter",
@@ -30,6 +33,61 @@
3033
]
3134

3235

36+
class WebSearchToolFilters(TypedDict, total=False):
37+
allowed_domains: Optional[List[str]]
38+
"""Allowed domains for the search.
39+
40+
If not provided, all domains are allowed. Subdomains of the provided domains are
41+
allowed as well.
42+
43+
Example: `["pubmed.ncbi.nlm.nih.gov"]`
44+
"""
45+
46+
47+
class WebSearchToolUserLocation(TypedDict, total=False):
48+
city: Optional[str]
49+
"""Free text input for the city of the user, e.g. `San Francisco`."""
50+
51+
country: Optional[str]
52+
"""
53+
The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
54+
the user, e.g. `US`.
55+
"""
56+
57+
region: Optional[str]
58+
"""Free text input for the region of the user, e.g. `California`."""
59+
60+
timezone: Optional[str]
61+
"""
62+
The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
63+
user, e.g. `America/Los_Angeles`.
64+
"""
65+
66+
type: Literal["approximate"]
67+
"""The type of ___location approximation. Always `approximate`."""
68+
69+
70+
class WebSearchTool(TypedDict, total=False):
71+
type: Required[Literal["web_search", "web_search_2025_08_26"]]
72+
"""The type of the web search tool.
73+
74+
One of `web_search` or `web_search_2025_08_26`.
75+
"""
76+
77+
filters: Optional[WebSearchToolFilters]
78+
"""Filters for the search."""
79+
80+
search_context_size: Literal["low", "medium", "high"]
81+
"""High level guidance for the amount of context window space to use for the
82+
search.
83+
84+
One of `low`, `medium`, or `high`. `medium` is the default.
85+
"""
86+
87+
user_location: Optional[WebSearchToolUserLocation]
88+
"""The approximate ___location of the user."""
89+
90+
3391
class McpAllowedToolsMcpToolFilter(TypedDict, total=False):
3492
read_only: bool
3593
"""Indicates whether or not a tool modifies data or is read-only.
@@ -243,13 +301,14 @@ class LocalShell(TypedDict, total=False):
243301
ToolParam: TypeAlias = Union[
244302
FunctionToolParam,
245303
FileSearchToolParam,
246-
WebSearchToolParam,
247304
ComputerToolParam,
305+
WebSearchTool,
248306
Mcp,
249307
CodeInterpreter,
250308
ImageGeneration,
251309
LocalShell,
252310
CustomToolParam,
311+
WebSearchToolParam,
253312
]
254313

255314

0 commit comments

Comments
 (0)