@ai-sdk/openai 3.0.44 → 3.0.46

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.
@@ -37,11 +37,12 @@ export const openaiResponsesReasoningModelIds = [
37
37
  'gpt-5.2-chat-latest',
38
38
  'gpt-5.2-pro',
39
39
  'gpt-5.2-codex',
40
+ 'gpt-5.3-chat-latest',
41
+ 'gpt-5.3-codex',
40
42
  'gpt-5.4',
41
43
  'gpt-5.4-2026-03-05',
42
44
  'gpt-5.4-pro',
43
45
  'gpt-5.4-pro-2026-03-05',
44
- 'gpt-5.3-codex',
45
46
  ] as const;
46
47
 
47
48
  export const openaiResponsesModelIds = [
@@ -98,11 +99,12 @@ export type OpenAIResponsesModelId =
98
99
  | 'gpt-5.2-pro'
99
100
  | 'gpt-5.2-pro-2025-12-11'
100
101
  | 'gpt-5.2-codex'
102
+ | 'gpt-5.3-chat-latest'
103
+ | 'gpt-5.3-codex'
101
104
  | 'gpt-5.4'
102
105
  | 'gpt-5.4-2026-03-05'
103
106
  | 'gpt-5.4-pro'
104
107
  | 'gpt-5.4-pro-2026-03-05'
105
- | 'gpt-5.3-codex'
106
108
  | 'gpt-5-2025-08-07'
107
109
  | 'gpt-5-chat-latest'
108
110
  | 'gpt-5-codex'
@@ -10,6 +10,7 @@ import { imageGenerationArgsSchema } from '../tool/image-generation';
10
10
  import { customArgsSchema } from '../tool/custom';
11
11
  import { mcpArgsSchema } from '../tool/mcp';
12
12
  import { shellArgsSchema } from '../tool/shell';
13
+ import { toolSearchArgsSchema } from '../tool/tool-search';
13
14
  import { webSearchArgsSchema } from '../tool/web-search';
14
15
  import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
15
16
  import { OpenAIResponsesTool } from './openai-responses-api';
@@ -56,15 +57,22 @@ export async function prepareResponsesTools({
56
57
 
57
58
  for (const tool of tools) {
58
59
  switch (tool.type) {
59
- case 'function':
60
+ case 'function': {
61
+ const openaiOptions = tool.providerOptions?.openai as
62
+ | { deferLoading?: boolean }
63
+ | undefined;
64
+ const deferLoading = openaiOptions?.deferLoading;
65
+
60
66
  openaiTools.push({
61
67
  type: 'function',
62
68
  name: tool.name,
63
69
  description: tool.description,
64
70
  parameters: tool.inputSchema,
65
71
  ...(tool.strict != null ? { strict: tool.strict } : {}),
72
+ ...(deferLoading != null ? { defer_loading: deferLoading } : {}),
66
73
  });
67
74
  break;
75
+ }
68
76
  case 'provider': {
69
77
  switch (tool.id) {
70
78
  case 'openai.file_search': {
@@ -248,6 +256,23 @@ export async function prepareResponsesTools({
248
256
  resolvedCustomProviderToolNames.add(args.name);
249
257
  break;
250
258
  }
259
+ case 'openai.tool_search': {
260
+ const args = await validateTypes({
261
+ value: tool.args,
262
+ schema: toolSearchArgsSchema,
263
+ });
264
+ openaiTools.push({
265
+ type: 'tool_search',
266
+ ...(args.execution != null ? { execution: args.execution } : {}),
267
+ ...(args.description != null
268
+ ? { description: args.description }
269
+ : {}),
270
+ ...(args.parameters != null
271
+ ? { parameters: args.parameters }
272
+ : {}),
273
+ });
274
+ break;
275
+ }
251
276
  }
252
277
  break;
253
278
  }
@@ -0,0 +1,98 @@
1
+ import { JSONObject } from '@ai-sdk/provider';
2
+ import {
3
+ createProviderToolFactoryWithOutputSchema,
4
+ FlexibleSchema,
5
+ lazySchema,
6
+ zodSchema,
7
+ } from '@ai-sdk/provider-utils';
8
+ import { z } from 'zod/v4';
9
+
10
+ export const toolSearchArgsSchema = lazySchema(() =>
11
+ zodSchema(
12
+ z.object({
13
+ execution: z.enum(['server', 'client']).optional(),
14
+ description: z.string().optional(),
15
+ parameters: z.record(z.string(), z.unknown()).optional(),
16
+ }),
17
+ ),
18
+ );
19
+
20
+ export const toolSearchInputSchema = lazySchema(() =>
21
+ zodSchema(
22
+ z.object({
23
+ arguments: z.unknown().optional(),
24
+ call_id: z.string().nullish(),
25
+ }),
26
+ ),
27
+ );
28
+
29
+ export const toolSearchOutputSchema: FlexibleSchema<{
30
+ tools: Array<JSONObject>;
31
+ }> = lazySchema(() =>
32
+ zodSchema(
33
+ z.object({
34
+ tools: z.array(z.record(z.string(), z.unknown())),
35
+ }),
36
+ ),
37
+ ) as FlexibleSchema<{ tools: Array<JSONObject> }>;
38
+
39
+ const toolSearchToolFactory = createProviderToolFactoryWithOutputSchema<
40
+ {
41
+ /**
42
+ * The arguments from the tool_search_call.
43
+ * This is preserved for multi-turn conversation reconstruction.
44
+ */
45
+ arguments?: unknown;
46
+
47
+ /**
48
+ * The call ID from the tool_search_call.
49
+ * Present for client-executed tool search; null for hosted.
50
+ */
51
+ call_id?: string | null;
52
+ },
53
+ {
54
+ /**
55
+ * The tools that were loaded by the tool search.
56
+ * These are the deferred tools that the model requested to load.
57
+ * Each tool is represented as a JSON object with properties depending on its type.
58
+ *
59
+ * Common properties include:
60
+ * - `type`: The type of the tool (e.g., 'function', 'web_search', etc.)
61
+ * - `name`: The name of the tool (for function tools)
62
+ * - `description`: A description of the tool
63
+ * - `deferLoading`: Whether this tool was deferred (had defer_loading: true)
64
+ * - `parameters`: The JSON Schema for the function parameters (for function tools)
65
+ * - `strict`: Whether to enable strict schema adherence (for function tools)
66
+ */
67
+ tools: Array<JSONObject>;
68
+ },
69
+ {
70
+ /**
71
+ * Whether the tool search is executed by the server (hosted) or client.
72
+ * - `'server'` (default): OpenAI performs the search across deferred tools.
73
+ * - `'client'`: The model emits a `tool_search_call` and your `execute`
74
+ * function performs the lookup, returning the tools to load.
75
+ */
76
+ execution?: 'server' | 'client';
77
+
78
+ /**
79
+ * A description of the tool search capability.
80
+ * Only used for client-executed tool search.
81
+ */
82
+ description?: string;
83
+
84
+ /**
85
+ * JSON Schema for the search arguments your application expects.
86
+ * Only used for client-executed tool search.
87
+ */
88
+ parameters?: Record<string, unknown>;
89
+ }
90
+ >({
91
+ id: 'openai.tool_search',
92
+ inputSchema: toolSearchInputSchema,
93
+ outputSchema: toolSearchOutputSchema,
94
+ });
95
+
96
+ export const toolSearch = (
97
+ args: Parameters<typeof toolSearchToolFactory>[0] = {},
98
+ ) => toolSearchToolFactory(args);