@ai-sdk/openai 4.0.0-beta.6 → 4.0.0-beta.74

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +644 -24
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +240 -44
  4. package/dist/index.js +3345 -1683
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +390 -36
  7. package/dist/internal/index.js +2707 -1706
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/03-openai.mdx +413 -39
  10. package/package.json +17 -18
  11. package/src/chat/convert-openai-chat-usage.ts +1 -1
  12. package/src/chat/convert-to-openai-chat-messages.ts +96 -68
  13. package/src/chat/map-openai-finish-reason.ts +1 -1
  14. package/src/chat/openai-chat-api.ts +6 -2
  15. package/src/chat/{openai-chat-options.ts → openai-chat-language-model-options.ts} +11 -1
  16. package/src/chat/openai-chat-language-model.ts +82 -148
  17. package/src/chat/openai-chat-prepare-tools.ts +3 -3
  18. package/src/completion/convert-openai-completion-usage.ts +1 -1
  19. package/src/completion/convert-to-openai-completion-prompt.ts +1 -2
  20. package/src/completion/map-openai-finish-reason.ts +1 -1
  21. package/src/completion/openai-completion-api.ts +5 -2
  22. package/src/completion/{openai-completion-options.ts → openai-completion-language-model-options.ts} +5 -1
  23. package/src/completion/openai-completion-language-model.ts +53 -17
  24. package/src/embedding/{openai-embedding-options.ts → openai-embedding-model-options.ts} +5 -1
  25. package/src/embedding/openai-embedding-model.ts +22 -5
  26. package/src/files/openai-files-api.ts +17 -0
  27. package/src/files/openai-files-options.ts +22 -0
  28. package/src/files/openai-files.ts +100 -0
  29. package/src/image/openai-image-model-options.ts +123 -0
  30. package/src/image/openai-image-model.ts +62 -83
  31. package/src/index.ts +15 -6
  32. package/src/internal/index.ts +7 -6
  33. package/src/openai-config.ts +7 -7
  34. package/src/openai-language-model-capabilities.ts +5 -4
  35. package/src/openai-provider.ts +80 -9
  36. package/src/openai-stream-error.ts +181 -0
  37. package/src/openai-tools.ts +12 -1
  38. package/src/realtime/index.ts +2 -0
  39. package/src/realtime/openai-realtime-event-mapper.ts +436 -0
  40. package/src/realtime/openai-realtime-model-options.ts +3 -0
  41. package/src/realtime/openai-realtime-model.ts +111 -0
  42. package/src/responses/convert-openai-responses-usage.ts +1 -1
  43. package/src/responses/convert-to-openai-responses-input.ts +345 -90
  44. package/src/responses/map-openai-responses-finish-reason.ts +1 -1
  45. package/src/responses/openai-responses-api.ts +186 -17
  46. package/src/responses/{openai-responses-options.ts → openai-responses-language-model-options.ts} +55 -1
  47. package/src/responses/openai-responses-language-model.ts +330 -52
  48. package/src/responses/openai-responses-prepare-tools.ts +129 -18
  49. package/src/responses/openai-responses-provider-metadata.ts +12 -2
  50. package/src/skills/openai-skills-api.ts +31 -0
  51. package/src/skills/openai-skills.ts +83 -0
  52. package/src/speech/{openai-speech-options.ts → openai-speech-model-options.ts} +5 -1
  53. package/src/speech/openai-speech-model.ts +23 -7
  54. package/src/tool/apply-patch.ts +33 -32
  55. package/src/tool/code-interpreter.ts +40 -41
  56. package/src/tool/custom.ts +2 -8
  57. package/src/tool/file-search.ts +3 -3
  58. package/src/tool/image-generation.ts +2 -2
  59. package/src/tool/local-shell.ts +2 -2
  60. package/src/tool/mcp.ts +3 -3
  61. package/src/tool/shell.ts +9 -4
  62. package/src/tool/tool-search.ts +98 -0
  63. package/src/tool/web-search-preview.ts +2 -2
  64. package/src/tool/web-search.ts +10 -2
  65. package/src/transcription/{openai-transcription-options.ts → openai-transcription-model-options.ts} +5 -1
  66. package/src/transcription/openai-transcription-model.ts +35 -13
  67. package/dist/index.d.mts +0 -1107
  68. package/dist/index.mjs +0 -6509
  69. package/dist/index.mjs.map +0 -1
  70. package/dist/internal/index.d.mts +0 -1137
  71. package/dist/internal/index.mjs +0 -6322
  72. package/dist/internal/index.mjs.map +0 -1
  73. package/src/image/openai-image-options.ts +0 -31
package/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  The **[OpenAI provider](https://ai-sdk.dev/providers/ai-sdk-providers/openai)** for the [AI SDK](https://ai-sdk.dev/docs)
4
4
  contains language model support for the OpenAI chat and completion APIs and embedding model support for the OpenAI embeddings API.
5
5
 
6
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access OpenAI (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
7
+
6
8
  ## Setup
7
9
 
8
10
  The OpenAI provider is available in the `@ai-sdk/openai` module. You can install it with
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _ai_sdk_provider from '@ai-sdk/provider';
2
- import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4 } from '@ai-sdk/provider';
2
+ import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, Experimental_RealtimeFactoryV4, FilesV4, SkillsV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig } from '@ai-sdk/provider';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | (string & {});
6
+ type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | (string & {});
7
7
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
8
8
  logitBias?: Record<number, number> | undefined;
9
9
  logprobs?: number | boolean | undefined;
@@ -42,9 +42,36 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
42
42
  }>;
43
43
  type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
44
44
 
45
- type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'chatgpt-image-latest' | (string & {});
45
+ type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
46
+ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
47
+ quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
48
+ background?: "auto" | "transparent" | "opaque" | undefined;
49
+ outputFormat?: "png" | "jpeg" | "webp" | undefined;
50
+ outputCompression?: number | undefined;
51
+ user?: string | undefined;
52
+ }>;
53
+ type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
54
+ declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
55
+ quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
56
+ background?: "auto" | "transparent" | "opaque" | undefined;
57
+ outputFormat?: "png" | "jpeg" | "webp" | undefined;
58
+ outputCompression?: number | undefined;
59
+ user?: string | undefined;
60
+ style?: "vivid" | "natural" | undefined;
61
+ moderation?: "auto" | "low" | undefined;
62
+ }>;
63
+ type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
64
+ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
65
+ quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
66
+ background?: "auto" | "transparent" | "opaque" | undefined;
67
+ outputFormat?: "png" | "jpeg" | "webp" | undefined;
68
+ outputCompression?: number | undefined;
69
+ user?: string | undefined;
70
+ inputFidelity?: "low" | "high" | undefined;
71
+ }>;
72
+ type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
46
73
 
47
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
74
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
48
75
  /**
49
76
  * An object describing the specific action taken in this web search call.
50
77
  * Includes details on how the model used the web (search, open_page, find_in_page).
@@ -56,8 +83,14 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
56
83
  type: "search";
57
84
  /**
58
85
  * The search query.
86
+ *
87
+ * @deprecated Use `queries` instead.
59
88
  */
60
89
  query?: string;
90
+ /**
91
+ * The search queries the model used.
92
+ */
93
+ queries?: string[];
61
94
  } | {
62
95
  /**
63
96
  * Action type "openPage" - Opens a specific URL from search results.
@@ -141,7 +174,7 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
141
174
  */
142
175
  timezone?: string;
143
176
  };
144
- }>;
177
+ }, {}>;
145
178
 
146
179
  /**
147
180
  * A filter used to compare a specified attribute key to a given value using a defined comparison operation.
@@ -176,6 +209,21 @@ type OpenAIResponsesFileSearchToolCompoundFilter = {
176
209
  declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
177
210
  type: "unknown_chunk";
178
211
  message: string;
212
+ } | {
213
+ type: "error";
214
+ sequence_number: number;
215
+ error: {
216
+ type: string;
217
+ code: string;
218
+ message: string;
219
+ param?: string | null | undefined;
220
+ };
221
+ } | {
222
+ type: "error";
223
+ sequence_number: number;
224
+ message: string;
225
+ code?: string | null | undefined;
226
+ param?: string | null | undefined;
179
227
  } | {
180
228
  type: "response.output_text.delta";
181
229
  item_id: string;
@@ -206,6 +254,29 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
206
254
  } | null | undefined;
207
255
  service_tier?: string | null | undefined;
208
256
  };
257
+ } | {
258
+ type: "response.failed";
259
+ sequence_number: number;
260
+ response: {
261
+ error?: {
262
+ message: string;
263
+ code?: string | null | undefined;
264
+ } | null | undefined;
265
+ incomplete_details?: {
266
+ reason: string;
267
+ } | null | undefined;
268
+ usage?: {
269
+ input_tokens: number;
270
+ output_tokens: number;
271
+ input_tokens_details?: {
272
+ cached_tokens?: number | null | undefined;
273
+ } | null | undefined;
274
+ output_tokens_details?: {
275
+ reasoning_tokens?: number | null | undefined;
276
+ } | null | undefined;
277
+ } | null | undefined;
278
+ service_tier?: string | null | undefined;
279
+ };
209
280
  } | {
210
281
  type: "response.created";
211
282
  response: {
@@ -231,6 +302,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
231
302
  call_id: string;
232
303
  name: string;
233
304
  arguments: string;
305
+ namespace?: string | null | undefined;
234
306
  } | {
235
307
  type: "web_search_call";
236
308
  id: string;
@@ -300,6 +372,10 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
300
372
  action: {
301
373
  commands: string[];
302
374
  };
375
+ } | {
376
+ type: "compaction";
377
+ id: string;
378
+ encrypted_content?: string | null | undefined;
303
379
  } | {
304
380
  type: "shell_call_output";
305
381
  id: string;
@@ -315,6 +391,20 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
315
391
  exit_code: number;
316
392
  };
317
393
  }[];
394
+ } | {
395
+ type: "tool_search_call";
396
+ id: string;
397
+ execution: "server" | "client";
398
+ call_id: string | null;
399
+ status: "completed" | "in_progress" | "incomplete";
400
+ arguments: unknown;
401
+ } | {
402
+ type: "tool_search_output";
403
+ id: string;
404
+ execution: "server" | "client";
405
+ call_id: string | null;
406
+ status: "completed" | "in_progress" | "incomplete";
407
+ tools: Record<string, JSONValue | undefined>[];
318
408
  };
319
409
  } | {
320
410
  type: "response.output_item.done";
@@ -334,6 +424,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
334
424
  name: string;
335
425
  arguments: string;
336
426
  status: "completed";
427
+ namespace?: string | null | undefined;
337
428
  } | {
338
429
  type: "custom_tool_call";
339
430
  id: string;
@@ -364,6 +455,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
364
455
  action?: {
365
456
  type: "search";
366
457
  query?: string | null | undefined;
458
+ queries?: string[] | null | undefined;
367
459
  sources?: ({
368
460
  type: "url";
369
461
  url: string;
@@ -469,6 +561,10 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
469
561
  action: {
470
562
  commands: string[];
471
563
  };
564
+ } | {
565
+ type: "compaction";
566
+ id: string;
567
+ encrypted_content: string;
472
568
  } | {
473
569
  type: "shell_call_output";
474
570
  id: string;
@@ -484,6 +580,20 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
484
580
  exit_code: number;
485
581
  };
486
582
  }[];
583
+ } | {
584
+ type: "tool_search_call";
585
+ id: string;
586
+ execution: "server" | "client";
587
+ call_id: string | null;
588
+ status: "completed" | "in_progress" | "incomplete";
589
+ arguments: unknown;
590
+ } | {
591
+ type: "tool_search_output";
592
+ id: string;
593
+ execution: "server" | "client";
594
+ call_id: string | null;
595
+ status: "completed" | "in_progress" | "incomplete";
596
+ tools: Record<string, JSONValue | undefined>[];
487
597
  };
488
598
  } | {
489
599
  type: "response.function_call_arguments.delta";
@@ -559,26 +669,13 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
559
669
  item_id: string;
560
670
  output_index: number;
561
671
  diff: string;
562
- } | {
563
- type: "error";
564
- sequence_number: number;
565
- error: {
566
- type: string;
567
- code: string;
568
- message: string;
569
- param?: string | null | undefined;
570
- };
571
672
  }>;
572
673
  type OpenAIResponsesChunk = InferSchema<typeof openaiResponsesChunkSchema>;
573
674
  type OpenAIResponsesLogprobs = NonNullable<(OpenAIResponsesChunk & {
574
675
  type: 'response.output_text.delta';
575
676
  })['logprobs']> | null;
576
677
 
577
- declare const customToolFactory: _ai_sdk_provider_utils.ProviderToolFactory<string, {
578
- /**
579
- * The name of the custom tool, used to identify it in the API.
580
- */
581
- name: string;
678
+ declare const customToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactory<string, {
582
679
  /**
583
680
  * An optional description of what the tool does.
584
681
  */
@@ -594,7 +691,7 @@ declare const customToolFactory: _ai_sdk_provider_utils.ProviderToolFactory<stri
594
691
  } | {
595
692
  type: "text";
596
693
  };
597
- }>;
694
+ }, {}>;
598
695
 
599
696
  /**
600
697
  * Type definitions for the apply_patch operations.
@@ -635,23 +732,22 @@ declare const openaiTools: {
635
732
  * enabling iterative, multi-step code editing workflows.
636
733
  *
637
734
  */
638
- applyPatch: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
735
+ applyPatch: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
639
736
  callId: string;
640
737
  operation: ApplyPatchOperation;
641
738
  }, {
642
739
  status: "completed" | "failed";
643
740
  output?: string;
644
- }, {}>;
741
+ }, {}, {}>;
645
742
  /**
646
743
  * Custom tools let callers constrain model output to a grammar (regex or
647
744
  * Lark syntax). The model returns a `custom_tool_call` output item whose
648
745
  * `input` field is a string matching the specified grammar.
649
746
  *
650
- * @param name - The name of the custom tool.
651
747
  * @param description - An optional description of the tool.
652
748
  * @param format - The output format constraint (grammar type, syntax, and definition).
653
749
  */
654
- customTool: (args: Parameters<typeof customToolFactory>[0]) => _ai_sdk_provider_utils.Tool<string, unknown>;
750
+ customTool: (args: Parameters<typeof customToolFactory>[0]) => _ai_sdk_provider_utils.ProviderDefinedTool<string, unknown, {}>;
655
751
  /**
656
752
  * The Code Interpreter tool allows models to write and run Python code in a
657
753
  * sandboxed environment to solve complex problems in domains like data analysis,
@@ -663,7 +759,7 @@ declare const openaiTools: {
663
759
  container?: string | {
664
760
  fileIds?: string[];
665
761
  };
666
- }) => _ai_sdk_provider_utils.Tool<{
762
+ }) => _ai_sdk_provider_utils.ProviderExecutedTool<{
667
763
  code?: string | null;
668
764
  containerId: string;
669
765
  }, {
@@ -674,7 +770,7 @@ declare const openaiTools: {
674
770
  type: "image";
675
771
  url: string;
676
772
  }> | null;
677
- }>;
773
+ }, {}>;
678
774
  /**
679
775
  * File search is a tool available in the Responses API. It enables models to
680
776
  * retrieve information in a knowledge base of previously uploaded files through
@@ -685,7 +781,7 @@ declare const openaiTools: {
685
781
  * @param ranking - The ranking options to use for the file search.
686
782
  * @param filters - The filters to use for the file search.
687
783
  */
688
- fileSearch: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
784
+ fileSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
689
785
  queries: string[];
690
786
  results: null | {
691
787
  attributes: Record<string, unknown>;
@@ -702,7 +798,7 @@ declare const openaiTools: {
702
798
  scoreThreshold?: number;
703
799
  };
704
800
  filters?: OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter;
705
- }>;
801
+ }, {}>;
706
802
  /**
707
803
  * The image generation tool allows you to generate images using a text prompt,
708
804
  * and optionally image inputs. It leverages the GPT Image model,
@@ -733,16 +829,16 @@ declare const openaiTools: {
733
829
  partialImages?: number;
734
830
  quality?: "auto" | "low" | "medium" | "high";
735
831
  size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024";
736
- }) => _ai_sdk_provider_utils.Tool<{}, {
832
+ }) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
737
833
  result: string;
738
- }>;
834
+ }, {}>;
739
835
  /**
740
836
  * Local shell is a tool that allows agents to run shell commands locally
741
837
  * on a machine you or the user provides.
742
838
  *
743
839
  * Supported models: `gpt-5-codex`
744
840
  */
745
- localShell: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
841
+ localShell: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
746
842
  action: {
747
843
  type: "exec";
748
844
  command: string[];
@@ -753,7 +849,7 @@ declare const openaiTools: {
753
849
  };
754
850
  }, {
755
851
  output: string;
756
- }, {}>;
852
+ }, {}, {}>;
757
853
  /**
758
854
  * The shell tool allows the model to interact with your local computer through
759
855
  * a controlled command-line interface. The model proposes shell commands; your
@@ -765,7 +861,7 @@ declare const openaiTools: {
765
861
  * execution or add strict allow-/deny-lists before forwarding a command to
766
862
  * the system shell.
767
863
  */
768
- shell: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
864
+ shell: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
769
865
  action: {
770
866
  commands: string[];
771
867
  timeoutMs?: number;
@@ -800,7 +896,7 @@ declare const openaiTools: {
800
896
  };
801
897
  skills?: Array<{
802
898
  type: "skillReference";
803
- skillId: string;
899
+ providerReference: _ai_sdk_provider.SharedV4ProviderReference;
804
900
  version?: string;
805
901
  } | {
806
902
  type: "inline";
@@ -817,13 +913,27 @@ declare const openaiTools: {
817
913
  containerId: string;
818
914
  } | {
819
915
  type?: "local";
820
- skills?: Array<{
916
+ skills
917
+ /**
918
+ * Web search allows models to access up-to-date information from the internet
919
+ * and provide answers with sourced citations.
920
+ *
921
+ * @param searchContextSize - The search context size to use for the web search.
922
+ * @param userLocation - The user location to use for the web search.
923
+ */
924
+ ? /**
925
+ * Web search allows models to access up-to-date information from the internet
926
+ * and provide answers with sourced citations.
927
+ *
928
+ * @param searchContextSize - The search context size to use for the web search.
929
+ * @param userLocation - The user location to use for the web search.
930
+ */: Array<{
821
931
  name: string;
822
932
  description: string;
823
933
  path: string;
824
934
  }>;
825
935
  };
826
- }>;
936
+ }, {}>;
827
937
  /**
828
938
  * Web search allows models to access up-to-date information from the internet
829
939
  * and provide answers with sourced citations.
@@ -831,7 +941,7 @@ declare const openaiTools: {
831
941
  * @param searchContextSize - The search context size to use for the web search.
832
942
  * @param userLocation - The user location to use for the web search.
833
943
  */
834
- webSearchPreview: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
944
+ webSearchPreview: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
835
945
  action?: {
836
946
  type: "search";
837
947
  query?: string;
@@ -852,7 +962,7 @@ declare const openaiTools: {
852
962
  region?: string;
853
963
  timezone?: string;
854
964
  };
855
- }>;
965
+ }, {}>;
856
966
  /**
857
967
  * Web search allows models to access up-to-date information from the internet
858
968
  * and provide answers with sourced citations.
@@ -861,10 +971,11 @@ declare const openaiTools: {
861
971
  * @param searchContextSize - The search context size to use for the web search.
862
972
  * @param userLocation - The user location to use for the web search.
863
973
  */
864
- webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
974
+ webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
865
975
  action?: {
866
976
  type: "search";
867
977
  query?: string;
978
+ queries?: string[];
868
979
  } | {
869
980
  type: "openPage";
870
981
  url?: string | null;
@@ -880,7 +991,7 @@ declare const openaiTools: {
880
991
  type: "api";
881
992
  name: string;
882
993
  }>;
883
- }>;
994
+ }, {}>;
884
995
  /**
885
996
  * MCP (Model Context Protocol) allows models to call tools exposed by
886
997
  * remote MCP servers or service connectors.
@@ -910,17 +1021,41 @@ declare const openaiTools: {
910
1021
  };
911
1022
  serverDescription?: string;
912
1023
  serverUrl?: string;
913
- }) => _ai_sdk_provider_utils.Tool<{}, {
1024
+ }) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
914
1025
  type: "call";
915
1026
  serverLabel: string;
916
1027
  name: string;
917
1028
  arguments: string;
918
1029
  output?: string | null;
919
1030
  error?: _ai_sdk_provider.JSONValue;
920
- }>;
1031
+ }, {}>;
1032
+ /**
1033
+ * Tool search allows the model to dynamically search for and load deferred
1034
+ * tools into the model's context as needed. This helps reduce overall token
1035
+ * usage, cost, and latency by only loading tools when the model needs them.
1036
+ *
1037
+ * To use tool search, mark functions or namespaces with `defer_loading: true`
1038
+ * in the tools array. The model will use tool search to load these tools
1039
+ * when it determines they are needed.
1040
+ */
1041
+ toolSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
1042
+ arguments?: unknown;
1043
+ call_id?: string | null;
1044
+ }, {
1045
+ tools: Array<_ai_sdk_provider.JSONObject>;
1046
+ }, {
1047
+ execution?: "server" | "client";
1048
+ description?: string;
1049
+ parameters?: Record<string, unknown>;
1050
+ }, {}>>[0]) => _ai_sdk_provider_utils.ProviderDefinedTool<{
1051
+ arguments?: unknown;
1052
+ call_id?: string | null;
1053
+ }, {
1054
+ tools: Array<_ai_sdk_provider.JSONObject>;
1055
+ }, {}>;
921
1056
  };
922
1057
 
923
- type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-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-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.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | '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' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
1058
+ type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-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-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.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | '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' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
924
1059
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
925
1060
  conversation?: string | null | undefined;
926
1061
  include?: ("file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
@@ -937,12 +1072,21 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
937
1072
  safetyIdentifier?: string | null | undefined;
938
1073
  serviceTier?: "default" | "auto" | "flex" | "priority" | null | undefined;
939
1074
  store?: boolean | null | undefined;
1075
+ passThroughUnsupportedFiles?: boolean | undefined;
940
1076
  strictJsonSchema?: boolean | null | undefined;
941
1077
  textVerbosity?: "low" | "medium" | "high" | null | undefined;
942
1078
  truncation?: "auto" | "disabled" | null | undefined;
943
1079
  user?: string | null | undefined;
944
1080
  systemMessageMode?: "remove" | "system" | "developer" | undefined;
945
1081
  forceReasoning?: boolean | undefined;
1082
+ contextManagement?: {
1083
+ type: "compaction";
1084
+ compactThreshold: number;
1085
+ }[] | null | undefined;
1086
+ allowedTools?: {
1087
+ toolNames: string[];
1088
+ mode?: "auto" | "required" | undefined;
1089
+ } | undefined;
946
1090
  }>;
947
1091
  type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;
948
1092
 
@@ -1013,6 +1157,19 @@ interface OpenAIProvider extends ProviderV4 {
1013
1157
  * Creates a model for speech generation.
1014
1158
  */
1015
1159
  speech(modelId: OpenAISpeechModelId): SpeechModelV4;
1160
+ /**
1161
+ * Creates an experimental realtime model for bidirectional audio/text
1162
+ * communication over WebSocket.
1163
+ */
1164
+ experimental_realtime: Experimental_RealtimeFactoryV4;
1165
+ /**
1166
+ * Returns a FilesV4 interface for uploading files to OpenAI.
1167
+ */
1168
+ files(): FilesV4;
1169
+ /**
1170
+ * Returns a SkillsV4 interface for uploading skills to OpenAI.
1171
+ */
1172
+ skills(): SkillsV4;
1016
1173
  /**
1017
1174
  * OpenAI-specific tools.
1018
1175
  */
@@ -1058,6 +1215,37 @@ declare function createOpenAI(options?: OpenAIProviderSettings): OpenAIProvider;
1058
1215
  */
1059
1216
  declare const openai: OpenAIProvider;
1060
1217
 
1218
+ type OpenAIRealtimeModelConfig = {
1219
+ provider: string;
1220
+ baseURL: string;
1221
+ headers: () => Record<string, string | undefined>;
1222
+ fetch?: FetchFunction;
1223
+ };
1224
+ declare class OpenAIRealtimeModel implements Experimental_RealtimeModelV4 {
1225
+ readonly specificationVersion: "v4";
1226
+ readonly provider: string;
1227
+ readonly modelId: string;
1228
+ private readonly config;
1229
+ constructor(modelId: string, config: OpenAIRealtimeModelConfig);
1230
+ doCreateClientSecret(options: Experimental_RealtimeModelV4ClientSecretOptions): Promise<Experimental_RealtimeModelV4ClientSecretResult>;
1231
+ getWebSocketConfig(options: {
1232
+ token: string;
1233
+ url: string;
1234
+ }): {
1235
+ url: string;
1236
+ protocols?: string[];
1237
+ };
1238
+ parseServerEvent(raw: unknown): Experimental_RealtimeModelV4ServerEvent;
1239
+ serializeClientEvent(event: Experimental_RealtimeModelV4ClientEvent): unknown;
1240
+ buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig): Record<string, unknown>;
1241
+ }
1242
+
1243
+ declare const openaiFilesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
1244
+ purpose?: string | undefined;
1245
+ expiresAfter?: number | undefined;
1246
+ }>;
1247
+ type OpenAIFilesOptions = InferSchema<typeof openaiFilesOptionsSchema>;
1248
+
1061
1249
  type OpenaiResponsesChunk = InferSchema<typeof openaiResponsesChunkSchema>;
1062
1250
  type ResponsesOutputTextAnnotationProviderMetadata = Extract<OpenaiResponsesChunk, {
1063
1251
  type: 'response.output_text.annotation.added';
@@ -1077,6 +1265,14 @@ type OpenaiResponsesReasoningProviderMetadata = {
1077
1265
  type OpenaiResponsesProviderMetadata = {
1078
1266
  openai: ResponsesProviderMetadata;
1079
1267
  };
1268
+ type ResponsesCompactionProviderMetadata = {
1269
+ type: 'compaction';
1270
+ itemId: string;
1271
+ encryptedContent?: string;
1272
+ };
1273
+ type OpenaiResponsesCompactionProviderMetadata = {
1274
+ openai: ResponsesCompactionProviderMetadata;
1275
+ };
1080
1276
  type ResponsesTextProviderMetadata = {
1081
1277
  itemId: string;
1082
1278
  phase?: 'commentary' | 'final_answer' | null;
@@ -1104,4 +1300,4 @@ type OpenaiResponsesSourceDocumentProviderMetadata = {
1104
1300
 
1105
1301
  declare const VERSION: string;
1106
1302
 
1107
- export { type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIEmbeddingModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, VERSION, createOpenAI, openai };
1303
+ export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, VERSION, createOpenAI, openai };