@@ -29,16 +29,25 @@ export const ImageGenerationStatus = z
2929
3030/**
3131 * The built-in Web search tool
32+ *
33+ * see https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses
3234 */
3335export type WebSearchTool = {
3436 type : 'web_search' ;
35- name ?: 'web_search_preview' | string ;
37+ name ?: 'web_search' | ' web_search_preview' | string ;
3638 /**
3739 * Optional location for the search. Lets you customize results to be relevant to a location.
3840 */
39- userLocation ?: OpenAI . Responses . WebSearchTool . UserLocation ;
41+ userLocation ?: OpenAI . Responses . Tool . WebSearchTool . UserLocation ;
42+
43+ /**
44+ * Optional filters for the search.
45+ */
46+ filters ?: { allowedDomains ?: Array < string > | null } ;
47+
4048 /**
41- * The amount of context to use for the search.
49+ * High level guidance for the amount of context window space to use for the
50+ * search. One of `low`, `medium`, or `high`. `medium` is the default.
4251 */
4352 searchContextSize : 'low' | 'medium' | 'high' ;
4453} ;
@@ -53,13 +62,16 @@ export function webSearchTool(
5362) : HostedTool {
5463 const providerData : ProviderData . WebSearchTool = {
5564 type : 'web_search' ,
56- name : options . name ?? 'web_search_preview ' ,
65+ name : options . name ?? 'web_search ' ,
5766 user_location : options . userLocation ,
67+ filters : options . filters ?. allowedDomains
68+ ? { allowed_domains : options . filters . allowedDomains }
69+ : undefined ,
5870 search_context_size : options . searchContextSize ?? 'medium' ,
5971 } ;
6072 return {
6173 type : 'hosted_tool' ,
62- name : options . name ?? 'web_search_preview ' ,
74+ name : options . name ?? 'web_search ' ,
6375 providerData,
6476 } ;
6577}
0 commit comments