@ai-sdk/openai 3.0.0-beta.27 → 3.0.0-beta.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.0-beta.28
4
+
5
+ ### Patch Changes
6
+
7
+ - 401f561: fix(provider/openai): fix web search tool input types
8
+
3
9
  ## 3.0.0-beta.27
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -28,7 +28,44 @@ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large
28
28
 
29
29
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | (string & {});
30
30
 
31
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
31
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
32
+ /**
33
+ * An object describing the specific action taken in this web search call.
34
+ * Includes details on how the model used the web (search, open_page, find).
35
+ */
36
+ action: {
37
+ /**
38
+ * Action type "search" - Performs a web search query.
39
+ */
40
+ type: "search";
41
+ /**
42
+ * The search query.
43
+ */
44
+ query?: string;
45
+ } | {
46
+ /**
47
+ * Action type "openPage" - Opens a specific URL from search results.
48
+ */
49
+ type: "openPage";
50
+ /**
51
+ * The URL opened by the model.
52
+ */
53
+ url: string;
54
+ } | {
55
+ /**
56
+ * Action type "find": Searches for a pattern within a loaded page.
57
+ */
58
+ type: "find";
59
+ /**
60
+ * The URL of the page searched for the pattern.
61
+ */
62
+ url: string;
63
+ /**
64
+ * The pattern or text to search for within the page.
65
+ */
66
+ pattern: string;
67
+ };
68
+ }, {
32
69
  /**
33
70
  * Filters for the search.
34
71
  */
@@ -227,7 +264,19 @@ declare const openaiTools: {
227
264
  *
228
265
  * @deprecated Use `webSearch` instead.
229
266
  */
230
- webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
267
+ webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
268
+ action: {
269
+ type: "search";
270
+ query?: string;
271
+ } | {
272
+ type: "openPage";
273
+ url: string;
274
+ } | {
275
+ type: "find";
276
+ url: string;
277
+ pattern: string;
278
+ };
279
+ }, {
231
280
  searchContextSize?: "low" | "medium" | "high";
232
281
  userLocation?: {
233
282
  type: "approximate";
@@ -247,7 +296,19 @@ declare const openaiTools: {
247
296
  * @param searchContextSize - The search context size to use for the web search.
248
297
  * @param userLocation - The user location to use for the web search.
249
298
  */
250
- webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, unknown>;
299
+ webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
300
+ action: {
301
+ type: "search";
302
+ query?: string;
303
+ } | {
304
+ type: "openPage";
305
+ url: string;
306
+ } | {
307
+ type: "find";
308
+ url: string;
309
+ pattern: string;
310
+ };
311
+ }>;
251
312
  };
252
313
 
253
314
  type OpenAIResponsesModelId = 'chatgpt-4o-latest' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4-0613' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | (string & {});
package/dist/index.d.ts CHANGED
@@ -28,7 +28,44 @@ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large
28
28
 
29
29
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | (string & {});
30
30
 
31
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
31
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
32
+ /**
33
+ * An object describing the specific action taken in this web search call.
34
+ * Includes details on how the model used the web (search, open_page, find).
35
+ */
36
+ action: {
37
+ /**
38
+ * Action type "search" - Performs a web search query.
39
+ */
40
+ type: "search";
41
+ /**
42
+ * The search query.
43
+ */
44
+ query?: string;
45
+ } | {
46
+ /**
47
+ * Action type "openPage" - Opens a specific URL from search results.
48
+ */
49
+ type: "openPage";
50
+ /**
51
+ * The URL opened by the model.
52
+ */
53
+ url: string;
54
+ } | {
55
+ /**
56
+ * Action type "find": Searches for a pattern within a loaded page.
57
+ */
58
+ type: "find";
59
+ /**
60
+ * The URL of the page searched for the pattern.
61
+ */
62
+ url: string;
63
+ /**
64
+ * The pattern or text to search for within the page.
65
+ */
66
+ pattern: string;
67
+ };
68
+ }, {
32
69
  /**
33
70
  * Filters for the search.
34
71
  */
@@ -227,7 +264,19 @@ declare const openaiTools: {
227
264
  *
228
265
  * @deprecated Use `webSearch` instead.
229
266
  */
230
- webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
267
+ webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
268
+ action: {
269
+ type: "search";
270
+ query?: string;
271
+ } | {
272
+ type: "openPage";
273
+ url: string;
274
+ } | {
275
+ type: "find";
276
+ url: string;
277
+ pattern: string;
278
+ };
279
+ }, {
231
280
  searchContextSize?: "low" | "medium" | "high";
232
281
  userLocation?: {
233
282
  type: "approximate";
@@ -247,7 +296,19 @@ declare const openaiTools: {
247
296
  * @param searchContextSize - The search context size to use for the web search.
248
297
  * @param userLocation - The user location to use for the web search.
249
298
  */
250
- webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, unknown>;
299
+ webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
300
+ action: {
301
+ type: "search";
302
+ query?: string;
303
+ } | {
304
+ type: "openPage";
305
+ url: string;
306
+ } | {
307
+ type: "find";
308
+ url: string;
309
+ pattern: string;
310
+ };
311
+ }>;
251
312
  };
252
313
 
253
314
  type OpenAIResponsesModelId = 'chatgpt-4o-latest' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4-0613' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | (string & {});
package/dist/index.js CHANGED
@@ -1920,9 +1920,7 @@ var import_v413 = require("zod/v4");
1920
1920
  var webSearchArgsSchema = (0, import_provider_utils18.lazySchema)(
1921
1921
  () => (0, import_provider_utils18.zodSchema)(
1922
1922
  import_v413.z.object({
1923
- filters: import_v413.z.object({
1924
- allowedDomains: import_v413.z.array(import_v413.z.string()).optional()
1925
- }).optional(),
1923
+ filters: import_v413.z.object({ allowedDomains: import_v413.z.array(import_v413.z.string()).optional() }).optional(),
1926
1924
  searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
1927
1925
  userLocation: import_v413.z.object({
1928
1926
  type: import_v413.z.literal("approximate"),
@@ -1934,16 +1932,17 @@ var webSearchArgsSchema = (0, import_provider_utils18.lazySchema)(
1934
1932
  })
1935
1933
  )
1936
1934
  );
1937
- var webSearchInputSchema = (0, import_provider_utils18.lazySchema)(
1935
+ var webSearchInputSchema = (0, import_provider_utils18.lazySchema)(() => (0, import_provider_utils18.zodSchema)(import_v413.z.object({})));
1936
+ var webSearchOutputSchema = (0, import_provider_utils18.lazySchema)(
1938
1937
  () => (0, import_provider_utils18.zodSchema)(
1939
1938
  import_v413.z.object({
1940
1939
  action: import_v413.z.discriminatedUnion("type", [
1941
1940
  import_v413.z.object({
1942
1941
  type: import_v413.z.literal("search"),
1943
- query: import_v413.z.string().nullish()
1942
+ query: import_v413.z.string().optional()
1944
1943
  }),
1945
1944
  import_v413.z.object({
1946
- type: import_v413.z.literal("open_page"),
1945
+ type: import_v413.z.literal("openPage"),
1947
1946
  url: import_v413.z.string()
1948
1947
  }),
1949
1948
  import_v413.z.object({
@@ -1951,18 +1950,17 @@ var webSearchInputSchema = (0, import_provider_utils18.lazySchema)(
1951
1950
  url: import_v413.z.string(),
1952
1951
  pattern: import_v413.z.string()
1953
1952
  })
1954
- ]).nullish()
1953
+ ])
1955
1954
  })
1956
1955
  )
1957
1956
  );
1958
- var webSearchToolFactory = (0, import_provider_utils18.createProviderDefinedToolFactory)({
1957
+ var webSearchToolFactory = (0, import_provider_utils18.createProviderDefinedToolFactoryWithOutputSchema)({
1959
1958
  id: "openai.web_search",
1960
1959
  name: "web_search",
1961
- inputSchema: webSearchInputSchema
1960
+ inputSchema: webSearchInputSchema,
1961
+ outputSchema: webSearchOutputSchema
1962
1962
  });
1963
- var webSearch = (args = {}) => {
1964
- return webSearchToolFactory(args);
1965
- };
1963
+ var webSearch = (args = {}) => webSearchToolFactory(args);
1966
1964
 
1967
1965
  // src/tool/web-search-preview.ts
1968
1966
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
@@ -1970,51 +1968,30 @@ var import_v414 = require("zod/v4");
1970
1968
  var webSearchPreviewArgsSchema = (0, import_provider_utils19.lazySchema)(
1971
1969
  () => (0, import_provider_utils19.zodSchema)(
1972
1970
  import_v414.z.object({
1973
- /**
1974
- * Search context size to use for the web search.
1975
- * - high: Most comprehensive context, highest cost, slower response
1976
- * - medium: Balanced context, cost, and latency (default)
1977
- * - low: Least context, lowest cost, fastest response
1978
- */
1979
1971
  searchContextSize: import_v414.z.enum(["low", "medium", "high"]).optional(),
1980
- /**
1981
- * User location information to provide geographically relevant search results.
1982
- */
1983
1972
  userLocation: import_v414.z.object({
1984
- /**
1985
- * Type of location (always 'approximate')
1986
- */
1987
1973
  type: import_v414.z.literal("approximate"),
1988
- /**
1989
- * Two-letter ISO country code (e.g., 'US', 'GB')
1990
- */
1991
1974
  country: import_v414.z.string().optional(),
1992
- /**
1993
- * City name (free text, e.g., 'Minneapolis')
1994
- */
1995
1975
  city: import_v414.z.string().optional(),
1996
- /**
1997
- * Region name (free text, e.g., 'Minnesota')
1998
- */
1999
1976
  region: import_v414.z.string().optional(),
2000
- /**
2001
- * IANA timezone (e.g., 'America/Chicago')
2002
- */
2003
1977
  timezone: import_v414.z.string().optional()
2004
1978
  }).optional()
2005
1979
  })
2006
1980
  )
2007
1981
  );
2008
1982
  var webSearchPreviewInputSchema = (0, import_provider_utils19.lazySchema)(
1983
+ () => (0, import_provider_utils19.zodSchema)(import_v414.z.object({}))
1984
+ );
1985
+ var webSearchPreviewOutputSchema = (0, import_provider_utils19.lazySchema)(
2009
1986
  () => (0, import_provider_utils19.zodSchema)(
2010
1987
  import_v414.z.object({
2011
1988
  action: import_v414.z.discriminatedUnion("type", [
2012
1989
  import_v414.z.object({
2013
1990
  type: import_v414.z.literal("search"),
2014
- query: import_v414.z.string().nullish()
1991
+ query: import_v414.z.string().optional()
2015
1992
  }),
2016
1993
  import_v414.z.object({
2017
- type: import_v414.z.literal("open_page"),
1994
+ type: import_v414.z.literal("openPage"),
2018
1995
  url: import_v414.z.string()
2019
1996
  }),
2020
1997
  import_v414.z.object({
@@ -2022,14 +1999,15 @@ var webSearchPreviewInputSchema = (0, import_provider_utils19.lazySchema)(
2022
1999
  url: import_v414.z.string(),
2023
2000
  pattern: import_v414.z.string()
2024
2001
  })
2025
- ]).nullish()
2002
+ ])
2026
2003
  })
2027
2004
  )
2028
2005
  );
2029
- var webSearchPreview = (0, import_provider_utils19.createProviderDefinedToolFactory)({
2006
+ var webSearchPreview = (0, import_provider_utils19.createProviderDefinedToolFactoryWithOutputSchema)({
2030
2007
  id: "openai.web_search_preview",
2031
2008
  name: "web_search_preview",
2032
- inputSchema: webSearchPreviewInputSchema
2009
+ inputSchema: webSearchPreviewInputSchema,
2010
+ outputSchema: webSearchPreviewOutputSchema
2033
2011
  });
2034
2012
 
2035
2013
  // src/openai-tools.ts
@@ -2483,11 +2461,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2483
2461
  import_v416.z.object({
2484
2462
  type: import_v416.z.literal("web_search_call"),
2485
2463
  id: import_v416.z.string(),
2486
- status: import_v416.z.string(),
2487
- action: import_v416.z.object({
2488
- type: import_v416.z.literal("search"),
2489
- query: import_v416.z.string().optional()
2490
- }).nullish()
2464
+ status: import_v416.z.string()
2491
2465
  }),
2492
2466
  import_v416.z.object({
2493
2467
  type: import_v416.z.literal("computer_call"),
@@ -2573,7 +2547,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2573
2547
  url: import_v416.z.string(),
2574
2548
  pattern: import_v416.z.string()
2575
2549
  })
2576
- ]).nullish()
2550
+ ])
2577
2551
  }),
2578
2552
  import_v416.z.object({
2579
2553
  type: import_v416.z.literal("file_search_call"),
@@ -2754,7 +2728,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
2754
2728
  url: import_v416.z.string(),
2755
2729
  pattern: import_v416.z.string()
2756
2730
  })
2757
- ]).nullish()
2731
+ ])
2758
2732
  }),
2759
2733
  import_v416.z.object({
2760
2734
  type: import_v416.z.literal("file_search_call"),
@@ -3453,14 +3427,14 @@ var OpenAIResponsesLanguageModel = class {
3453
3427
  type: "tool-call",
3454
3428
  toolCallId: part.id,
3455
3429
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3456
- input: JSON.stringify({ action: part.action }),
3430
+ input: JSON.stringify({}),
3457
3431
  providerExecuted: true
3458
3432
  });
3459
3433
  content.push({
3460
3434
  type: "tool-result",
3461
3435
  toolCallId: part.id,
3462
3436
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3463
- result: { status: part.status },
3437
+ result: mapWebSearchOutput(part.action),
3464
3438
  providerExecuted: true
3465
3439
  });
3466
3440
  break;
@@ -3644,6 +3618,17 @@ var OpenAIResponsesLanguageModel = class {
3644
3618
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3645
3619
  providerExecuted: true
3646
3620
  });
3621
+ controller.enqueue({
3622
+ type: "tool-input-end",
3623
+ id: value.item.id
3624
+ });
3625
+ controller.enqueue({
3626
+ type: "tool-call",
3627
+ toolCallId: value.item.id,
3628
+ toolName: "web_search",
3629
+ input: JSON.stringify({}),
3630
+ providerExecuted: true
3631
+ });
3647
3632
  } else if (value.item.type === "computer_call") {
3648
3633
  ongoingToolCalls[value.output_index] = {
3649
3634
  toolName: "computer_use",
@@ -3737,22 +3722,11 @@ var OpenAIResponsesLanguageModel = class {
3737
3722
  });
3738
3723
  } else if (value.item.type === "web_search_call") {
3739
3724
  ongoingToolCalls[value.output_index] = void 0;
3740
- controller.enqueue({
3741
- type: "tool-input-end",
3742
- id: value.item.id
3743
- });
3744
- controller.enqueue({
3745
- type: "tool-call",
3746
- toolCallId: value.item.id,
3747
- toolName: "web_search",
3748
- input: JSON.stringify({ action: value.item.action }),
3749
- providerExecuted: true
3750
- });
3751
3725
  controller.enqueue({
3752
3726
  type: "tool-result",
3753
3727
  toolCallId: value.item.id,
3754
3728
  toolName: "web_search",
3755
- result: { status: value.item.status },
3729
+ result: mapWebSearchOutput(value.item.action),
3756
3730
  providerExecuted: true
3757
3731
  });
3758
3732
  } else if (value.item.type === "computer_call") {
@@ -4097,6 +4071,19 @@ function getResponsesModelConfig(modelId) {
4097
4071
  isReasoningModel: false
4098
4072
  };
4099
4073
  }
4074
+ function mapWebSearchOutput(action) {
4075
+ var _a;
4076
+ switch (action.type) {
4077
+ case "search":
4078
+ return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
4079
+ case "open_page":
4080
+ return { action: { type: "openPage", url: action.url } };
4081
+ case "find":
4082
+ return {
4083
+ action: { type: "find", url: action.url, pattern: action.pattern }
4084
+ };
4085
+ }
4086
+ }
4100
4087
 
4101
4088
  // src/speech/openai-speech-model.ts
4102
4089
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
@@ -4451,7 +4438,7 @@ var OpenAITranscriptionModel = class {
4451
4438
  };
4452
4439
 
4453
4440
  // src/version.ts
4454
- var VERSION = true ? "3.0.0-beta.27" : "0.0.0-test";
4441
+ var VERSION = true ? "3.0.0-beta.28" : "0.0.0-test";
4455
4442
 
4456
4443
  // src/openai-provider.ts
4457
4444
  function createOpenAI(options = {}) {