@zenning/openai 2.0.29 → 2.1.0

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/dist/index.js CHANGED
@@ -18,20 +18,20 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  createOpenAI: () => createOpenAI,
24
24
  openai: () => openai
25
25
  });
26
- module.exports = __toCommonJS(src_exports);
26
+ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/openai-provider.ts
29
29
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
30
30
 
31
31
  // src/chat/openai-chat-language-model.ts
32
- var import_provider3 = require("@ai-sdk/provider");
33
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
34
- var import_v45 = require("zod/v4");
32
+ var import_provider3 = require("@zenning/provider");
33
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
34
+ var import_v43 = require("zod/v4");
35
35
 
36
36
  // src/openai-error.ts
37
37
  var import_v4 = require("zod/v4");
@@ -53,7 +53,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
53
53
  });
54
54
 
55
55
  // src/chat/convert-to-openai-chat-messages.ts
56
- var import_provider = require("@ai-sdk/provider");
56
+ var import_provider = require("@zenning/provider");
57
57
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
58
58
  function convertToOpenAIChatMessages({
59
59
  prompt,
@@ -351,99 +351,7 @@ var openaiProviderOptions = import_v42.z.object({
351
351
  });
352
352
 
353
353
  // src/chat/openai-chat-prepare-tools.ts
354
- var import_provider2 = require("@ai-sdk/provider");
355
-
356
- // src/tool/file-search.ts
357
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
358
- var import_v43 = require("zod/v4");
359
- var comparisonFilterSchema = import_v43.z.object({
360
- key: import_v43.z.string(),
361
- type: import_v43.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
362
- value: import_v43.z.union([import_v43.z.string(), import_v43.z.number(), import_v43.z.boolean()])
363
- });
364
- var compoundFilterSchema = import_v43.z.object({
365
- type: import_v43.z.enum(["and", "or"]),
366
- filters: import_v43.z.array(
367
- import_v43.z.union([comparisonFilterSchema, import_v43.z.lazy(() => compoundFilterSchema)])
368
- )
369
- });
370
- var filtersSchema = import_v43.z.union([comparisonFilterSchema, compoundFilterSchema]);
371
- var fileSearchArgsSchema = import_v43.z.object({
372
- vectorStoreIds: import_v43.z.array(import_v43.z.string()).optional(),
373
- maxNumResults: import_v43.z.number().optional(),
374
- ranking: import_v43.z.object({
375
- ranker: import_v43.z.enum(["auto", "default-2024-08-21"]).optional()
376
- }).optional(),
377
- filters: filtersSchema.optional()
378
- });
379
- var fileSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
380
- id: "openai.file_search",
381
- name: "file_search",
382
- inputSchema: import_v43.z.object({
383
- query: import_v43.z.string().optional()
384
- })
385
- });
386
-
387
- // src/tool/web-search-preview.ts
388
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
389
- var import_v44 = require("zod/v4");
390
- var webSearchPreviewArgsSchema = import_v44.z.object({
391
- /**
392
- * Search context size to use for the web search.
393
- * - high: Most comprehensive context, highest cost, slower response
394
- * - medium: Balanced context, cost, and latency (default)
395
- * - low: Least context, lowest cost, fastest response
396
- */
397
- searchContextSize: import_v44.z.enum(["low", "medium", "high"]).optional(),
398
- /**
399
- * User location information to provide geographically relevant search results.
400
- */
401
- userLocation: import_v44.z.object({
402
- /**
403
- * Type of location (always 'approximate')
404
- */
405
- type: import_v44.z.literal("approximate"),
406
- /**
407
- * Two-letter ISO country code (e.g., 'US', 'GB')
408
- */
409
- country: import_v44.z.string().optional(),
410
- /**
411
- * City name (free text, e.g., 'Minneapolis')
412
- */
413
- city: import_v44.z.string().optional(),
414
- /**
415
- * Region name (free text, e.g., 'Minnesota')
416
- */
417
- region: import_v44.z.string().optional(),
418
- /**
419
- * IANA timezone (e.g., 'America/Chicago')
420
- */
421
- timezone: import_v44.z.string().optional()
422
- }).optional()
423
- });
424
- var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFactory)({
425
- id: "openai.web_search_preview",
426
- name: "web_search_preview",
427
- inputSchema: import_v44.z.object({
428
- action: import_v44.z.discriminatedUnion("type", [
429
- import_v44.z.object({
430
- type: import_v44.z.literal("search"),
431
- query: import_v44.z.string().nullish()
432
- }),
433
- import_v44.z.object({
434
- type: import_v44.z.literal("open_page"),
435
- url: import_v44.z.string()
436
- }),
437
- import_v44.z.object({
438
- type: import_v44.z.literal("find"),
439
- url: import_v44.z.string(),
440
- pattern: import_v44.z.string()
441
- })
442
- ]).nullish()
443
- })
444
- });
445
-
446
- // src/chat/openai-chat-prepare-tools.ts
354
+ var import_provider2 = require("@zenning/provider");
447
355
  function prepareChatTools({
448
356
  tools,
449
357
  toolChoice,
@@ -469,33 +377,6 @@ function prepareChatTools({
469
377
  }
470
378
  });
471
379
  break;
472
- case "provider-defined":
473
- switch (tool.id) {
474
- case "openai.file_search": {
475
- const args = fileSearchArgsSchema.parse(tool.args);
476
- openaiTools2.push({
477
- type: "file_search",
478
- vector_store_ids: args.vectorStoreIds,
479
- max_num_results: args.maxNumResults,
480
- ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
481
- filters: args.filters
482
- });
483
- break;
484
- }
485
- case "openai.web_search_preview": {
486
- const args = webSearchPreviewArgsSchema.parse(tool.args);
487
- openaiTools2.push({
488
- type: "web_search_preview",
489
- search_context_size: args.searchContextSize,
490
- user_location: args.userLocation
491
- });
492
- break;
493
- }
494
- default:
495
- toolWarnings.push({ type: "unsupported-tool", tool });
496
- break;
497
- }
498
- break;
499
380
  default:
500
381
  toolWarnings.push({ type: "unsupported-tool", tool });
501
382
  break;
@@ -560,7 +441,7 @@ var OpenAIChatLanguageModel = class {
560
441
  }) {
561
442
  var _a, _b, _c, _d;
562
443
  const warnings = [];
563
- const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
444
+ const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
564
445
  provider: "openai",
565
446
  providerOptions,
566
447
  schema: openaiProviderOptions
@@ -739,15 +620,15 @@ var OpenAIChatLanguageModel = class {
739
620
  responseHeaders,
740
621
  value: response,
741
622
  rawValue: rawResponse
742
- } = await (0, import_provider_utils5.postJsonToApi)({
623
+ } = await (0, import_provider_utils3.postJsonToApi)({
743
624
  url: this.config.url({
744
625
  path: "/chat/completions",
745
626
  modelId: this.modelId
746
627
  }),
747
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
628
+ headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
748
629
  body,
749
630
  failedResponseHandler: openaiFailedResponseHandler,
750
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
631
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
751
632
  openaiChatResponseSchema
752
633
  ),
753
634
  abortSignal: options.abortSignal,
@@ -762,7 +643,7 @@ var OpenAIChatLanguageModel = class {
762
643
  for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
763
644
  content.push({
764
645
  type: "tool-call",
765
- toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils5.generateId)(),
646
+ toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils3.generateId)(),
766
647
  toolName: toolCall.function.name,
767
648
  input: toolCall.function.arguments
768
649
  });
@@ -771,7 +652,7 @@ var OpenAIChatLanguageModel = class {
771
652
  content.push({
772
653
  type: "source",
773
654
  sourceType: "url",
774
- id: (0, import_provider_utils5.generateId)(),
655
+ id: (0, import_provider_utils3.generateId)(),
775
656
  url: annotation.url,
776
657
  title: annotation.title
777
658
  });
@@ -817,15 +698,15 @@ var OpenAIChatLanguageModel = class {
817
698
  include_usage: true
818
699
  }
819
700
  };
820
- const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
701
+ const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
821
702
  url: this.config.url({
822
703
  path: "/chat/completions",
823
704
  modelId: this.modelId
824
705
  }),
825
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
706
+ headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
826
707
  body,
827
708
  failedResponseHandler: openaiFailedResponseHandler,
828
- successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
709
+ successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
829
710
  openaiChatChunkSchema
830
711
  ),
831
712
  abortSignal: options.abortSignal,
@@ -950,14 +831,14 @@ var OpenAIChatLanguageModel = class {
950
831
  delta: toolCall2.function.arguments
951
832
  });
952
833
  }
953
- if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
834
+ if ((0, import_provider_utils3.isParsableJson)(toolCall2.function.arguments)) {
954
835
  controller.enqueue({
955
836
  type: "tool-input-end",
956
837
  id: toolCall2.id
957
838
  });
958
839
  controller.enqueue({
959
840
  type: "tool-call",
960
- toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils5.generateId)(),
841
+ toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils3.generateId)(),
961
842
  toolName: toolCall2.function.name,
962
843
  input: toolCall2.function.arguments
963
844
  });
@@ -978,14 +859,14 @@ var OpenAIChatLanguageModel = class {
978
859
  id: toolCall.id,
979
860
  delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
980
861
  });
981
- if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && (0, import_provider_utils5.isParsableJson)(toolCall.function.arguments)) {
862
+ if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && (0, import_provider_utils3.isParsableJson)(toolCall.function.arguments)) {
982
863
  controller.enqueue({
983
864
  type: "tool-input-end",
984
865
  id: toolCall.id
985
866
  });
986
867
  controller.enqueue({
987
868
  type: "tool-call",
988
- toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils5.generateId)(),
869
+ toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils3.generateId)(),
989
870
  toolName: toolCall.function.name,
990
871
  input: toolCall.function.arguments
991
872
  });
@@ -998,7 +879,7 @@ var OpenAIChatLanguageModel = class {
998
879
  controller.enqueue({
999
880
  type: "source",
1000
881
  sourceType: "url",
1001
- id: (0, import_provider_utils5.generateId)(),
882
+ id: (0, import_provider_utils3.generateId)(),
1002
883
  url: annotation.url,
1003
884
  title: annotation.title
1004
885
  });
@@ -1023,115 +904,115 @@ var OpenAIChatLanguageModel = class {
1023
904
  };
1024
905
  }
1025
906
  };
1026
- var openaiTokenUsageSchema = import_v45.z.object({
1027
- prompt_tokens: import_v45.z.number().nullish(),
1028
- completion_tokens: import_v45.z.number().nullish(),
1029
- total_tokens: import_v45.z.number().nullish(),
1030
- prompt_tokens_details: import_v45.z.object({
1031
- cached_tokens: import_v45.z.number().nullish()
907
+ var openaiTokenUsageSchema = import_v43.z.object({
908
+ prompt_tokens: import_v43.z.number().nullish(),
909
+ completion_tokens: import_v43.z.number().nullish(),
910
+ total_tokens: import_v43.z.number().nullish(),
911
+ prompt_tokens_details: import_v43.z.object({
912
+ cached_tokens: import_v43.z.number().nullish()
1032
913
  }).nullish(),
1033
- completion_tokens_details: import_v45.z.object({
1034
- reasoning_tokens: import_v45.z.number().nullish(),
1035
- accepted_prediction_tokens: import_v45.z.number().nullish(),
1036
- rejected_prediction_tokens: import_v45.z.number().nullish()
914
+ completion_tokens_details: import_v43.z.object({
915
+ reasoning_tokens: import_v43.z.number().nullish(),
916
+ accepted_prediction_tokens: import_v43.z.number().nullish(),
917
+ rejected_prediction_tokens: import_v43.z.number().nullish()
1037
918
  }).nullish()
1038
919
  }).nullish();
1039
- var openaiChatResponseSchema = import_v45.z.object({
1040
- id: import_v45.z.string().nullish(),
1041
- created: import_v45.z.number().nullish(),
1042
- model: import_v45.z.string().nullish(),
1043
- choices: import_v45.z.array(
1044
- import_v45.z.object({
1045
- message: import_v45.z.object({
1046
- role: import_v45.z.literal("assistant").nullish(),
1047
- content: import_v45.z.string().nullish(),
1048
- tool_calls: import_v45.z.array(
1049
- import_v45.z.object({
1050
- id: import_v45.z.string().nullish(),
1051
- type: import_v45.z.literal("function"),
1052
- function: import_v45.z.object({
1053
- name: import_v45.z.string(),
1054
- arguments: import_v45.z.string()
920
+ var openaiChatResponseSchema = import_v43.z.object({
921
+ id: import_v43.z.string().nullish(),
922
+ created: import_v43.z.number().nullish(),
923
+ model: import_v43.z.string().nullish(),
924
+ choices: import_v43.z.array(
925
+ import_v43.z.object({
926
+ message: import_v43.z.object({
927
+ role: import_v43.z.literal("assistant").nullish(),
928
+ content: import_v43.z.string().nullish(),
929
+ tool_calls: import_v43.z.array(
930
+ import_v43.z.object({
931
+ id: import_v43.z.string().nullish(),
932
+ type: import_v43.z.literal("function"),
933
+ function: import_v43.z.object({
934
+ name: import_v43.z.string(),
935
+ arguments: import_v43.z.string()
1055
936
  })
1056
937
  })
1057
938
  ).nullish(),
1058
- annotations: import_v45.z.array(
1059
- import_v45.z.object({
1060
- type: import_v45.z.literal("url_citation"),
1061
- start_index: import_v45.z.number(),
1062
- end_index: import_v45.z.number(),
1063
- url: import_v45.z.string(),
1064
- title: import_v45.z.string()
939
+ annotations: import_v43.z.array(
940
+ import_v43.z.object({
941
+ type: import_v43.z.literal("url_citation"),
942
+ start_index: import_v43.z.number(),
943
+ end_index: import_v43.z.number(),
944
+ url: import_v43.z.string(),
945
+ title: import_v43.z.string()
1065
946
  })
1066
947
  ).nullish()
1067
948
  }),
1068
- index: import_v45.z.number(),
1069
- logprobs: import_v45.z.object({
1070
- content: import_v45.z.array(
1071
- import_v45.z.object({
1072
- token: import_v45.z.string(),
1073
- logprob: import_v45.z.number(),
1074
- top_logprobs: import_v45.z.array(
1075
- import_v45.z.object({
1076
- token: import_v45.z.string(),
1077
- logprob: import_v45.z.number()
949
+ index: import_v43.z.number(),
950
+ logprobs: import_v43.z.object({
951
+ content: import_v43.z.array(
952
+ import_v43.z.object({
953
+ token: import_v43.z.string(),
954
+ logprob: import_v43.z.number(),
955
+ top_logprobs: import_v43.z.array(
956
+ import_v43.z.object({
957
+ token: import_v43.z.string(),
958
+ logprob: import_v43.z.number()
1078
959
  })
1079
960
  )
1080
961
  })
1081
962
  ).nullish()
1082
963
  }).nullish(),
1083
- finish_reason: import_v45.z.string().nullish()
964
+ finish_reason: import_v43.z.string().nullish()
1084
965
  })
1085
966
  ),
1086
967
  usage: openaiTokenUsageSchema
1087
968
  });
1088
- var openaiChatChunkSchema = import_v45.z.union([
1089
- import_v45.z.object({
1090
- id: import_v45.z.string().nullish(),
1091
- created: import_v45.z.number().nullish(),
1092
- model: import_v45.z.string().nullish(),
1093
- choices: import_v45.z.array(
1094
- import_v45.z.object({
1095
- delta: import_v45.z.object({
1096
- role: import_v45.z.enum(["assistant"]).nullish(),
1097
- content: import_v45.z.string().nullish(),
1098
- tool_calls: import_v45.z.array(
1099
- import_v45.z.object({
1100
- index: import_v45.z.number(),
1101
- id: import_v45.z.string().nullish(),
1102
- type: import_v45.z.literal("function").nullish(),
1103
- function: import_v45.z.object({
1104
- name: import_v45.z.string().nullish(),
1105
- arguments: import_v45.z.string().nullish()
969
+ var openaiChatChunkSchema = import_v43.z.union([
970
+ import_v43.z.object({
971
+ id: import_v43.z.string().nullish(),
972
+ created: import_v43.z.number().nullish(),
973
+ model: import_v43.z.string().nullish(),
974
+ choices: import_v43.z.array(
975
+ import_v43.z.object({
976
+ delta: import_v43.z.object({
977
+ role: import_v43.z.enum(["assistant"]).nullish(),
978
+ content: import_v43.z.string().nullish(),
979
+ tool_calls: import_v43.z.array(
980
+ import_v43.z.object({
981
+ index: import_v43.z.number(),
982
+ id: import_v43.z.string().nullish(),
983
+ type: import_v43.z.literal("function").nullish(),
984
+ function: import_v43.z.object({
985
+ name: import_v43.z.string().nullish(),
986
+ arguments: import_v43.z.string().nullish()
1106
987
  })
1107
988
  })
1108
989
  ).nullish(),
1109
- annotations: import_v45.z.array(
1110
- import_v45.z.object({
1111
- type: import_v45.z.literal("url_citation"),
1112
- start_index: import_v45.z.number(),
1113
- end_index: import_v45.z.number(),
1114
- url: import_v45.z.string(),
1115
- title: import_v45.z.string()
990
+ annotations: import_v43.z.array(
991
+ import_v43.z.object({
992
+ type: import_v43.z.literal("url_citation"),
993
+ start_index: import_v43.z.number(),
994
+ end_index: import_v43.z.number(),
995
+ url: import_v43.z.string(),
996
+ title: import_v43.z.string()
1116
997
  })
1117
998
  ).nullish()
1118
999
  }).nullish(),
1119
- logprobs: import_v45.z.object({
1120
- content: import_v45.z.array(
1121
- import_v45.z.object({
1122
- token: import_v45.z.string(),
1123
- logprob: import_v45.z.number(),
1124
- top_logprobs: import_v45.z.array(
1125
- import_v45.z.object({
1126
- token: import_v45.z.string(),
1127
- logprob: import_v45.z.number()
1000
+ logprobs: import_v43.z.object({
1001
+ content: import_v43.z.array(
1002
+ import_v43.z.object({
1003
+ token: import_v43.z.string(),
1004
+ logprob: import_v43.z.number(),
1005
+ top_logprobs: import_v43.z.array(
1006
+ import_v43.z.object({
1007
+ token: import_v43.z.string(),
1008
+ logprob: import_v43.z.number()
1128
1009
  })
1129
1010
  )
1130
1011
  })
1131
1012
  ).nullish()
1132
1013
  }).nullish(),
1133
- finish_reason: import_v45.z.string().nullish(),
1134
- index: import_v45.z.number()
1014
+ finish_reason: import_v43.z.string().nullish(),
1015
+ index: import_v43.z.number()
1135
1016
  })
1136
1017
  ),
1137
1018
  usage: openaiTokenUsageSchema
@@ -1188,11 +1069,11 @@ var reasoningModels = {
1188
1069
  };
1189
1070
 
1190
1071
  // src/completion/openai-completion-language-model.ts
1191
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1192
- var import_v47 = require("zod/v4");
1072
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
1073
+ var import_v45 = require("zod/v4");
1193
1074
 
1194
1075
  // src/completion/convert-to-openai-completion-prompt.ts
1195
- var import_provider4 = require("@ai-sdk/provider");
1076
+ var import_provider4 = require("@zenning/provider");
1196
1077
  function convertToOpenAICompletionPrompt({
1197
1078
  prompt,
1198
1079
  user = "user",
@@ -1297,12 +1178,12 @@ function mapOpenAIFinishReason2(finishReason) {
1297
1178
  }
1298
1179
 
1299
1180
  // src/completion/openai-completion-options.ts
1300
- var import_v46 = require("zod/v4");
1301
- var openaiCompletionProviderOptions = import_v46.z.object({
1181
+ var import_v44 = require("zod/v4");
1182
+ var openaiCompletionProviderOptions = import_v44.z.object({
1302
1183
  /**
1303
1184
  Echo back the prompt in addition to the completion.
1304
1185
  */
1305
- echo: import_v46.z.boolean().optional(),
1186
+ echo: import_v44.z.boolean().optional(),
1306
1187
  /**
1307
1188
  Modify the likelihood of specified tokens appearing in the completion.
1308
1189
 
@@ -1317,16 +1198,16 @@ var openaiCompletionProviderOptions = import_v46.z.object({
1317
1198
  As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
1318
1199
  token from being generated.
1319
1200
  */
1320
- logitBias: import_v46.z.record(import_v46.z.string(), import_v46.z.number()).optional(),
1201
+ logitBias: import_v44.z.record(import_v44.z.string(), import_v44.z.number()).optional(),
1321
1202
  /**
1322
1203
  The suffix that comes after a completion of inserted text.
1323
1204
  */
1324
- suffix: import_v46.z.string().optional(),
1205
+ suffix: import_v44.z.string().optional(),
1325
1206
  /**
1326
1207
  A unique identifier representing your end-user, which can help OpenAI to
1327
1208
  monitor and detect abuse. Learn more.
1328
1209
  */
1329
- user: import_v46.z.string().optional(),
1210
+ user: import_v44.z.string().optional(),
1330
1211
  /**
1331
1212
  Return the log probabilities of the tokens. Including logprobs will increase
1332
1213
  the response size and can slow down response times. However, it can
@@ -1336,7 +1217,7 @@ var openaiCompletionProviderOptions = import_v46.z.object({
1336
1217
  Setting to a number will return the log probabilities of the top n
1337
1218
  tokens that were generated.
1338
1219
  */
1339
- logprobs: import_v46.z.union([import_v46.z.boolean(), import_v46.z.number()]).optional()
1220
+ logprobs: import_v44.z.union([import_v44.z.boolean(), import_v44.z.number()]).optional()
1340
1221
  });
1341
1222
 
1342
1223
  // src/completion/openai-completion-language-model.ts
@@ -1372,12 +1253,12 @@ var OpenAICompletionLanguageModel = class {
1372
1253
  }) {
1373
1254
  const warnings = [];
1374
1255
  const openaiOptions = {
1375
- ...await (0, import_provider_utils6.parseProviderOptions)({
1256
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1376
1257
  provider: "openai",
1377
1258
  providerOptions,
1378
1259
  schema: openaiCompletionProviderOptions
1379
1260
  }),
1380
- ...await (0, import_provider_utils6.parseProviderOptions)({
1261
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1381
1262
  provider: this.providerOptionsName,
1382
1263
  providerOptions,
1383
1264
  schema: openaiCompletionProviderOptions
@@ -1433,15 +1314,15 @@ var OpenAICompletionLanguageModel = class {
1433
1314
  responseHeaders,
1434
1315
  value: response,
1435
1316
  rawValue: rawResponse
1436
- } = await (0, import_provider_utils6.postJsonToApi)({
1317
+ } = await (0, import_provider_utils4.postJsonToApi)({
1437
1318
  url: this.config.url({
1438
1319
  path: "/completions",
1439
1320
  modelId: this.modelId
1440
1321
  }),
1441
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
1322
+ headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
1442
1323
  body: args,
1443
1324
  failedResponseHandler: openaiFailedResponseHandler,
1444
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1325
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1445
1326
  openaiCompletionResponseSchema
1446
1327
  ),
1447
1328
  abortSignal: options.abortSignal,
@@ -1479,15 +1360,15 @@ var OpenAICompletionLanguageModel = class {
1479
1360
  include_usage: true
1480
1361
  }
1481
1362
  };
1482
- const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
1363
+ const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1483
1364
  url: this.config.url({
1484
1365
  path: "/completions",
1485
1366
  modelId: this.modelId
1486
1367
  }),
1487
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
1368
+ headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
1488
1369
  body,
1489
1370
  failedResponseHandler: openaiFailedResponseHandler,
1490
- successfulResponseHandler: (0, import_provider_utils6.createEventSourceResponseHandler)(
1371
+ successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
1491
1372
  openaiCompletionChunkSchema
1492
1373
  ),
1493
1374
  abortSignal: options.abortSignal,
@@ -1568,42 +1449,42 @@ var OpenAICompletionLanguageModel = class {
1568
1449
  };
1569
1450
  }
1570
1451
  };
1571
- var usageSchema = import_v47.z.object({
1572
- prompt_tokens: import_v47.z.number(),
1573
- completion_tokens: import_v47.z.number(),
1574
- total_tokens: import_v47.z.number()
1452
+ var usageSchema = import_v45.z.object({
1453
+ prompt_tokens: import_v45.z.number(),
1454
+ completion_tokens: import_v45.z.number(),
1455
+ total_tokens: import_v45.z.number()
1575
1456
  });
1576
- var openaiCompletionResponseSchema = import_v47.z.object({
1577
- id: import_v47.z.string().nullish(),
1578
- created: import_v47.z.number().nullish(),
1579
- model: import_v47.z.string().nullish(),
1580
- choices: import_v47.z.array(
1581
- import_v47.z.object({
1582
- text: import_v47.z.string(),
1583
- finish_reason: import_v47.z.string(),
1584
- logprobs: import_v47.z.object({
1585
- tokens: import_v47.z.array(import_v47.z.string()),
1586
- token_logprobs: import_v47.z.array(import_v47.z.number()),
1587
- top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullish()
1457
+ var openaiCompletionResponseSchema = import_v45.z.object({
1458
+ id: import_v45.z.string().nullish(),
1459
+ created: import_v45.z.number().nullish(),
1460
+ model: import_v45.z.string().nullish(),
1461
+ choices: import_v45.z.array(
1462
+ import_v45.z.object({
1463
+ text: import_v45.z.string(),
1464
+ finish_reason: import_v45.z.string(),
1465
+ logprobs: import_v45.z.object({
1466
+ tokens: import_v45.z.array(import_v45.z.string()),
1467
+ token_logprobs: import_v45.z.array(import_v45.z.number()),
1468
+ top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
1588
1469
  }).nullish()
1589
1470
  })
1590
1471
  ),
1591
1472
  usage: usageSchema.nullish()
1592
1473
  });
1593
- var openaiCompletionChunkSchema = import_v47.z.union([
1594
- import_v47.z.object({
1595
- id: import_v47.z.string().nullish(),
1596
- created: import_v47.z.number().nullish(),
1597
- model: import_v47.z.string().nullish(),
1598
- choices: import_v47.z.array(
1599
- import_v47.z.object({
1600
- text: import_v47.z.string(),
1601
- finish_reason: import_v47.z.string().nullish(),
1602
- index: import_v47.z.number(),
1603
- logprobs: import_v47.z.object({
1604
- tokens: import_v47.z.array(import_v47.z.string()),
1605
- token_logprobs: import_v47.z.array(import_v47.z.number()),
1606
- top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullish()
1474
+ var openaiCompletionChunkSchema = import_v45.z.union([
1475
+ import_v45.z.object({
1476
+ id: import_v45.z.string().nullish(),
1477
+ created: import_v45.z.number().nullish(),
1478
+ model: import_v45.z.string().nullish(),
1479
+ choices: import_v45.z.array(
1480
+ import_v45.z.object({
1481
+ text: import_v45.z.string(),
1482
+ finish_reason: import_v45.z.string().nullish(),
1483
+ index: import_v45.z.number(),
1484
+ logprobs: import_v45.z.object({
1485
+ tokens: import_v45.z.array(import_v45.z.string()),
1486
+ token_logprobs: import_v45.z.array(import_v45.z.number()),
1487
+ top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
1607
1488
  }).nullish()
1608
1489
  })
1609
1490
  ),
@@ -1613,23 +1494,23 @@ var openaiCompletionChunkSchema = import_v47.z.union([
1613
1494
  ]);
1614
1495
 
1615
1496
  // src/embedding/openai-embedding-model.ts
1616
- var import_provider5 = require("@ai-sdk/provider");
1617
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1618
- var import_v49 = require("zod/v4");
1497
+ var import_provider5 = require("@zenning/provider");
1498
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
1499
+ var import_v47 = require("zod/v4");
1619
1500
 
1620
1501
  // src/embedding/openai-embedding-options.ts
1621
- var import_v48 = require("zod/v4");
1622
- var openaiEmbeddingProviderOptions = import_v48.z.object({
1502
+ var import_v46 = require("zod/v4");
1503
+ var openaiEmbeddingProviderOptions = import_v46.z.object({
1623
1504
  /**
1624
1505
  The number of dimensions the resulting output embeddings should have.
1625
1506
  Only supported in text-embedding-3 and later models.
1626
1507
  */
1627
- dimensions: import_v48.z.number().optional(),
1508
+ dimensions: import_v46.z.number().optional(),
1628
1509
  /**
1629
1510
  A unique identifier representing your end-user, which can help OpenAI to
1630
1511
  monitor and detect abuse. Learn more.
1631
1512
  */
1632
- user: import_v48.z.string().optional()
1513
+ user: import_v46.z.string().optional()
1633
1514
  });
1634
1515
 
1635
1516
  // src/embedding/openai-embedding-model.ts
@@ -1659,7 +1540,7 @@ var OpenAIEmbeddingModel = class {
1659
1540
  values
1660
1541
  });
1661
1542
  }
1662
- const openaiOptions = (_a = await (0, import_provider_utils7.parseProviderOptions)({
1543
+ const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
1663
1544
  provider: "openai",
1664
1545
  providerOptions,
1665
1546
  schema: openaiEmbeddingProviderOptions
@@ -1668,12 +1549,12 @@ var OpenAIEmbeddingModel = class {
1668
1549
  responseHeaders,
1669
1550
  value: response,
1670
1551
  rawValue
1671
- } = await (0, import_provider_utils7.postJsonToApi)({
1552
+ } = await (0, import_provider_utils5.postJsonToApi)({
1672
1553
  url: this.config.url({
1673
1554
  path: "/embeddings",
1674
1555
  modelId: this.modelId
1675
1556
  }),
1676
- headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), headers),
1557
+ headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), headers),
1677
1558
  body: {
1678
1559
  model: this.modelId,
1679
1560
  input: values,
@@ -1682,7 +1563,7 @@ var OpenAIEmbeddingModel = class {
1682
1563
  user: openaiOptions.user
1683
1564
  },
1684
1565
  failedResponseHandler: openaiFailedResponseHandler,
1685
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1566
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1686
1567
  openaiTextEmbeddingResponseSchema
1687
1568
  ),
1688
1569
  abortSignal,
@@ -1695,14 +1576,14 @@ var OpenAIEmbeddingModel = class {
1695
1576
  };
1696
1577
  }
1697
1578
  };
1698
- var openaiTextEmbeddingResponseSchema = import_v49.z.object({
1699
- data: import_v49.z.array(import_v49.z.object({ embedding: import_v49.z.array(import_v49.z.number()) })),
1700
- usage: import_v49.z.object({ prompt_tokens: import_v49.z.number() }).nullish()
1579
+ var openaiTextEmbeddingResponseSchema = import_v47.z.object({
1580
+ data: import_v47.z.array(import_v47.z.object({ embedding: import_v47.z.array(import_v47.z.number()) })),
1581
+ usage: import_v47.z.object({ prompt_tokens: import_v47.z.number() }).nullish()
1701
1582
  });
1702
1583
 
1703
1584
  // src/image/openai-image-model.ts
1704
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1705
- var import_v410 = require("zod/v4");
1585
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1586
+ var import_v48 = require("zod/v4");
1706
1587
 
1707
1588
  // src/image/openai-image-options.ts
1708
1589
  var modelMaxImagesPerCall = {
@@ -1749,12 +1630,12 @@ var OpenAIImageModel = class {
1749
1630
  warnings.push({ type: "unsupported-setting", setting: "seed" });
1750
1631
  }
1751
1632
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1752
- const { value: response, responseHeaders } = await (0, import_provider_utils8.postJsonToApi)({
1633
+ const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
1753
1634
  url: this.config.url({
1754
1635
  path: "/images/generations",
1755
1636
  modelId: this.modelId
1756
1637
  }),
1757
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), headers),
1638
+ headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), headers),
1758
1639
  body: {
1759
1640
  model: this.modelId,
1760
1641
  prompt,
@@ -1764,7 +1645,7 @@ var OpenAIImageModel = class {
1764
1645
  ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1765
1646
  },
1766
1647
  failedResponseHandler: openaiFailedResponseHandler,
1767
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1648
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1768
1649
  openaiImageResponseSchema
1769
1650
  ),
1770
1651
  abortSignal,
@@ -1790,36 +1671,36 @@ var OpenAIImageModel = class {
1790
1671
  };
1791
1672
  }
1792
1673
  };
1793
- var openaiImageResponseSchema = import_v410.z.object({
1794
- data: import_v410.z.array(
1795
- import_v410.z.object({ b64_json: import_v410.z.string(), revised_prompt: import_v410.z.string().optional() })
1674
+ var openaiImageResponseSchema = import_v48.z.object({
1675
+ data: import_v48.z.array(
1676
+ import_v48.z.object({ b64_json: import_v48.z.string(), revised_prompt: import_v48.z.string().optional() })
1796
1677
  )
1797
1678
  });
1798
1679
 
1799
1680
  // src/tool/code-interpreter.ts
1800
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1801
- var import_v411 = require("zod/v4");
1802
- var codeInterpreterInputSchema = import_v411.z.object({
1803
- code: import_v411.z.string().nullish(),
1804
- containerId: import_v411.z.string()
1681
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1682
+ var import_v49 = require("zod/v4");
1683
+ var codeInterpreterInputSchema = import_v49.z.object({
1684
+ code: import_v49.z.string().nullish(),
1685
+ containerId: import_v49.z.string()
1805
1686
  });
1806
- var codeInterpreterOutputSchema = import_v411.z.object({
1807
- outputs: import_v411.z.array(
1808
- import_v411.z.discriminatedUnion("type", [
1809
- import_v411.z.object({ type: import_v411.z.literal("logs"), logs: import_v411.z.string() }),
1810
- import_v411.z.object({ type: import_v411.z.literal("image"), url: import_v411.z.string() })
1687
+ var codeInterpreterOutputSchema = import_v49.z.object({
1688
+ outputs: import_v49.z.array(
1689
+ import_v49.z.discriminatedUnion("type", [
1690
+ import_v49.z.object({ type: import_v49.z.literal("logs"), logs: import_v49.z.string() }),
1691
+ import_v49.z.object({ type: import_v49.z.literal("image"), url: import_v49.z.string() })
1811
1692
  ])
1812
1693
  ).nullish()
1813
1694
  });
1814
- var codeInterpreterArgsSchema = import_v411.z.object({
1815
- container: import_v411.z.union([
1816
- import_v411.z.string(),
1817
- import_v411.z.object({
1818
- fileIds: import_v411.z.array(import_v411.z.string()).optional()
1695
+ var codeInterpreterArgsSchema = import_v49.z.object({
1696
+ container: import_v49.z.union([
1697
+ import_v49.z.string(),
1698
+ import_v49.z.object({
1699
+ fileIds: import_v49.z.array(import_v49.z.string()).optional()
1819
1700
  })
1820
1701
  ]).optional()
1821
1702
  });
1822
- var codeInterpreterToolFactory = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1703
+ var codeInterpreterToolFactory = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1823
1704
  id: "openai.code_interpreter",
1824
1705
  name: "code_interpreter",
1825
1706
  inputSchema: codeInterpreterInputSchema,
@@ -1829,6 +1710,78 @@ var codeInterpreter = (args = {}) => {
1829
1710
  return codeInterpreterToolFactory(args);
1830
1711
  };
1831
1712
 
1713
+ // src/tool/file-search.ts
1714
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1715
+ var import_v410 = require("zod/v4");
1716
+ var comparisonFilterSchema = import_v410.z.object({
1717
+ key: import_v410.z.string(),
1718
+ type: import_v410.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
1719
+ value: import_v410.z.union([import_v410.z.string(), import_v410.z.number(), import_v410.z.boolean()])
1720
+ });
1721
+ var compoundFilterSchema = import_v410.z.object({
1722
+ type: import_v410.z.enum(["and", "or"]),
1723
+ filters: import_v410.z.array(
1724
+ import_v410.z.union([comparisonFilterSchema, import_v410.z.lazy(() => compoundFilterSchema)])
1725
+ )
1726
+ });
1727
+ var fileSearchArgsSchema = import_v410.z.object({
1728
+ vectorStoreIds: import_v410.z.array(import_v410.z.string()),
1729
+ maxNumResults: import_v410.z.number().optional(),
1730
+ ranking: import_v410.z.object({
1731
+ ranker: import_v410.z.string().optional(),
1732
+ scoreThreshold: import_v410.z.number().optional()
1733
+ }).optional(),
1734
+ filters: import_v410.z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
1735
+ });
1736
+ var fileSearchOutputSchema = import_v410.z.object({
1737
+ queries: import_v410.z.array(import_v410.z.string()),
1738
+ results: import_v410.z.array(
1739
+ import_v410.z.object({
1740
+ attributes: import_v410.z.record(import_v410.z.string(), import_v410.z.unknown()),
1741
+ fileId: import_v410.z.string(),
1742
+ filename: import_v410.z.string(),
1743
+ score: import_v410.z.number(),
1744
+ text: import_v410.z.string()
1745
+ })
1746
+ ).nullable()
1747
+ });
1748
+ var fileSearch = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
1749
+ id: "openai.file_search",
1750
+ name: "file_search",
1751
+ inputSchema: import_v410.z.object({}),
1752
+ outputSchema: fileSearchOutputSchema
1753
+ });
1754
+
1755
+ // src/tool/image-generation.ts
1756
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1757
+ var import_v411 = require("zod/v4");
1758
+ var imageGenerationArgsSchema = import_v411.z.object({
1759
+ background: import_v411.z.enum(["auto", "opaque", "transparent"]).optional(),
1760
+ inputFidelity: import_v411.z.enum(["low", "high"]).optional(),
1761
+ inputImageMask: import_v411.z.object({
1762
+ fileId: import_v411.z.string().optional(),
1763
+ imageUrl: import_v411.z.string().optional()
1764
+ }).optional(),
1765
+ model: import_v411.z.string().optional(),
1766
+ moderation: import_v411.z.enum(["auto"]).optional(),
1767
+ outputCompression: import_v411.z.number().int().min(0).max(100).optional(),
1768
+ outputFormat: import_v411.z.enum(["png", "jpeg", "webp"]).optional(),
1769
+ quality: import_v411.z.enum(["auto", "low", "medium", "high"]).optional(),
1770
+ size: import_v411.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
1771
+ }).strict();
1772
+ var imageGenerationOutputSchema = import_v411.z.object({
1773
+ result: import_v411.z.string()
1774
+ });
1775
+ var imageGenerationToolFactory = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1776
+ id: "openai.image_generation",
1777
+ name: "image_generation",
1778
+ inputSchema: import_v411.z.object({}),
1779
+ outputSchema: imageGenerationOutputSchema
1780
+ });
1781
+ var imageGeneration = (args = {}) => {
1782
+ return imageGenerationToolFactory(args);
1783
+ };
1784
+
1832
1785
  // src/tool/web-search.ts
1833
1786
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
1834
1787
  var import_v412 = require("zod/v4");
@@ -1870,6 +1823,65 @@ var webSearch = (args = {}) => {
1870
1823
  return webSearchToolFactory(args);
1871
1824
  };
1872
1825
 
1826
+ // src/tool/web-search-preview.ts
1827
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1828
+ var import_v413 = require("zod/v4");
1829
+ var webSearchPreviewArgsSchema = import_v413.z.object({
1830
+ /**
1831
+ * Search context size to use for the web search.
1832
+ * - high: Most comprehensive context, highest cost, slower response
1833
+ * - medium: Balanced context, cost, and latency (default)
1834
+ * - low: Least context, lowest cost, fastest response
1835
+ */
1836
+ searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
1837
+ /**
1838
+ * User location information to provide geographically relevant search results.
1839
+ */
1840
+ userLocation: import_v413.z.object({
1841
+ /**
1842
+ * Type of location (always 'approximate')
1843
+ */
1844
+ type: import_v413.z.literal("approximate"),
1845
+ /**
1846
+ * Two-letter ISO country code (e.g., 'US', 'GB')
1847
+ */
1848
+ country: import_v413.z.string().optional(),
1849
+ /**
1850
+ * City name (free text, e.g., 'Minneapolis')
1851
+ */
1852
+ city: import_v413.z.string().optional(),
1853
+ /**
1854
+ * Region name (free text, e.g., 'Minnesota')
1855
+ */
1856
+ region: import_v413.z.string().optional(),
1857
+ /**
1858
+ * IANA timezone (e.g., 'America/Chicago')
1859
+ */
1860
+ timezone: import_v413.z.string().optional()
1861
+ }).optional()
1862
+ });
1863
+ var webSearchPreview = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1864
+ id: "openai.web_search_preview",
1865
+ name: "web_search_preview",
1866
+ inputSchema: import_v413.z.object({
1867
+ action: import_v413.z.discriminatedUnion("type", [
1868
+ import_v413.z.object({
1869
+ type: import_v413.z.literal("search"),
1870
+ query: import_v413.z.string().nullish()
1871
+ }),
1872
+ import_v413.z.object({
1873
+ type: import_v413.z.literal("open_page"),
1874
+ url: import_v413.z.string()
1875
+ }),
1876
+ import_v413.z.object({
1877
+ type: import_v413.z.literal("find"),
1878
+ url: import_v413.z.string(),
1879
+ pattern: import_v413.z.string()
1880
+ })
1881
+ ]).nullish()
1882
+ })
1883
+ });
1884
+
1873
1885
  // src/openai-tools.ts
1874
1886
  var openaiTools = {
1875
1887
  /**
@@ -1895,6 +1907,20 @@ var openaiTools = {
1895
1907
  * @param filters - The filters to use for the file search.
1896
1908
  */
1897
1909
  fileSearch,
1910
+ /**
1911
+ * The image generation tool allows you to generate images using a text prompt,
1912
+ * and optionally image inputs. It leverages the GPT Image model,
1913
+ * and automatically optimizes text inputs for improved performance.
1914
+ *
1915
+ * Must have name `image_generation`.
1916
+ *
1917
+ * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)
1918
+ * @param quality - Rendering quality (e.g. low, medium, high)
1919
+ * @param format - File output format
1920
+ * @param compression - Compression level (0-100%) for JPEG and WebP formats
1921
+ * @param background - Transparent or opaque
1922
+ */
1923
+ imageGeneration,
1898
1924
  /**
1899
1925
  * Web search allows models to access up-to-date information from the internet
1900
1926
  * and provide answers with sourced citations.
@@ -1921,37 +1947,37 @@ var openaiTools = {
1921
1947
  };
1922
1948
 
1923
1949
  // src/responses/openai-responses-language-model.ts
1924
- var import_provider8 = require("@ai-sdk/provider");
1950
+ var import_provider8 = require("@zenning/provider");
1925
1951
  var import_provider_utils13 = require("@ai-sdk/provider-utils");
1926
- var import_v414 = require("zod/v4");
1952
+ var import_v415 = require("zod/v4");
1927
1953
 
1928
- // src/responses/convert-to-openai-responses-messages.ts
1929
- var import_provider6 = require("@ai-sdk/provider");
1930
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1931
- var import_v413 = require("zod/v4");
1954
+ // src/responses/convert-to-openai-responses-input.ts
1955
+ var import_provider6 = require("@zenning/provider");
1932
1956
  var import_provider_utils12 = require("@ai-sdk/provider-utils");
1957
+ var import_v414 = require("zod/v4");
1933
1958
  function isFileId(data, prefixes) {
1934
1959
  if (!prefixes) return false;
1935
1960
  return prefixes.some((prefix) => data.startsWith(prefix));
1936
1961
  }
1937
- async function convertToOpenAIResponsesMessages({
1962
+ async function convertToOpenAIResponsesInput({
1938
1963
  prompt,
1939
1964
  systemMessageMode,
1940
- fileIdPrefixes
1965
+ fileIdPrefixes,
1966
+ store
1941
1967
  }) {
1942
1968
  var _a, _b, _c, _d, _e, _f;
1943
- const messages = [];
1969
+ const input = [];
1944
1970
  const warnings = [];
1945
1971
  for (const { role, content } of prompt) {
1946
1972
  switch (role) {
1947
1973
  case "system": {
1948
1974
  switch (systemMessageMode) {
1949
1975
  case "system": {
1950
- messages.push({ role: "system", content });
1976
+ input.push({ role: "system", content });
1951
1977
  break;
1952
1978
  }
1953
1979
  case "developer": {
1954
- messages.push({ role: "developer", content });
1980
+ input.push({ role: "developer", content });
1955
1981
  break;
1956
1982
  }
1957
1983
  case "remove": {
@@ -1971,7 +1997,7 @@ async function convertToOpenAIResponsesMessages({
1971
1997
  break;
1972
1998
  }
1973
1999
  case "user": {
1974
- messages.push({
2000
+ input.push({
1975
2001
  role: "user",
1976
2002
  content: content.map((part, index) => {
1977
2003
  var _a2, _b2, _c2;
@@ -2016,10 +2042,11 @@ async function convertToOpenAIResponsesMessages({
2016
2042
  }
2017
2043
  case "assistant": {
2018
2044
  const reasoningMessages = {};
2045
+ const toolCallParts = {};
2019
2046
  for (const part of content) {
2020
2047
  switch (part.type) {
2021
2048
  case "text": {
2022
- messages.push({
2049
+ input.push({
2023
2050
  role: "assistant",
2024
2051
  content: [{ type: "output_text", text: part.text }],
2025
2052
  id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
@@ -2027,10 +2054,11 @@ async function convertToOpenAIResponsesMessages({
2027
2054
  break;
2028
2055
  }
2029
2056
  case "tool-call": {
2057
+ toolCallParts[part.toolCallId] = part;
2030
2058
  if (part.providerExecuted) {
2031
2059
  break;
2032
2060
  }
2033
- messages.push({
2061
+ input.push({
2034
2062
  type: "function_call",
2035
2063
  call_id: part.toolCallId,
2036
2064
  name: part.toolName,
@@ -2039,15 +2067,20 @@ async function convertToOpenAIResponsesMessages({
2039
2067
  });
2040
2068
  break;
2041
2069
  }
2070
+ // assistant tool result parts are from provider-executed tools:
2042
2071
  case "tool-result": {
2043
- warnings.push({
2044
- type: "other",
2045
- message: `tool result parts in assistant messages are not supported for OpenAI responses`
2046
- });
2072
+ if (store) {
2073
+ input.push({ type: "item_reference", id: part.toolCallId });
2074
+ } else {
2075
+ warnings.push({
2076
+ type: "other",
2077
+ message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
2078
+ });
2079
+ }
2047
2080
  break;
2048
2081
  }
2049
2082
  case "reasoning": {
2050
- const providerOptions = await (0, import_provider_utils11.parseProviderOptions)({
2083
+ const providerOptions = await (0, import_provider_utils12.parseProviderOptions)({
2051
2084
  provider: "openai",
2052
2085
  providerOptions: part.providerOptions,
2053
2086
  schema: openaiResponsesReasoningProviderOptionsSchema
@@ -2071,7 +2104,7 @@ async function convertToOpenAIResponsesMessages({
2071
2104
  encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2072
2105
  summary: summaryParts
2073
2106
  };
2074
- messages.push(reasoningMessages[reasoningId]);
2107
+ input.push(reasoningMessages[reasoningId]);
2075
2108
  } else {
2076
2109
  existingReasoningMessage.summary.push(...summaryParts);
2077
2110
  }
@@ -2102,7 +2135,7 @@ async function convertToOpenAIResponsesMessages({
2102
2135
  contentValue = JSON.stringify(output.value);
2103
2136
  break;
2104
2137
  }
2105
- messages.push({
2138
+ input.push({
2106
2139
  type: "function_call_output",
2107
2140
  call_id: part.toolCallId,
2108
2141
  output: contentValue
@@ -2116,11 +2149,11 @@ async function convertToOpenAIResponsesMessages({
2116
2149
  }
2117
2150
  }
2118
2151
  }
2119
- return { messages, warnings };
2152
+ return { input, warnings };
2120
2153
  }
2121
- var openaiResponsesReasoningProviderOptionsSchema = import_v413.z.object({
2122
- itemId: import_v413.z.string().nullish(),
2123
- reasoningEncryptedContent: import_v413.z.string().nullish()
2154
+ var openaiResponsesReasoningProviderOptionsSchema = import_v414.z.object({
2155
+ itemId: import_v414.z.string().nullish(),
2156
+ reasoningEncryptedContent: import_v414.z.string().nullish()
2124
2157
  });
2125
2158
 
2126
2159
  // src/responses/map-openai-responses-finish-reason.ts
@@ -2142,7 +2175,7 @@ function mapOpenAIResponseFinishReason({
2142
2175
  }
2143
2176
 
2144
2177
  // src/responses/openai-responses-prepare-tools.ts
2145
- var import_provider7 = require("@ai-sdk/provider");
2178
+ var import_provider7 = require("@zenning/provider");
2146
2179
  function prepareResponsesTools({
2147
2180
  tools,
2148
2181
  toolChoice,
@@ -2173,7 +2206,10 @@ function prepareResponsesTools({
2173
2206
  type: "file_search",
2174
2207
  vector_store_ids: args.vectorStoreIds,
2175
2208
  max_num_results: args.maxNumResults,
2176
- ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
2209
+ ranking_options: args.ranking ? {
2210
+ ranker: args.ranking.ranker,
2211
+ score_threshold: args.ranking.scoreThreshold
2212
+ } : void 0,
2177
2213
  filters: args.filters
2178
2214
  });
2179
2215
  break;
@@ -2205,8 +2241,23 @@ function prepareResponsesTools({
2205
2241
  });
2206
2242
  break;
2207
2243
  }
2208
- default: {
2209
- toolWarnings.push({ type: "unsupported-tool", tool });
2244
+ case "openai.image_generation": {
2245
+ const args = imageGenerationArgsSchema.parse(tool.args);
2246
+ openaiTools2.push({
2247
+ type: "image_generation",
2248
+ background: args.background,
2249
+ input_fidelity: args.inputFidelity,
2250
+ input_image_mask: args.inputImageMask ? {
2251
+ file_id: args.inputImageMask.fileId,
2252
+ image_url: args.inputImageMask.imageUrl
2253
+ } : void 0,
2254
+ model: args.model,
2255
+ size: args.size,
2256
+ quality: args.quality,
2257
+ moderation: args.moderation,
2258
+ output_format: args.outputFormat,
2259
+ output_compression: args.outputCompression
2260
+ });
2210
2261
  break;
2211
2262
  }
2212
2263
  }
@@ -2229,7 +2280,7 @@ function prepareResponsesTools({
2229
2280
  case "tool":
2230
2281
  return {
2231
2282
  tools: openaiTools2,
2232
- toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
2283
+ toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
2233
2284
  toolWarnings
2234
2285
  };
2235
2286
  default: {
@@ -2242,47 +2293,66 @@ function prepareResponsesTools({
2242
2293
  }
2243
2294
 
2244
2295
  // src/responses/openai-responses-language-model.ts
2245
- var webSearchCallItem = import_v414.z.object({
2246
- type: import_v414.z.literal("web_search_call"),
2247
- id: import_v414.z.string(),
2248
- status: import_v414.z.string(),
2249
- action: import_v414.z.discriminatedUnion("type", [
2250
- import_v414.z.object({
2251
- type: import_v414.z.literal("search"),
2252
- query: import_v414.z.string().nullish()
2296
+ var webSearchCallItem = import_v415.z.object({
2297
+ type: import_v415.z.literal("web_search_call"),
2298
+ id: import_v415.z.string(),
2299
+ status: import_v415.z.string(),
2300
+ action: import_v415.z.discriminatedUnion("type", [
2301
+ import_v415.z.object({
2302
+ type: import_v415.z.literal("search"),
2303
+ query: import_v415.z.string().nullish()
2253
2304
  }),
2254
- import_v414.z.object({
2255
- type: import_v414.z.literal("open_page"),
2256
- url: import_v414.z.string()
2305
+ import_v415.z.object({
2306
+ type: import_v415.z.literal("open_page"),
2307
+ url: import_v415.z.string()
2257
2308
  }),
2258
- import_v414.z.object({
2259
- type: import_v414.z.literal("find"),
2260
- url: import_v414.z.string(),
2261
- pattern: import_v414.z.string()
2309
+ import_v415.z.object({
2310
+ type: import_v415.z.literal("find"),
2311
+ url: import_v415.z.string(),
2312
+ pattern: import_v415.z.string()
2262
2313
  })
2263
2314
  ]).nullish()
2264
2315
  });
2265
- var codeInterpreterCallItem = import_v414.z.object({
2266
- type: import_v414.z.literal("code_interpreter_call"),
2267
- id: import_v414.z.string(),
2268
- code: import_v414.z.string().nullable(),
2269
- container_id: import_v414.z.string(),
2270
- outputs: import_v414.z.array(
2271
- import_v414.z.discriminatedUnion("type", [
2272
- import_v414.z.object({ type: import_v414.z.literal("logs"), logs: import_v414.z.string() }),
2273
- import_v414.z.object({ type: import_v414.z.literal("image"), url: import_v414.z.string() })
2316
+ var fileSearchCallItem = import_v415.z.object({
2317
+ type: import_v415.z.literal("file_search_call"),
2318
+ id: import_v415.z.string(),
2319
+ queries: import_v415.z.array(import_v415.z.string()),
2320
+ results: import_v415.z.array(
2321
+ import_v415.z.object({
2322
+ attributes: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()),
2323
+ file_id: import_v415.z.string(),
2324
+ filename: import_v415.z.string(),
2325
+ score: import_v415.z.number(),
2326
+ text: import_v415.z.string()
2327
+ })
2328
+ ).nullish()
2329
+ });
2330
+ var codeInterpreterCallItem = import_v415.z.object({
2331
+ type: import_v415.z.literal("code_interpreter_call"),
2332
+ id: import_v415.z.string(),
2333
+ code: import_v415.z.string().nullable(),
2334
+ container_id: import_v415.z.string(),
2335
+ outputs: import_v415.z.array(
2336
+ import_v415.z.discriminatedUnion("type", [
2337
+ import_v415.z.object({ type: import_v415.z.literal("logs"), logs: import_v415.z.string() }),
2338
+ import_v415.z.object({ type: import_v415.z.literal("image"), url: import_v415.z.string() })
2274
2339
  ])
2275
2340
  ).nullable()
2276
2341
  });
2342
+ var imageGenerationCallItem = import_v415.z.object({
2343
+ type: import_v415.z.literal("image_generation_call"),
2344
+ id: import_v415.z.string(),
2345
+ result: import_v415.z.string()
2346
+ });
2277
2347
  var TOP_LOGPROBS_MAX = 20;
2278
- var LOGPROBS_SCHEMA = import_v414.z.array(
2279
- import_v414.z.object({
2280
- token: import_v414.z.string(),
2281
- logprob: import_v414.z.number(),
2282
- top_logprobs: import_v414.z.array(
2283
- import_v414.z.object({
2284
- token: import_v414.z.string(),
2285
- logprob: import_v414.z.number()
2348
+ var LOGPROBS_SCHEMA = import_v415.z.array(
2349
+ import_v415.z.object({
2350
+ token: import_v415.z.string(),
2351
+ logprob: import_v415.z.number(),
2352
+ top_logprobs: import_v415.z.array(
2353
+ import_v415.z.object({
2354
+ token: import_v415.z.string(),
2355
+ logprob: import_v415.z.number()
2286
2356
  })
2287
2357
  )
2288
2358
  })
@@ -2339,32 +2409,44 @@ var OpenAIResponsesLanguageModel = class {
2339
2409
  if (stopSequences != null) {
2340
2410
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2341
2411
  }
2342
- const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
2343
- prompt,
2344
- systemMessageMode: modelConfig.systemMessageMode,
2345
- fileIdPrefixes: this.config.fileIdPrefixes
2346
- });
2347
- warnings.push(...messageWarnings);
2348
2412
  const openaiOptions = await (0, import_provider_utils13.parseProviderOptions)({
2349
2413
  provider: "openai",
2350
2414
  providerOptions,
2351
2415
  schema: openaiResponsesProviderOptionsSchema
2352
2416
  });
2353
- const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2417
+ const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2418
+ prompt,
2419
+ systemMessageMode: modelConfig.systemMessageMode,
2420
+ fileIdPrefixes: this.config.fileIdPrefixes,
2421
+ store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
2422
+ });
2423
+ warnings.push(...inputWarnings);
2424
+ const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
2354
2425
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
2426
+ function addInclude(key) {
2427
+ include = include != null ? [...include, key] : [key];
2428
+ }
2429
+ function hasOpenAITool(id) {
2430
+ return (tools == null ? void 0 : tools.find(
2431
+ (tool) => tool.type === "provider-defined" && tool.id === id
2432
+ )) != null;
2433
+ }
2355
2434
  const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
2356
- include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2357
- const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2435
+ if (topLogprobs) {
2436
+ addInclude("message.output_text.logprobs");
2437
+ }
2438
+ const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
2358
2439
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2359
- )) == null ? void 0 : _b.name;
2360
- include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2361
- const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2362
- (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2363
2440
  )) == null ? void 0 : _c.name;
2364
- include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2441
+ if (webSearchToolName) {
2442
+ addInclude("web_search_call.action.sources");
2443
+ }
2444
+ if (hasOpenAITool("openai.code_interpreter")) {
2445
+ addInclude("code_interpreter_call.outputs");
2446
+ }
2365
2447
  const baseArgs = {
2366
2448
  model: this.modelId,
2367
- input: messages,
2449
+ input,
2368
2450
  temperature,
2369
2451
  top_p: topP,
2370
2452
  max_output_tokens: maxOutputTokens,
@@ -2385,6 +2467,7 @@ var OpenAIResponsesLanguageModel = class {
2385
2467
  }
2386
2468
  },
2387
2469
  // provider options:
2470
+ max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
2388
2471
  metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
2389
2472
  parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
2390
2473
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
@@ -2480,7 +2563,7 @@ var OpenAIResponsesLanguageModel = class {
2480
2563
  };
2481
2564
  }
2482
2565
  async doGenerate(options) {
2483
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2566
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2484
2567
  const {
2485
2568
  args: body,
2486
2569
  warnings,
@@ -2500,96 +2583,82 @@ var OpenAIResponsesLanguageModel = class {
2500
2583
  body,
2501
2584
  failedResponseHandler: openaiFailedResponseHandler,
2502
2585
  successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
2503
- import_v414.z.object({
2504
- id: import_v414.z.string(),
2505
- created_at: import_v414.z.number(),
2506
- error: import_v414.z.object({
2507
- code: import_v414.z.string(),
2508
- message: import_v414.z.string()
2586
+ import_v415.z.object({
2587
+ id: import_v415.z.string(),
2588
+ created_at: import_v415.z.number(),
2589
+ error: import_v415.z.object({
2590
+ code: import_v415.z.string(),
2591
+ message: import_v415.z.string()
2509
2592
  }).nullish(),
2510
- model: import_v414.z.string(),
2511
- output: import_v414.z.array(
2512
- import_v414.z.discriminatedUnion("type", [
2513
- import_v414.z.object({
2514
- type: import_v414.z.literal("message"),
2515
- role: import_v414.z.literal("assistant"),
2516
- id: import_v414.z.string(),
2517
- content: import_v414.z.array(
2518
- import_v414.z.object({
2519
- type: import_v414.z.literal("output_text"),
2520
- text: import_v414.z.string(),
2593
+ model: import_v415.z.string(),
2594
+ output: import_v415.z.array(
2595
+ import_v415.z.discriminatedUnion("type", [
2596
+ import_v415.z.object({
2597
+ type: import_v415.z.literal("message"),
2598
+ role: import_v415.z.literal("assistant"),
2599
+ id: import_v415.z.string(),
2600
+ content: import_v415.z.array(
2601
+ import_v415.z.object({
2602
+ type: import_v415.z.literal("output_text"),
2603
+ text: import_v415.z.string(),
2521
2604
  logprobs: LOGPROBS_SCHEMA.nullish(),
2522
- annotations: import_v414.z.array(
2523
- import_v414.z.discriminatedUnion("type", [
2524
- import_v414.z.object({
2525
- type: import_v414.z.literal("url_citation"),
2526
- start_index: import_v414.z.number(),
2527
- end_index: import_v414.z.number(),
2528
- url: import_v414.z.string(),
2529
- title: import_v414.z.string()
2605
+ annotations: import_v415.z.array(
2606
+ import_v415.z.discriminatedUnion("type", [
2607
+ import_v415.z.object({
2608
+ type: import_v415.z.literal("url_citation"),
2609
+ start_index: import_v415.z.number(),
2610
+ end_index: import_v415.z.number(),
2611
+ url: import_v415.z.string(),
2612
+ title: import_v415.z.string()
2530
2613
  }),
2531
- import_v414.z.object({
2532
- type: import_v414.z.literal("file_citation"),
2533
- file_id: import_v414.z.string(),
2534
- filename: import_v414.z.string().nullish(),
2535
- index: import_v414.z.number().nullish(),
2536
- start_index: import_v414.z.number().nullish(),
2537
- end_index: import_v414.z.number().nullish(),
2538
- quote: import_v414.z.string().nullish()
2614
+ import_v415.z.object({
2615
+ type: import_v415.z.literal("file_citation"),
2616
+ file_id: import_v415.z.string(),
2617
+ filename: import_v415.z.string().nullish(),
2618
+ index: import_v415.z.number().nullish(),
2619
+ start_index: import_v415.z.number().nullish(),
2620
+ end_index: import_v415.z.number().nullish(),
2621
+ quote: import_v415.z.string().nullish()
2539
2622
  }),
2540
- import_v414.z.object({
2541
- type: import_v414.z.literal("container_file_citation")
2623
+ import_v415.z.object({
2624
+ type: import_v415.z.literal("container_file_citation")
2542
2625
  })
2543
2626
  ])
2544
2627
  )
2545
2628
  })
2546
2629
  )
2547
2630
  }),
2631
+ webSearchCallItem,
2632
+ fileSearchCallItem,
2548
2633
  codeInterpreterCallItem,
2549
- import_v414.z.object({
2550
- type: import_v414.z.literal("function_call"),
2551
- call_id: import_v414.z.string(),
2552
- name: import_v414.z.string(),
2553
- arguments: import_v414.z.string(),
2554
- id: import_v414.z.string()
2634
+ imageGenerationCallItem,
2635
+ import_v415.z.object({
2636
+ type: import_v415.z.literal("function_call"),
2637
+ call_id: import_v415.z.string(),
2638
+ name: import_v415.z.string(),
2639
+ arguments: import_v415.z.string(),
2640
+ id: import_v415.z.string()
2555
2641
  }),
2556
- webSearchCallItem,
2557
- import_v414.z.object({
2558
- type: import_v414.z.literal("computer_call"),
2559
- id: import_v414.z.string(),
2560
- status: import_v414.z.string().optional()
2642
+ import_v415.z.object({
2643
+ type: import_v415.z.literal("computer_call"),
2644
+ id: import_v415.z.string(),
2645
+ status: import_v415.z.string().optional()
2561
2646
  }),
2562
- import_v414.z.object({
2563
- type: import_v414.z.literal("file_search_call"),
2564
- id: import_v414.z.string(),
2565
- status: import_v414.z.string().optional(),
2566
- queries: import_v414.z.array(import_v414.z.string()).nullish(),
2567
- results: import_v414.z.array(
2568
- import_v414.z.object({
2569
- attributes: import_v414.z.object({
2570
- file_id: import_v414.z.string(),
2571
- filename: import_v414.z.string(),
2572
- score: import_v414.z.number(),
2573
- text: import_v414.z.string()
2574
- })
2575
- })
2576
- ).nullish()
2577
- }),
2578
- import_v414.z.object({
2579
- type: import_v414.z.literal("reasoning"),
2580
- id: import_v414.z.string(),
2581
- encrypted_content: import_v414.z.string().nullish(),
2582
- summary: import_v414.z.array(
2583
- import_v414.z.object({
2584
- type: import_v414.z.literal("summary_text"),
2585
- text: import_v414.z.string()
2647
+ import_v415.z.object({
2648
+ type: import_v415.z.literal("reasoning"),
2649
+ id: import_v415.z.string(),
2650
+ encrypted_content: import_v415.z.string().nullish(),
2651
+ summary: import_v415.z.array(
2652
+ import_v415.z.object({
2653
+ type: import_v415.z.literal("summary_text"),
2654
+ text: import_v415.z.string()
2586
2655
  })
2587
2656
  )
2588
2657
  })
2589
2658
  ])
2590
2659
  ),
2591
- service_tier: import_v414.z.string().nullish(),
2592
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullable(),
2660
+ service_tier: import_v415.z.string().nullish(),
2661
+ incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullable(),
2593
2662
  usage: usageSchema2
2594
2663
  })
2595
2664
  ),
@@ -2630,6 +2699,25 @@ var OpenAIResponsesLanguageModel = class {
2630
2699
  }
2631
2700
  break;
2632
2701
  }
2702
+ case "image_generation_call": {
2703
+ content.push({
2704
+ type: "tool-call",
2705
+ toolCallId: part.id,
2706
+ toolName: "image_generation",
2707
+ input: "{}",
2708
+ providerExecuted: true
2709
+ });
2710
+ content.push({
2711
+ type: "tool-result",
2712
+ toolCallId: part.id,
2713
+ toolName: "image_generation",
2714
+ result: {
2715
+ result: part.result
2716
+ },
2717
+ providerExecuted: true
2718
+ });
2719
+ break;
2720
+ }
2633
2721
  case "message": {
2634
2722
  for (const contentPart of part.content) {
2635
2723
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
@@ -2660,7 +2748,10 @@ var OpenAIResponsesLanguageModel = class {
2660
2748
  id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils13.generateId)(),
2661
2749
  mediaType: "text/plain",
2662
2750
  title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
2663
- filename: (_l = annotation.filename) != null ? _l : annotation.file_id
2751
+ filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
2752
+ fileId: annotation.file_id,
2753
+ startIndex: (_m = annotation.start_index) != null ? _m : void 0,
2754
+ endIndex: (_n = annotation.end_index) != null ? _n : void 0
2664
2755
  });
2665
2756
  }
2666
2757
  }
@@ -2724,7 +2815,7 @@ var OpenAIResponsesLanguageModel = class {
2724
2815
  type: "tool-call",
2725
2816
  toolCallId: part.id,
2726
2817
  toolName: "file_search",
2727
- input: "",
2818
+ input: "{}",
2728
2819
  providerExecuted: true
2729
2820
  });
2730
2821
  content.push({
@@ -2732,10 +2823,14 @@ var OpenAIResponsesLanguageModel = class {
2732
2823
  toolCallId: part.id,
2733
2824
  toolName: "file_search",
2734
2825
  result: {
2735
- type: "file_search_tool_result",
2736
- status: part.status || "completed",
2737
- ...part.queries && { queries: part.queries },
2738
- ...part.results && { results: part.results }
2826
+ queries: part.queries,
2827
+ results: (_p = (_o = part.results) == null ? void 0 : _o.map((result) => ({
2828
+ attributes: result.attributes,
2829
+ fileId: result.file_id,
2830
+ filename: result.filename,
2831
+ score: result.score,
2832
+ text: result.text
2833
+ }))) != null ? _p : null
2739
2834
  },
2740
2835
  providerExecuted: true
2741
2836
  });
@@ -2777,15 +2872,15 @@ var OpenAIResponsesLanguageModel = class {
2777
2872
  return {
2778
2873
  content,
2779
2874
  finishReason: mapOpenAIResponseFinishReason({
2780
- finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
2875
+ finishReason: (_q = response.incomplete_details) == null ? void 0 : _q.reason,
2781
2876
  hasFunctionCall
2782
2877
  }),
2783
2878
  usage: {
2784
2879
  inputTokens: response.usage.input_tokens,
2785
2880
  outputTokens: response.usage.output_tokens,
2786
2881
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
2787
- reasoningTokens: (_o = (_n = response.usage.output_tokens_details) == null ? void 0 : _n.reasoning_tokens) != null ? _o : void 0,
2788
- cachedInputTokens: (_q = (_p = response.usage.input_tokens_details) == null ? void 0 : _p.cached_tokens) != null ? _q : void 0
2882
+ reasoningTokens: (_s = (_r = response.usage.output_tokens_details) == null ? void 0 : _r.reasoning_tokens) != null ? _s : void 0,
2883
+ cachedInputTokens: (_u = (_t = response.usage.input_tokens_details) == null ? void 0 : _t.cached_tokens) != null ? _u : void 0
2789
2884
  },
2790
2885
  request: { body },
2791
2886
  response: {
@@ -2842,7 +2937,7 @@ var OpenAIResponsesLanguageModel = class {
2842
2937
  controller.enqueue({ type: "stream-start", warnings });
2843
2938
  },
2844
2939
  transform(chunk, controller) {
2845
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2940
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
2846
2941
  if (options.includeRawChunks) {
2847
2942
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2848
2943
  }
@@ -2884,14 +2979,20 @@ var OpenAIResponsesLanguageModel = class {
2884
2979
  toolName: "computer_use"
2885
2980
  });
2886
2981
  } else if (value.item.type === "file_search_call") {
2887
- ongoingToolCalls[value.output_index] = {
2982
+ controller.enqueue({
2983
+ type: "tool-call",
2984
+ toolCallId: value.item.id,
2888
2985
  toolName: "file_search",
2889
- toolCallId: value.item.id
2890
- };
2986
+ input: "{}",
2987
+ providerExecuted: true
2988
+ });
2989
+ } else if (value.item.type === "image_generation_call") {
2891
2990
  controller.enqueue({
2892
- type: "tool-input-start",
2893
- id: value.item.id,
2894
- toolName: "file_search"
2991
+ type: "tool-call",
2992
+ toolCallId: value.item.id,
2993
+ toolName: "image_generation",
2994
+ input: "{}",
2995
+ providerExecuted: true
2895
2996
  });
2896
2997
  } else if (value.item.type === "message") {
2897
2998
  controller.enqueue({
@@ -2983,26 +3084,19 @@ var OpenAIResponsesLanguageModel = class {
2983
3084
  });
2984
3085
  } else if (value.item.type === "file_search_call") {
2985
3086
  ongoingToolCalls[value.output_index] = void 0;
2986
- controller.enqueue({
2987
- type: "tool-input-end",
2988
- id: value.item.id
2989
- });
2990
- controller.enqueue({
2991
- type: "tool-call",
2992
- toolCallId: value.item.id,
2993
- toolName: "file_search",
2994
- input: "",
2995
- providerExecuted: true
2996
- });
2997
3087
  controller.enqueue({
2998
3088
  type: "tool-result",
2999
3089
  toolCallId: value.item.id,
3000
3090
  toolName: "file_search",
3001
3091
  result: {
3002
- type: "file_search_tool_result",
3003
- status: value.item.status || "completed",
3004
- ...value.item.queries && { queries: value.item.queries },
3005
- ...value.item.results && { results: value.item.results }
3092
+ queries: value.item.queries,
3093
+ results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
3094
+ attributes: result.attributes,
3095
+ fileId: result.file_id,
3096
+ filename: result.filename,
3097
+ score: result.score,
3098
+ text: result.text
3099
+ }))) != null ? _c : null
3006
3100
  },
3007
3101
  providerExecuted: true
3008
3102
  });
@@ -3026,6 +3120,16 @@ var OpenAIResponsesLanguageModel = class {
3026
3120
  },
3027
3121
  providerExecuted: true
3028
3122
  });
3123
+ } else if (value.item.type === "image_generation_call") {
3124
+ controller.enqueue({
3125
+ type: "tool-result",
3126
+ toolCallId: value.item.id,
3127
+ toolName: "image_generation",
3128
+ result: {
3129
+ result: value.item.result
3130
+ },
3131
+ providerExecuted: true
3132
+ });
3029
3133
  } else if (value.item.type === "message") {
3030
3134
  controller.enqueue({
3031
3135
  type: "text-end",
@@ -3040,7 +3144,7 @@ var OpenAIResponsesLanguageModel = class {
3040
3144
  providerMetadata: {
3041
3145
  openai: {
3042
3146
  itemId: value.item.id,
3043
- reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
3147
+ reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
3044
3148
  }
3045
3149
  }
3046
3150
  });
@@ -3070,12 +3174,12 @@ var OpenAIResponsesLanguageModel = class {
3070
3174
  id: value.item_id,
3071
3175
  delta: value.delta
3072
3176
  });
3073
- if (((_d = (_c = options.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.logprobs) && value.logprobs) {
3177
+ if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
3074
3178
  logprobs.push(value.logprobs);
3075
3179
  }
3076
3180
  } else if (isResponseReasoningSummaryPartAddedChunk(value)) {
3077
3181
  if (value.summary_index > 0) {
3078
- (_e = activeReasoning[value.item_id]) == null ? void 0 : _e.summaryParts.push(
3182
+ (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.summaryParts.push(
3079
3183
  value.summary_index
3080
3184
  );
3081
3185
  controller.enqueue({
@@ -3084,7 +3188,7 @@ var OpenAIResponsesLanguageModel = class {
3084
3188
  providerMetadata: {
3085
3189
  openai: {
3086
3190
  itemId: value.item_id,
3087
- reasoningEncryptedContent: (_g = (_f = activeReasoning[value.item_id]) == null ? void 0 : _f.encryptedContent) != null ? _g : null
3191
+ reasoningEncryptedContent: (_i = (_h = activeReasoning[value.item_id]) == null ? void 0 : _h.encryptedContent) != null ? _i : null
3088
3192
  }
3089
3193
  }
3090
3194
  });
@@ -3102,14 +3206,14 @@ var OpenAIResponsesLanguageModel = class {
3102
3206
  });
3103
3207
  } else if (isResponseFinishedChunk(value)) {
3104
3208
  finishReason = mapOpenAIResponseFinishReason({
3105
- finishReason: (_h = value.response.incomplete_details) == null ? void 0 : _h.reason,
3209
+ finishReason: (_j = value.response.incomplete_details) == null ? void 0 : _j.reason,
3106
3210
  hasFunctionCall
3107
3211
  });
3108
3212
  usage.inputTokens = value.response.usage.input_tokens;
3109
3213
  usage.outputTokens = value.response.usage.output_tokens;
3110
3214
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
3111
- usage.reasoningTokens = (_j = (_i = value.response.usage.output_tokens_details) == null ? void 0 : _i.reasoning_tokens) != null ? _j : void 0;
3112
- usage.cachedInputTokens = (_l = (_k = value.response.usage.input_tokens_details) == null ? void 0 : _k.cached_tokens) != null ? _l : void 0;
3215
+ usage.reasoningTokens = (_l = (_k = value.response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0;
3216
+ usage.cachedInputTokens = (_n = (_m = value.response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0;
3113
3217
  if (typeof value.response.service_tier === "string") {
3114
3218
  serviceTier = value.response.service_tier;
3115
3219
  }
@@ -3118,7 +3222,7 @@ var OpenAIResponsesLanguageModel = class {
3118
3222
  controller.enqueue({
3119
3223
  type: "source",
3120
3224
  sourceType: "url",
3121
- id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils13.generateId)(),
3225
+ id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils13.generateId)(),
3122
3226
  url: value.annotation.url,
3123
3227
  title: value.annotation.title
3124
3228
  });
@@ -3126,10 +3230,13 @@ var OpenAIResponsesLanguageModel = class {
3126
3230
  controller.enqueue({
3127
3231
  type: "source",
3128
3232
  sourceType: "document",
3129
- id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils13.generateId)(),
3233
+ id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils13.generateId)(),
3130
3234
  mediaType: "text/plain",
3131
- title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
3132
- filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
3235
+ title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
3236
+ filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id,
3237
+ fileId: value.annotation.file_id,
3238
+ startIndex: (_x = value.annotation.start_index) != null ? _x : void 0,
3239
+ endIndex: (_y = value.annotation.end_index) != null ? _y : void 0
3133
3240
  });
3134
3241
  }
3135
3242
  } else if (isErrorChunk(value)) {
@@ -3162,177 +3269,155 @@ var OpenAIResponsesLanguageModel = class {
3162
3269
  };
3163
3270
  }
3164
3271
  };
3165
- var usageSchema2 = import_v414.z.object({
3166
- input_tokens: import_v414.z.number(),
3167
- input_tokens_details: import_v414.z.object({ cached_tokens: import_v414.z.number().nullish() }).nullish(),
3168
- output_tokens: import_v414.z.number(),
3169
- output_tokens_details: import_v414.z.object({ reasoning_tokens: import_v414.z.number().nullish() }).nullish()
3272
+ var usageSchema2 = import_v415.z.object({
3273
+ input_tokens: import_v415.z.number(),
3274
+ input_tokens_details: import_v415.z.object({ cached_tokens: import_v415.z.number().nullish() }).nullish(),
3275
+ output_tokens: import_v415.z.number(),
3276
+ output_tokens_details: import_v415.z.object({ reasoning_tokens: import_v415.z.number().nullish() }).nullish()
3170
3277
  });
3171
- var textDeltaChunkSchema = import_v414.z.object({
3172
- type: import_v414.z.literal("response.output_text.delta"),
3173
- item_id: import_v414.z.string(),
3174
- delta: import_v414.z.string(),
3278
+ var textDeltaChunkSchema = import_v415.z.object({
3279
+ type: import_v415.z.literal("response.output_text.delta"),
3280
+ item_id: import_v415.z.string(),
3281
+ delta: import_v415.z.string(),
3175
3282
  logprobs: LOGPROBS_SCHEMA.nullish()
3176
3283
  });
3177
- var errorChunkSchema = import_v414.z.object({
3178
- type: import_v414.z.literal("error"),
3179
- code: import_v414.z.string(),
3180
- message: import_v414.z.string(),
3181
- param: import_v414.z.string().nullish(),
3182
- sequence_number: import_v414.z.number()
3284
+ var errorChunkSchema = import_v415.z.object({
3285
+ type: import_v415.z.literal("error"),
3286
+ code: import_v415.z.string(),
3287
+ message: import_v415.z.string(),
3288
+ param: import_v415.z.string().nullish(),
3289
+ sequence_number: import_v415.z.number()
3183
3290
  });
3184
- var responseFinishedChunkSchema = import_v414.z.object({
3185
- type: import_v414.z.enum(["response.completed", "response.incomplete"]),
3186
- response: import_v414.z.object({
3187
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullish(),
3291
+ var responseFinishedChunkSchema = import_v415.z.object({
3292
+ type: import_v415.z.enum(["response.completed", "response.incomplete"]),
3293
+ response: import_v415.z.object({
3294
+ incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
3188
3295
  usage: usageSchema2,
3189
- service_tier: import_v414.z.string().nullish()
3296
+ service_tier: import_v415.z.string().nullish()
3190
3297
  })
3191
3298
  });
3192
- var responseCreatedChunkSchema = import_v414.z.object({
3193
- type: import_v414.z.literal("response.created"),
3194
- response: import_v414.z.object({
3195
- id: import_v414.z.string(),
3196
- created_at: import_v414.z.number(),
3197
- model: import_v414.z.string(),
3198
- service_tier: import_v414.z.string().nullish()
3299
+ var responseCreatedChunkSchema = import_v415.z.object({
3300
+ type: import_v415.z.literal("response.created"),
3301
+ response: import_v415.z.object({
3302
+ id: import_v415.z.string(),
3303
+ created_at: import_v415.z.number(),
3304
+ model: import_v415.z.string(),
3305
+ service_tier: import_v415.z.string().nullish()
3199
3306
  })
3200
3307
  });
3201
- var responseOutputItemAddedSchema = import_v414.z.object({
3202
- type: import_v414.z.literal("response.output_item.added"),
3203
- output_index: import_v414.z.number(),
3204
- item: import_v414.z.discriminatedUnion("type", [
3205
- import_v414.z.object({
3206
- type: import_v414.z.literal("message"),
3207
- id: import_v414.z.string()
3308
+ var responseOutputItemAddedSchema = import_v415.z.object({
3309
+ type: import_v415.z.literal("response.output_item.added"),
3310
+ output_index: import_v415.z.number(),
3311
+ item: import_v415.z.discriminatedUnion("type", [
3312
+ import_v415.z.object({
3313
+ type: import_v415.z.literal("message"),
3314
+ id: import_v415.z.string()
3208
3315
  }),
3209
- import_v414.z.object({
3210
- type: import_v414.z.literal("reasoning"),
3211
- id: import_v414.z.string(),
3212
- encrypted_content: import_v414.z.string().nullish()
3316
+ import_v415.z.object({
3317
+ type: import_v415.z.literal("reasoning"),
3318
+ id: import_v415.z.string(),
3319
+ encrypted_content: import_v415.z.string().nullish()
3213
3320
  }),
3214
- import_v414.z.object({
3215
- type: import_v414.z.literal("function_call"),
3216
- id: import_v414.z.string(),
3217
- call_id: import_v414.z.string(),
3218
- name: import_v414.z.string(),
3219
- arguments: import_v414.z.string()
3321
+ import_v415.z.object({
3322
+ type: import_v415.z.literal("function_call"),
3323
+ id: import_v415.z.string(),
3324
+ call_id: import_v415.z.string(),
3325
+ name: import_v415.z.string(),
3326
+ arguments: import_v415.z.string()
3220
3327
  }),
3221
- import_v414.z.object({
3222
- type: import_v414.z.literal("web_search_call"),
3223
- id: import_v414.z.string(),
3224
- status: import_v414.z.string(),
3225
- action: import_v414.z.object({
3226
- type: import_v414.z.literal("search"),
3227
- query: import_v414.z.string().optional()
3328
+ import_v415.z.object({
3329
+ type: import_v415.z.literal("web_search_call"),
3330
+ id: import_v415.z.string(),
3331
+ status: import_v415.z.string(),
3332
+ action: import_v415.z.object({
3333
+ type: import_v415.z.literal("search"),
3334
+ query: import_v415.z.string().optional()
3228
3335
  }).nullish()
3229
3336
  }),
3230
- import_v414.z.object({
3231
- type: import_v414.z.literal("computer_call"),
3232
- id: import_v414.z.string(),
3233
- status: import_v414.z.string()
3337
+ import_v415.z.object({
3338
+ type: import_v415.z.literal("computer_call"),
3339
+ id: import_v415.z.string(),
3340
+ status: import_v415.z.string()
3234
3341
  }),
3235
- import_v414.z.object({
3236
- type: import_v414.z.literal("file_search_call"),
3237
- id: import_v414.z.string(),
3238
- status: import_v414.z.string(),
3239
- queries: import_v414.z.array(import_v414.z.string()).nullish(),
3240
- results: import_v414.z.array(
3241
- import_v414.z.object({
3242
- attributes: import_v414.z.object({
3243
- file_id: import_v414.z.string(),
3244
- filename: import_v414.z.string(),
3245
- score: import_v414.z.number(),
3246
- text: import_v414.z.string()
3247
- })
3248
- })
3249
- ).optional()
3342
+ import_v415.z.object({
3343
+ type: import_v415.z.literal("file_search_call"),
3344
+ id: import_v415.z.string()
3345
+ }),
3346
+ import_v415.z.object({
3347
+ type: import_v415.z.literal("image_generation_call"),
3348
+ id: import_v415.z.string()
3250
3349
  })
3251
3350
  ])
3252
3351
  });
3253
- var responseOutputItemDoneSchema = import_v414.z.object({
3254
- type: import_v414.z.literal("response.output_item.done"),
3255
- output_index: import_v414.z.number(),
3256
- item: import_v414.z.discriminatedUnion("type", [
3257
- import_v414.z.object({
3258
- type: import_v414.z.literal("message"),
3259
- id: import_v414.z.string()
3352
+ var responseOutputItemDoneSchema = import_v415.z.object({
3353
+ type: import_v415.z.literal("response.output_item.done"),
3354
+ output_index: import_v415.z.number(),
3355
+ item: import_v415.z.discriminatedUnion("type", [
3356
+ import_v415.z.object({
3357
+ type: import_v415.z.literal("message"),
3358
+ id: import_v415.z.string()
3260
3359
  }),
3261
- import_v414.z.object({
3262
- type: import_v414.z.literal("reasoning"),
3263
- id: import_v414.z.string(),
3264
- encrypted_content: import_v414.z.string().nullish()
3360
+ import_v415.z.object({
3361
+ type: import_v415.z.literal("reasoning"),
3362
+ id: import_v415.z.string(),
3363
+ encrypted_content: import_v415.z.string().nullish()
3265
3364
  }),
3266
- import_v414.z.object({
3267
- type: import_v414.z.literal("function_call"),
3268
- id: import_v414.z.string(),
3269
- call_id: import_v414.z.string(),
3270
- name: import_v414.z.string(),
3271
- arguments: import_v414.z.string(),
3272
- status: import_v414.z.literal("completed")
3365
+ import_v415.z.object({
3366
+ type: import_v415.z.literal("function_call"),
3367
+ id: import_v415.z.string(),
3368
+ call_id: import_v415.z.string(),
3369
+ name: import_v415.z.string(),
3370
+ arguments: import_v415.z.string(),
3371
+ status: import_v415.z.literal("completed")
3273
3372
  }),
3274
3373
  codeInterpreterCallItem,
3374
+ imageGenerationCallItem,
3275
3375
  webSearchCallItem,
3276
- import_v414.z.object({
3277
- type: import_v414.z.literal("computer_call"),
3278
- id: import_v414.z.string(),
3279
- status: import_v414.z.literal("completed")
3280
- }),
3281
- import_v414.z.object({
3282
- type: import_v414.z.literal("file_search_call"),
3283
- id: import_v414.z.string(),
3284
- status: import_v414.z.literal("completed"),
3285
- queries: import_v414.z.array(import_v414.z.string()).nullish(),
3286
- results: import_v414.z.array(
3287
- import_v414.z.object({
3288
- attributes: import_v414.z.object({
3289
- file_id: import_v414.z.string(),
3290
- filename: import_v414.z.string(),
3291
- score: import_v414.z.number(),
3292
- text: import_v414.z.string()
3293
- })
3294
- })
3295
- ).nullish()
3376
+ fileSearchCallItem,
3377
+ import_v415.z.object({
3378
+ type: import_v415.z.literal("computer_call"),
3379
+ id: import_v415.z.string(),
3380
+ status: import_v415.z.literal("completed")
3296
3381
  })
3297
3382
  ])
3298
3383
  });
3299
- var responseFunctionCallArgumentsDeltaSchema = import_v414.z.object({
3300
- type: import_v414.z.literal("response.function_call_arguments.delta"),
3301
- item_id: import_v414.z.string(),
3302
- output_index: import_v414.z.number(),
3303
- delta: import_v414.z.string()
3384
+ var responseFunctionCallArgumentsDeltaSchema = import_v415.z.object({
3385
+ type: import_v415.z.literal("response.function_call_arguments.delta"),
3386
+ item_id: import_v415.z.string(),
3387
+ output_index: import_v415.z.number(),
3388
+ delta: import_v415.z.string()
3304
3389
  });
3305
- var responseAnnotationAddedSchema = import_v414.z.object({
3306
- type: import_v414.z.literal("response.output_text.annotation.added"),
3307
- annotation: import_v414.z.discriminatedUnion("type", [
3308
- import_v414.z.object({
3309
- type: import_v414.z.literal("url_citation"),
3310
- url: import_v414.z.string(),
3311
- title: import_v414.z.string()
3390
+ var responseAnnotationAddedSchema = import_v415.z.object({
3391
+ type: import_v415.z.literal("response.output_text.annotation.added"),
3392
+ annotation: import_v415.z.discriminatedUnion("type", [
3393
+ import_v415.z.object({
3394
+ type: import_v415.z.literal("url_citation"),
3395
+ url: import_v415.z.string(),
3396
+ title: import_v415.z.string()
3312
3397
  }),
3313
- import_v414.z.object({
3314
- type: import_v414.z.literal("file_citation"),
3315
- file_id: import_v414.z.string(),
3316
- filename: import_v414.z.string().nullish(),
3317
- index: import_v414.z.number().nullish(),
3318
- start_index: import_v414.z.number().nullish(),
3319
- end_index: import_v414.z.number().nullish(),
3320
- quote: import_v414.z.string().nullish()
3398
+ import_v415.z.object({
3399
+ type: import_v415.z.literal("file_citation"),
3400
+ file_id: import_v415.z.string(),
3401
+ filename: import_v415.z.string().nullish(),
3402
+ index: import_v415.z.number().nullish(),
3403
+ start_index: import_v415.z.number().nullish(),
3404
+ end_index: import_v415.z.number().nullish(),
3405
+ quote: import_v415.z.string().nullish()
3321
3406
  })
3322
3407
  ])
3323
3408
  });
3324
- var responseReasoningSummaryPartAddedSchema = import_v414.z.object({
3325
- type: import_v414.z.literal("response.reasoning_summary_part.added"),
3326
- item_id: import_v414.z.string(),
3327
- summary_index: import_v414.z.number()
3409
+ var responseReasoningSummaryPartAddedSchema = import_v415.z.object({
3410
+ type: import_v415.z.literal("response.reasoning_summary_part.added"),
3411
+ item_id: import_v415.z.string(),
3412
+ summary_index: import_v415.z.number()
3328
3413
  });
3329
- var responseReasoningSummaryTextDeltaSchema = import_v414.z.object({
3330
- type: import_v414.z.literal("response.reasoning_summary_text.delta"),
3331
- item_id: import_v414.z.string(),
3332
- summary_index: import_v414.z.number(),
3333
- delta: import_v414.z.string()
3414
+ var responseReasoningSummaryTextDeltaSchema = import_v415.z.object({
3415
+ type: import_v415.z.literal("response.reasoning_summary_text.delta"),
3416
+ item_id: import_v415.z.string(),
3417
+ summary_index: import_v415.z.number(),
3418
+ delta: import_v415.z.string()
3334
3419
  });
3335
- var openaiResponsesChunkSchema = import_v414.z.union([
3420
+ var openaiResponsesChunkSchema = import_v415.z.union([
3336
3421
  textDeltaChunkSchema,
3337
3422
  responseFinishedChunkSchema,
3338
3423
  responseCreatedChunkSchema,
@@ -3343,7 +3428,7 @@ var openaiResponsesChunkSchema = import_v414.z.union([
3343
3428
  responseReasoningSummaryPartAddedSchema,
3344
3429
  responseReasoningSummaryTextDeltaSchema,
3345
3430
  errorChunkSchema,
3346
- import_v414.z.object({ type: import_v414.z.string() }).loose()
3431
+ import_v415.z.object({ type: import_v415.z.string() }).loose()
3347
3432
  // fallback for unknown chunks
3348
3433
  ]);
3349
3434
  function isTextDeltaChunk(chunk) {
@@ -3416,27 +3501,15 @@ function getResponsesModelConfig(modelId) {
3416
3501
  isReasoningModel: false
3417
3502
  };
3418
3503
  }
3419
- var openaiResponsesProviderOptionsSchema = import_v414.z.object({
3420
- metadata: import_v414.z.any().nullish(),
3421
- parallelToolCalls: import_v414.z.boolean().nullish(),
3422
- previousResponseId: import_v414.z.string().nullish(),
3423
- store: import_v414.z.boolean().nullish(),
3424
- user: import_v414.z.string().nullish(),
3425
- reasoningEffort: import_v414.z.string().nullish(),
3426
- strictJsonSchema: import_v414.z.boolean().nullish(),
3427
- instructions: import_v414.z.string().nullish(),
3428
- reasoningSummary: import_v414.z.string().nullish(),
3429
- serviceTier: import_v414.z.enum(["auto", "flex", "priority"]).nullish(),
3430
- include: import_v414.z.array(
3431
- import_v414.z.enum([
3504
+ var openaiResponsesProviderOptionsSchema = import_v415.z.object({
3505
+ include: import_v415.z.array(
3506
+ import_v415.z.enum([
3432
3507
  "reasoning.encrypted_content",
3433
3508
  "file_search_call.results",
3434
3509
  "message.output_text.logprobs"
3435
3510
  ])
3436
3511
  ).nullish(),
3437
- textVerbosity: import_v414.z.enum(["low", "medium", "high"]).nullish(),
3438
- promptCacheKey: import_v414.z.string().nullish(),
3439
- safetyIdentifier: import_v414.z.string().nullish(),
3512
+ instructions: import_v415.z.string().nullish(),
3440
3513
  /**
3441
3514
  * Return the log probabilities of the tokens.
3442
3515
  *
@@ -3449,15 +3522,33 @@ var openaiResponsesProviderOptionsSchema = import_v414.z.object({
3449
3522
  * @see https://platform.openai.com/docs/api-reference/responses/create
3450
3523
  * @see https://cookbook.openai.com/examples/using_logprobs
3451
3524
  */
3452
- logprobs: import_v414.z.union([import_v414.z.boolean(), import_v414.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
3525
+ logprobs: import_v415.z.union([import_v415.z.boolean(), import_v415.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3526
+ /**
3527
+ * The maximum number of total calls to built-in tools that can be processed in a response.
3528
+ * This maximum number applies across all built-in tool calls, not per individual tool.
3529
+ * Any further attempts to call a tool by the model will be ignored.
3530
+ */
3531
+ maxToolCalls: import_v415.z.number().nullish(),
3532
+ metadata: import_v415.z.any().nullish(),
3533
+ parallelToolCalls: import_v415.z.boolean().nullish(),
3534
+ previousResponseId: import_v415.z.string().nullish(),
3535
+ promptCacheKey: import_v415.z.string().nullish(),
3536
+ reasoningEffort: import_v415.z.string().nullish(),
3537
+ reasoningSummary: import_v415.z.string().nullish(),
3538
+ safetyIdentifier: import_v415.z.string().nullish(),
3539
+ serviceTier: import_v415.z.enum(["auto", "flex", "priority"]).nullish(),
3540
+ store: import_v415.z.boolean().nullish(),
3541
+ strictJsonSchema: import_v415.z.boolean().nullish(),
3542
+ textVerbosity: import_v415.z.enum(["low", "medium", "high"]).nullish(),
3543
+ user: import_v415.z.string().nullish()
3453
3544
  });
3454
3545
 
3455
3546
  // src/speech/openai-speech-model.ts
3456
3547
  var import_provider_utils14 = require("@ai-sdk/provider-utils");
3457
- var import_v415 = require("zod/v4");
3458
- var OpenAIProviderOptionsSchema = import_v415.z.object({
3459
- instructions: import_v415.z.string().nullish(),
3460
- speed: import_v415.z.number().min(0.25).max(4).default(1).nullish()
3548
+ var import_v416 = require("zod/v4");
3549
+ var OpenAIProviderOptionsSchema = import_v416.z.object({
3550
+ instructions: import_v416.z.string().nullish(),
3551
+ speed: import_v416.z.number().min(0.25).max(4).default(1).nullish()
3461
3552
  });
3462
3553
  var OpenAISpeechModel = class {
3463
3554
  constructor(modelId, config) {
@@ -3561,33 +3652,33 @@ var OpenAISpeechModel = class {
3561
3652
 
3562
3653
  // src/transcription/openai-transcription-model.ts
3563
3654
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
3564
- var import_v417 = require("zod/v4");
3655
+ var import_v418 = require("zod/v4");
3565
3656
 
3566
3657
  // src/transcription/openai-transcription-options.ts
3567
- var import_v416 = require("zod/v4");
3568
- var openAITranscriptionProviderOptions = import_v416.z.object({
3658
+ var import_v417 = require("zod/v4");
3659
+ var openAITranscriptionProviderOptions = import_v417.z.object({
3569
3660
  /**
3570
3661
  * Additional information to include in the transcription response.
3571
3662
  */
3572
- include: import_v416.z.array(import_v416.z.string()).optional(),
3663
+ include: import_v417.z.array(import_v417.z.string()).optional(),
3573
3664
  /**
3574
3665
  * The language of the input audio in ISO-639-1 format.
3575
3666
  */
3576
- language: import_v416.z.string().optional(),
3667
+ language: import_v417.z.string().optional(),
3577
3668
  /**
3578
3669
  * An optional text to guide the model's style or continue a previous audio segment.
3579
3670
  */
3580
- prompt: import_v416.z.string().optional(),
3671
+ prompt: import_v417.z.string().optional(),
3581
3672
  /**
3582
3673
  * The sampling temperature, between 0 and 1.
3583
3674
  * @default 0
3584
3675
  */
3585
- temperature: import_v416.z.number().min(0).max(1).default(0).optional(),
3676
+ temperature: import_v417.z.number().min(0).max(1).default(0).optional(),
3586
3677
  /**
3587
3678
  * The timestamp granularities to populate for this transcription.
3588
3679
  * @default ['segment']
3589
3680
  */
3590
- timestampGranularities: import_v416.z.array(import_v416.z.enum(["word", "segment"])).default(["segment"]).optional()
3681
+ timestampGranularities: import_v417.z.array(import_v417.z.enum(["word", "segment"])).default(["segment"]).optional()
3591
3682
  });
3592
3683
 
3593
3684
  // src/transcription/openai-transcription-model.ts
@@ -3756,29 +3847,29 @@ var OpenAITranscriptionModel = class {
3756
3847
  };
3757
3848
  }
3758
3849
  };
3759
- var openaiTranscriptionResponseSchema = import_v417.z.object({
3760
- text: import_v417.z.string(),
3761
- language: import_v417.z.string().nullish(),
3762
- duration: import_v417.z.number().nullish(),
3763
- words: import_v417.z.array(
3764
- import_v417.z.object({
3765
- word: import_v417.z.string(),
3766
- start: import_v417.z.number(),
3767
- end: import_v417.z.number()
3850
+ var openaiTranscriptionResponseSchema = import_v418.z.object({
3851
+ text: import_v418.z.string(),
3852
+ language: import_v418.z.string().nullish(),
3853
+ duration: import_v418.z.number().nullish(),
3854
+ words: import_v418.z.array(
3855
+ import_v418.z.object({
3856
+ word: import_v418.z.string(),
3857
+ start: import_v418.z.number(),
3858
+ end: import_v418.z.number()
3768
3859
  })
3769
3860
  ).nullish(),
3770
- segments: import_v417.z.array(
3771
- import_v417.z.object({
3772
- id: import_v417.z.number(),
3773
- seek: import_v417.z.number(),
3774
- start: import_v417.z.number(),
3775
- end: import_v417.z.number(),
3776
- text: import_v417.z.string(),
3777
- tokens: import_v417.z.array(import_v417.z.number()),
3778
- temperature: import_v417.z.number(),
3779
- avg_logprob: import_v417.z.number(),
3780
- compression_ratio: import_v417.z.number(),
3781
- no_speech_prob: import_v417.z.number()
3861
+ segments: import_v418.z.array(
3862
+ import_v418.z.object({
3863
+ id: import_v418.z.number(),
3864
+ seek: import_v418.z.number(),
3865
+ start: import_v418.z.number(),
3866
+ end: import_v418.z.number(),
3867
+ text: import_v418.z.string(),
3868
+ tokens: import_v418.z.array(import_v418.z.number()),
3869
+ temperature: import_v418.z.number(),
3870
+ avg_logprob: import_v418.z.number(),
3871
+ compression_ratio: import_v418.z.number(),
3872
+ no_speech_prob: import_v418.z.number()
3782
3873
  })
3783
3874
  ).nullish()
3784
3875
  });