@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.
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/internal/index.ts
21
- var internal_exports = {};
22
- __export(internal_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  OpenAIChatLanguageModel: () => OpenAIChatLanguageModel,
24
24
  OpenAICompletionLanguageModel: () => OpenAICompletionLanguageModel,
25
25
  OpenAIEmbeddingModel: () => OpenAIEmbeddingModel,
@@ -34,12 +34,12 @@ __export(internal_exports, {
34
34
  openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
35
35
  openaiProviderOptions: () => openaiProviderOptions
36
36
  });
37
- module.exports = __toCommonJS(internal_exports);
37
+ module.exports = __toCommonJS(index_exports);
38
38
 
39
39
  // src/chat/openai-chat-language-model.ts
40
- var import_provider3 = require("@ai-sdk/provider");
41
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
42
- var import_v45 = require("zod/v4");
40
+ var import_provider3 = require("@zenning/provider");
41
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
42
+ var import_v43 = require("zod/v4");
43
43
 
44
44
  // src/openai-error.ts
45
45
  var import_v4 = require("zod/v4");
@@ -61,7 +61,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
61
61
  });
62
62
 
63
63
  // src/chat/convert-to-openai-chat-messages.ts
64
- var import_provider = require("@ai-sdk/provider");
64
+ var import_provider = require("@zenning/provider");
65
65
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
66
66
  function convertToOpenAIChatMessages({
67
67
  prompt,
@@ -359,99 +359,7 @@ var openaiProviderOptions = import_v42.z.object({
359
359
  });
360
360
 
361
361
  // src/chat/openai-chat-prepare-tools.ts
362
- var import_provider2 = require("@ai-sdk/provider");
363
-
364
- // src/tool/file-search.ts
365
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
366
- var import_v43 = require("zod/v4");
367
- var comparisonFilterSchema = import_v43.z.object({
368
- key: import_v43.z.string(),
369
- type: import_v43.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
370
- value: import_v43.z.union([import_v43.z.string(), import_v43.z.number(), import_v43.z.boolean()])
371
- });
372
- var compoundFilterSchema = import_v43.z.object({
373
- type: import_v43.z.enum(["and", "or"]),
374
- filters: import_v43.z.array(
375
- import_v43.z.union([comparisonFilterSchema, import_v43.z.lazy(() => compoundFilterSchema)])
376
- )
377
- });
378
- var filtersSchema = import_v43.z.union([comparisonFilterSchema, compoundFilterSchema]);
379
- var fileSearchArgsSchema = import_v43.z.object({
380
- vectorStoreIds: import_v43.z.array(import_v43.z.string()).optional(),
381
- maxNumResults: import_v43.z.number().optional(),
382
- ranking: import_v43.z.object({
383
- ranker: import_v43.z.enum(["auto", "default-2024-08-21"]).optional()
384
- }).optional(),
385
- filters: filtersSchema.optional()
386
- });
387
- var fileSearch = (0, import_provider_utils3.createProviderDefinedToolFactory)({
388
- id: "openai.file_search",
389
- name: "file_search",
390
- inputSchema: import_v43.z.object({
391
- query: import_v43.z.string().optional()
392
- })
393
- });
394
-
395
- // src/tool/web-search-preview.ts
396
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
397
- var import_v44 = require("zod/v4");
398
- var webSearchPreviewArgsSchema = import_v44.z.object({
399
- /**
400
- * Search context size to use for the web search.
401
- * - high: Most comprehensive context, highest cost, slower response
402
- * - medium: Balanced context, cost, and latency (default)
403
- * - low: Least context, lowest cost, fastest response
404
- */
405
- searchContextSize: import_v44.z.enum(["low", "medium", "high"]).optional(),
406
- /**
407
- * User location information to provide geographically relevant search results.
408
- */
409
- userLocation: import_v44.z.object({
410
- /**
411
- * Type of location (always 'approximate')
412
- */
413
- type: import_v44.z.literal("approximate"),
414
- /**
415
- * Two-letter ISO country code (e.g., 'US', 'GB')
416
- */
417
- country: import_v44.z.string().optional(),
418
- /**
419
- * City name (free text, e.g., 'Minneapolis')
420
- */
421
- city: import_v44.z.string().optional(),
422
- /**
423
- * Region name (free text, e.g., 'Minnesota')
424
- */
425
- region: import_v44.z.string().optional(),
426
- /**
427
- * IANA timezone (e.g., 'America/Chicago')
428
- */
429
- timezone: import_v44.z.string().optional()
430
- }).optional()
431
- });
432
- var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFactory)({
433
- id: "openai.web_search_preview",
434
- name: "web_search_preview",
435
- inputSchema: import_v44.z.object({
436
- action: import_v44.z.discriminatedUnion("type", [
437
- import_v44.z.object({
438
- type: import_v44.z.literal("search"),
439
- query: import_v44.z.string().nullish()
440
- }),
441
- import_v44.z.object({
442
- type: import_v44.z.literal("open_page"),
443
- url: import_v44.z.string()
444
- }),
445
- import_v44.z.object({
446
- type: import_v44.z.literal("find"),
447
- url: import_v44.z.string(),
448
- pattern: import_v44.z.string()
449
- })
450
- ]).nullish()
451
- })
452
- });
453
-
454
- // src/chat/openai-chat-prepare-tools.ts
362
+ var import_provider2 = require("@zenning/provider");
455
363
  function prepareChatTools({
456
364
  tools,
457
365
  toolChoice,
@@ -477,33 +385,6 @@ function prepareChatTools({
477
385
  }
478
386
  });
479
387
  break;
480
- case "provider-defined":
481
- switch (tool.id) {
482
- case "openai.file_search": {
483
- const args = fileSearchArgsSchema.parse(tool.args);
484
- openaiTools.push({
485
- type: "file_search",
486
- vector_store_ids: args.vectorStoreIds,
487
- max_num_results: args.maxNumResults,
488
- ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
489
- filters: args.filters
490
- });
491
- break;
492
- }
493
- case "openai.web_search_preview": {
494
- const args = webSearchPreviewArgsSchema.parse(tool.args);
495
- openaiTools.push({
496
- type: "web_search_preview",
497
- search_context_size: args.searchContextSize,
498
- user_location: args.userLocation
499
- });
500
- break;
501
- }
502
- default:
503
- toolWarnings.push({ type: "unsupported-tool", tool });
504
- break;
505
- }
506
- break;
507
388
  default:
508
389
  toolWarnings.push({ type: "unsupported-tool", tool });
509
390
  break;
@@ -568,7 +449,7 @@ var OpenAIChatLanguageModel = class {
568
449
  }) {
569
450
  var _a, _b, _c, _d;
570
451
  const warnings = [];
571
- const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
452
+ const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
572
453
  provider: "openai",
573
454
  providerOptions,
574
455
  schema: openaiProviderOptions
@@ -747,15 +628,15 @@ var OpenAIChatLanguageModel = class {
747
628
  responseHeaders,
748
629
  value: response,
749
630
  rawValue: rawResponse
750
- } = await (0, import_provider_utils5.postJsonToApi)({
631
+ } = await (0, import_provider_utils3.postJsonToApi)({
751
632
  url: this.config.url({
752
633
  path: "/chat/completions",
753
634
  modelId: this.modelId
754
635
  }),
755
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
636
+ headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
756
637
  body,
757
638
  failedResponseHandler: openaiFailedResponseHandler,
758
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
639
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
759
640
  openaiChatResponseSchema
760
641
  ),
761
642
  abortSignal: options.abortSignal,
@@ -770,7 +651,7 @@ var OpenAIChatLanguageModel = class {
770
651
  for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
771
652
  content.push({
772
653
  type: "tool-call",
773
- toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils5.generateId)(),
654
+ toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils3.generateId)(),
774
655
  toolName: toolCall.function.name,
775
656
  input: toolCall.function.arguments
776
657
  });
@@ -779,7 +660,7 @@ var OpenAIChatLanguageModel = class {
779
660
  content.push({
780
661
  type: "source",
781
662
  sourceType: "url",
782
- id: (0, import_provider_utils5.generateId)(),
663
+ id: (0, import_provider_utils3.generateId)(),
783
664
  url: annotation.url,
784
665
  title: annotation.title
785
666
  });
@@ -825,15 +706,15 @@ var OpenAIChatLanguageModel = class {
825
706
  include_usage: true
826
707
  }
827
708
  };
828
- const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
709
+ const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
829
710
  url: this.config.url({
830
711
  path: "/chat/completions",
831
712
  modelId: this.modelId
832
713
  }),
833
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
714
+ headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
834
715
  body,
835
716
  failedResponseHandler: openaiFailedResponseHandler,
836
- successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
717
+ successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
837
718
  openaiChatChunkSchema
838
719
  ),
839
720
  abortSignal: options.abortSignal,
@@ -958,14 +839,14 @@ var OpenAIChatLanguageModel = class {
958
839
  delta: toolCall2.function.arguments
959
840
  });
960
841
  }
961
- if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
842
+ if ((0, import_provider_utils3.isParsableJson)(toolCall2.function.arguments)) {
962
843
  controller.enqueue({
963
844
  type: "tool-input-end",
964
845
  id: toolCall2.id
965
846
  });
966
847
  controller.enqueue({
967
848
  type: "tool-call",
968
- toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils5.generateId)(),
849
+ toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils3.generateId)(),
969
850
  toolName: toolCall2.function.name,
970
851
  input: toolCall2.function.arguments
971
852
  });
@@ -986,14 +867,14 @@ var OpenAIChatLanguageModel = class {
986
867
  id: toolCall.id,
987
868
  delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
988
869
  });
989
- 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)) {
870
+ 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)) {
990
871
  controller.enqueue({
991
872
  type: "tool-input-end",
992
873
  id: toolCall.id
993
874
  });
994
875
  controller.enqueue({
995
876
  type: "tool-call",
996
- toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils5.generateId)(),
877
+ toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils3.generateId)(),
997
878
  toolName: toolCall.function.name,
998
879
  input: toolCall.function.arguments
999
880
  });
@@ -1006,7 +887,7 @@ var OpenAIChatLanguageModel = class {
1006
887
  controller.enqueue({
1007
888
  type: "source",
1008
889
  sourceType: "url",
1009
- id: (0, import_provider_utils5.generateId)(),
890
+ id: (0, import_provider_utils3.generateId)(),
1010
891
  url: annotation.url,
1011
892
  title: annotation.title
1012
893
  });
@@ -1031,115 +912,115 @@ var OpenAIChatLanguageModel = class {
1031
912
  };
1032
913
  }
1033
914
  };
1034
- var openaiTokenUsageSchema = import_v45.z.object({
1035
- prompt_tokens: import_v45.z.number().nullish(),
1036
- completion_tokens: import_v45.z.number().nullish(),
1037
- total_tokens: import_v45.z.number().nullish(),
1038
- prompt_tokens_details: import_v45.z.object({
1039
- cached_tokens: import_v45.z.number().nullish()
915
+ var openaiTokenUsageSchema = import_v43.z.object({
916
+ prompt_tokens: import_v43.z.number().nullish(),
917
+ completion_tokens: import_v43.z.number().nullish(),
918
+ total_tokens: import_v43.z.number().nullish(),
919
+ prompt_tokens_details: import_v43.z.object({
920
+ cached_tokens: import_v43.z.number().nullish()
1040
921
  }).nullish(),
1041
- completion_tokens_details: import_v45.z.object({
1042
- reasoning_tokens: import_v45.z.number().nullish(),
1043
- accepted_prediction_tokens: import_v45.z.number().nullish(),
1044
- rejected_prediction_tokens: import_v45.z.number().nullish()
922
+ completion_tokens_details: import_v43.z.object({
923
+ reasoning_tokens: import_v43.z.number().nullish(),
924
+ accepted_prediction_tokens: import_v43.z.number().nullish(),
925
+ rejected_prediction_tokens: import_v43.z.number().nullish()
1045
926
  }).nullish()
1046
927
  }).nullish();
1047
- var openaiChatResponseSchema = import_v45.z.object({
1048
- id: import_v45.z.string().nullish(),
1049
- created: import_v45.z.number().nullish(),
1050
- model: import_v45.z.string().nullish(),
1051
- choices: import_v45.z.array(
1052
- import_v45.z.object({
1053
- message: import_v45.z.object({
1054
- role: import_v45.z.literal("assistant").nullish(),
1055
- content: import_v45.z.string().nullish(),
1056
- tool_calls: import_v45.z.array(
1057
- import_v45.z.object({
1058
- id: import_v45.z.string().nullish(),
1059
- type: import_v45.z.literal("function"),
1060
- function: import_v45.z.object({
1061
- name: import_v45.z.string(),
1062
- arguments: import_v45.z.string()
928
+ var openaiChatResponseSchema = import_v43.z.object({
929
+ id: import_v43.z.string().nullish(),
930
+ created: import_v43.z.number().nullish(),
931
+ model: import_v43.z.string().nullish(),
932
+ choices: import_v43.z.array(
933
+ import_v43.z.object({
934
+ message: import_v43.z.object({
935
+ role: import_v43.z.literal("assistant").nullish(),
936
+ content: import_v43.z.string().nullish(),
937
+ tool_calls: import_v43.z.array(
938
+ import_v43.z.object({
939
+ id: import_v43.z.string().nullish(),
940
+ type: import_v43.z.literal("function"),
941
+ function: import_v43.z.object({
942
+ name: import_v43.z.string(),
943
+ arguments: import_v43.z.string()
1063
944
  })
1064
945
  })
1065
946
  ).nullish(),
1066
- annotations: import_v45.z.array(
1067
- import_v45.z.object({
1068
- type: import_v45.z.literal("url_citation"),
1069
- start_index: import_v45.z.number(),
1070
- end_index: import_v45.z.number(),
1071
- url: import_v45.z.string(),
1072
- title: import_v45.z.string()
947
+ annotations: import_v43.z.array(
948
+ import_v43.z.object({
949
+ type: import_v43.z.literal("url_citation"),
950
+ start_index: import_v43.z.number(),
951
+ end_index: import_v43.z.number(),
952
+ url: import_v43.z.string(),
953
+ title: import_v43.z.string()
1073
954
  })
1074
955
  ).nullish()
1075
956
  }),
1076
- index: import_v45.z.number(),
1077
- logprobs: import_v45.z.object({
1078
- content: import_v45.z.array(
1079
- import_v45.z.object({
1080
- token: import_v45.z.string(),
1081
- logprob: import_v45.z.number(),
1082
- top_logprobs: import_v45.z.array(
1083
- import_v45.z.object({
1084
- token: import_v45.z.string(),
1085
- logprob: import_v45.z.number()
957
+ index: import_v43.z.number(),
958
+ logprobs: import_v43.z.object({
959
+ content: import_v43.z.array(
960
+ import_v43.z.object({
961
+ token: import_v43.z.string(),
962
+ logprob: import_v43.z.number(),
963
+ top_logprobs: import_v43.z.array(
964
+ import_v43.z.object({
965
+ token: import_v43.z.string(),
966
+ logprob: import_v43.z.number()
1086
967
  })
1087
968
  )
1088
969
  })
1089
970
  ).nullish()
1090
971
  }).nullish(),
1091
- finish_reason: import_v45.z.string().nullish()
972
+ finish_reason: import_v43.z.string().nullish()
1092
973
  })
1093
974
  ),
1094
975
  usage: openaiTokenUsageSchema
1095
976
  });
1096
- var openaiChatChunkSchema = import_v45.z.union([
1097
- import_v45.z.object({
1098
- id: import_v45.z.string().nullish(),
1099
- created: import_v45.z.number().nullish(),
1100
- model: import_v45.z.string().nullish(),
1101
- choices: import_v45.z.array(
1102
- import_v45.z.object({
1103
- delta: import_v45.z.object({
1104
- role: import_v45.z.enum(["assistant"]).nullish(),
1105
- content: import_v45.z.string().nullish(),
1106
- tool_calls: import_v45.z.array(
1107
- import_v45.z.object({
1108
- index: import_v45.z.number(),
1109
- id: import_v45.z.string().nullish(),
1110
- type: import_v45.z.literal("function").nullish(),
1111
- function: import_v45.z.object({
1112
- name: import_v45.z.string().nullish(),
1113
- arguments: import_v45.z.string().nullish()
977
+ var openaiChatChunkSchema = import_v43.z.union([
978
+ import_v43.z.object({
979
+ id: import_v43.z.string().nullish(),
980
+ created: import_v43.z.number().nullish(),
981
+ model: import_v43.z.string().nullish(),
982
+ choices: import_v43.z.array(
983
+ import_v43.z.object({
984
+ delta: import_v43.z.object({
985
+ role: import_v43.z.enum(["assistant"]).nullish(),
986
+ content: import_v43.z.string().nullish(),
987
+ tool_calls: import_v43.z.array(
988
+ import_v43.z.object({
989
+ index: import_v43.z.number(),
990
+ id: import_v43.z.string().nullish(),
991
+ type: import_v43.z.literal("function").nullish(),
992
+ function: import_v43.z.object({
993
+ name: import_v43.z.string().nullish(),
994
+ arguments: import_v43.z.string().nullish()
1114
995
  })
1115
996
  })
1116
997
  ).nullish(),
1117
- annotations: import_v45.z.array(
1118
- import_v45.z.object({
1119
- type: import_v45.z.literal("url_citation"),
1120
- start_index: import_v45.z.number(),
1121
- end_index: import_v45.z.number(),
1122
- url: import_v45.z.string(),
1123
- title: import_v45.z.string()
998
+ annotations: import_v43.z.array(
999
+ import_v43.z.object({
1000
+ type: import_v43.z.literal("url_citation"),
1001
+ start_index: import_v43.z.number(),
1002
+ end_index: import_v43.z.number(),
1003
+ url: import_v43.z.string(),
1004
+ title: import_v43.z.string()
1124
1005
  })
1125
1006
  ).nullish()
1126
1007
  }).nullish(),
1127
- logprobs: import_v45.z.object({
1128
- content: import_v45.z.array(
1129
- import_v45.z.object({
1130
- token: import_v45.z.string(),
1131
- logprob: import_v45.z.number(),
1132
- top_logprobs: import_v45.z.array(
1133
- import_v45.z.object({
1134
- token: import_v45.z.string(),
1135
- logprob: import_v45.z.number()
1008
+ logprobs: import_v43.z.object({
1009
+ content: import_v43.z.array(
1010
+ import_v43.z.object({
1011
+ token: import_v43.z.string(),
1012
+ logprob: import_v43.z.number(),
1013
+ top_logprobs: import_v43.z.array(
1014
+ import_v43.z.object({
1015
+ token: import_v43.z.string(),
1016
+ logprob: import_v43.z.number()
1136
1017
  })
1137
1018
  )
1138
1019
  })
1139
1020
  ).nullish()
1140
1021
  }).nullish(),
1141
- finish_reason: import_v45.z.string().nullish(),
1142
- index: import_v45.z.number()
1022
+ finish_reason: import_v43.z.string().nullish(),
1023
+ index: import_v43.z.number()
1143
1024
  })
1144
1025
  ),
1145
1026
  usage: openaiTokenUsageSchema
@@ -1196,11 +1077,11 @@ var reasoningModels = {
1196
1077
  };
1197
1078
 
1198
1079
  // src/completion/openai-completion-language-model.ts
1199
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1200
- var import_v47 = require("zod/v4");
1080
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
1081
+ var import_v45 = require("zod/v4");
1201
1082
 
1202
1083
  // src/completion/convert-to-openai-completion-prompt.ts
1203
- var import_provider4 = require("@ai-sdk/provider");
1084
+ var import_provider4 = require("@zenning/provider");
1204
1085
  function convertToOpenAICompletionPrompt({
1205
1086
  prompt,
1206
1087
  user = "user",
@@ -1305,12 +1186,12 @@ function mapOpenAIFinishReason2(finishReason) {
1305
1186
  }
1306
1187
 
1307
1188
  // src/completion/openai-completion-options.ts
1308
- var import_v46 = require("zod/v4");
1309
- var openaiCompletionProviderOptions = import_v46.z.object({
1189
+ var import_v44 = require("zod/v4");
1190
+ var openaiCompletionProviderOptions = import_v44.z.object({
1310
1191
  /**
1311
1192
  Echo back the prompt in addition to the completion.
1312
1193
  */
1313
- echo: import_v46.z.boolean().optional(),
1194
+ echo: import_v44.z.boolean().optional(),
1314
1195
  /**
1315
1196
  Modify the likelihood of specified tokens appearing in the completion.
1316
1197
 
@@ -1325,16 +1206,16 @@ var openaiCompletionProviderOptions = import_v46.z.object({
1325
1206
  As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
1326
1207
  token from being generated.
1327
1208
  */
1328
- logitBias: import_v46.z.record(import_v46.z.string(), import_v46.z.number()).optional(),
1209
+ logitBias: import_v44.z.record(import_v44.z.string(), import_v44.z.number()).optional(),
1329
1210
  /**
1330
1211
  The suffix that comes after a completion of inserted text.
1331
1212
  */
1332
- suffix: import_v46.z.string().optional(),
1213
+ suffix: import_v44.z.string().optional(),
1333
1214
  /**
1334
1215
  A unique identifier representing your end-user, which can help OpenAI to
1335
1216
  monitor and detect abuse. Learn more.
1336
1217
  */
1337
- user: import_v46.z.string().optional(),
1218
+ user: import_v44.z.string().optional(),
1338
1219
  /**
1339
1220
  Return the log probabilities of the tokens. Including logprobs will increase
1340
1221
  the response size and can slow down response times. However, it can
@@ -1344,7 +1225,7 @@ var openaiCompletionProviderOptions = import_v46.z.object({
1344
1225
  Setting to a number will return the log probabilities of the top n
1345
1226
  tokens that were generated.
1346
1227
  */
1347
- logprobs: import_v46.z.union([import_v46.z.boolean(), import_v46.z.number()]).optional()
1228
+ logprobs: import_v44.z.union([import_v44.z.boolean(), import_v44.z.number()]).optional()
1348
1229
  });
1349
1230
 
1350
1231
  // src/completion/openai-completion-language-model.ts
@@ -1380,12 +1261,12 @@ var OpenAICompletionLanguageModel = class {
1380
1261
  }) {
1381
1262
  const warnings = [];
1382
1263
  const openaiOptions = {
1383
- ...await (0, import_provider_utils6.parseProviderOptions)({
1264
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1384
1265
  provider: "openai",
1385
1266
  providerOptions,
1386
1267
  schema: openaiCompletionProviderOptions
1387
1268
  }),
1388
- ...await (0, import_provider_utils6.parseProviderOptions)({
1269
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1389
1270
  provider: this.providerOptionsName,
1390
1271
  providerOptions,
1391
1272
  schema: openaiCompletionProviderOptions
@@ -1441,15 +1322,15 @@ var OpenAICompletionLanguageModel = class {
1441
1322
  responseHeaders,
1442
1323
  value: response,
1443
1324
  rawValue: rawResponse
1444
- } = await (0, import_provider_utils6.postJsonToApi)({
1325
+ } = await (0, import_provider_utils4.postJsonToApi)({
1445
1326
  url: this.config.url({
1446
1327
  path: "/completions",
1447
1328
  modelId: this.modelId
1448
1329
  }),
1449
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
1330
+ headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
1450
1331
  body: args,
1451
1332
  failedResponseHandler: openaiFailedResponseHandler,
1452
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1333
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1453
1334
  openaiCompletionResponseSchema
1454
1335
  ),
1455
1336
  abortSignal: options.abortSignal,
@@ -1487,15 +1368,15 @@ var OpenAICompletionLanguageModel = class {
1487
1368
  include_usage: true
1488
1369
  }
1489
1370
  };
1490
- const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
1371
+ const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1491
1372
  url: this.config.url({
1492
1373
  path: "/completions",
1493
1374
  modelId: this.modelId
1494
1375
  }),
1495
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
1376
+ headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
1496
1377
  body,
1497
1378
  failedResponseHandler: openaiFailedResponseHandler,
1498
- successfulResponseHandler: (0, import_provider_utils6.createEventSourceResponseHandler)(
1379
+ successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
1499
1380
  openaiCompletionChunkSchema
1500
1381
  ),
1501
1382
  abortSignal: options.abortSignal,
@@ -1576,42 +1457,42 @@ var OpenAICompletionLanguageModel = class {
1576
1457
  };
1577
1458
  }
1578
1459
  };
1579
- var usageSchema = import_v47.z.object({
1580
- prompt_tokens: import_v47.z.number(),
1581
- completion_tokens: import_v47.z.number(),
1582
- total_tokens: import_v47.z.number()
1460
+ var usageSchema = import_v45.z.object({
1461
+ prompt_tokens: import_v45.z.number(),
1462
+ completion_tokens: import_v45.z.number(),
1463
+ total_tokens: import_v45.z.number()
1583
1464
  });
1584
- var openaiCompletionResponseSchema = import_v47.z.object({
1585
- id: import_v47.z.string().nullish(),
1586
- created: import_v47.z.number().nullish(),
1587
- model: import_v47.z.string().nullish(),
1588
- choices: import_v47.z.array(
1589
- import_v47.z.object({
1590
- text: import_v47.z.string(),
1591
- finish_reason: import_v47.z.string(),
1592
- logprobs: import_v47.z.object({
1593
- tokens: import_v47.z.array(import_v47.z.string()),
1594
- token_logprobs: import_v47.z.array(import_v47.z.number()),
1595
- top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullish()
1465
+ var openaiCompletionResponseSchema = import_v45.z.object({
1466
+ id: import_v45.z.string().nullish(),
1467
+ created: import_v45.z.number().nullish(),
1468
+ model: import_v45.z.string().nullish(),
1469
+ choices: import_v45.z.array(
1470
+ import_v45.z.object({
1471
+ text: import_v45.z.string(),
1472
+ finish_reason: import_v45.z.string(),
1473
+ logprobs: import_v45.z.object({
1474
+ tokens: import_v45.z.array(import_v45.z.string()),
1475
+ token_logprobs: import_v45.z.array(import_v45.z.number()),
1476
+ top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
1596
1477
  }).nullish()
1597
1478
  })
1598
1479
  ),
1599
1480
  usage: usageSchema.nullish()
1600
1481
  });
1601
- var openaiCompletionChunkSchema = import_v47.z.union([
1602
- import_v47.z.object({
1603
- id: import_v47.z.string().nullish(),
1604
- created: import_v47.z.number().nullish(),
1605
- model: import_v47.z.string().nullish(),
1606
- choices: import_v47.z.array(
1607
- import_v47.z.object({
1608
- text: import_v47.z.string(),
1609
- finish_reason: import_v47.z.string().nullish(),
1610
- index: import_v47.z.number(),
1611
- logprobs: import_v47.z.object({
1612
- tokens: import_v47.z.array(import_v47.z.string()),
1613
- token_logprobs: import_v47.z.array(import_v47.z.number()),
1614
- top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullish()
1482
+ var openaiCompletionChunkSchema = import_v45.z.union([
1483
+ import_v45.z.object({
1484
+ id: import_v45.z.string().nullish(),
1485
+ created: import_v45.z.number().nullish(),
1486
+ model: import_v45.z.string().nullish(),
1487
+ choices: import_v45.z.array(
1488
+ import_v45.z.object({
1489
+ text: import_v45.z.string(),
1490
+ finish_reason: import_v45.z.string().nullish(),
1491
+ index: import_v45.z.number(),
1492
+ logprobs: import_v45.z.object({
1493
+ tokens: import_v45.z.array(import_v45.z.string()),
1494
+ token_logprobs: import_v45.z.array(import_v45.z.number()),
1495
+ top_logprobs: import_v45.z.array(import_v45.z.record(import_v45.z.string(), import_v45.z.number())).nullish()
1615
1496
  }).nullish()
1616
1497
  })
1617
1498
  ),
@@ -1621,23 +1502,23 @@ var openaiCompletionChunkSchema = import_v47.z.union([
1621
1502
  ]);
1622
1503
 
1623
1504
  // src/embedding/openai-embedding-model.ts
1624
- var import_provider5 = require("@ai-sdk/provider");
1625
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1626
- var import_v49 = require("zod/v4");
1505
+ var import_provider5 = require("@zenning/provider");
1506
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
1507
+ var import_v47 = require("zod/v4");
1627
1508
 
1628
1509
  // src/embedding/openai-embedding-options.ts
1629
- var import_v48 = require("zod/v4");
1630
- var openaiEmbeddingProviderOptions = import_v48.z.object({
1510
+ var import_v46 = require("zod/v4");
1511
+ var openaiEmbeddingProviderOptions = import_v46.z.object({
1631
1512
  /**
1632
1513
  The number of dimensions the resulting output embeddings should have.
1633
1514
  Only supported in text-embedding-3 and later models.
1634
1515
  */
1635
- dimensions: import_v48.z.number().optional(),
1516
+ dimensions: import_v46.z.number().optional(),
1636
1517
  /**
1637
1518
  A unique identifier representing your end-user, which can help OpenAI to
1638
1519
  monitor and detect abuse. Learn more.
1639
1520
  */
1640
- user: import_v48.z.string().optional()
1521
+ user: import_v46.z.string().optional()
1641
1522
  });
1642
1523
 
1643
1524
  // src/embedding/openai-embedding-model.ts
@@ -1667,7 +1548,7 @@ var OpenAIEmbeddingModel = class {
1667
1548
  values
1668
1549
  });
1669
1550
  }
1670
- const openaiOptions = (_a = await (0, import_provider_utils7.parseProviderOptions)({
1551
+ const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
1671
1552
  provider: "openai",
1672
1553
  providerOptions,
1673
1554
  schema: openaiEmbeddingProviderOptions
@@ -1676,12 +1557,12 @@ var OpenAIEmbeddingModel = class {
1676
1557
  responseHeaders,
1677
1558
  value: response,
1678
1559
  rawValue
1679
- } = await (0, import_provider_utils7.postJsonToApi)({
1560
+ } = await (0, import_provider_utils5.postJsonToApi)({
1680
1561
  url: this.config.url({
1681
1562
  path: "/embeddings",
1682
1563
  modelId: this.modelId
1683
1564
  }),
1684
- headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), headers),
1565
+ headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), headers),
1685
1566
  body: {
1686
1567
  model: this.modelId,
1687
1568
  input: values,
@@ -1690,7 +1571,7 @@ var OpenAIEmbeddingModel = class {
1690
1571
  user: openaiOptions.user
1691
1572
  },
1692
1573
  failedResponseHandler: openaiFailedResponseHandler,
1693
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1574
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1694
1575
  openaiTextEmbeddingResponseSchema
1695
1576
  ),
1696
1577
  abortSignal,
@@ -1703,14 +1584,14 @@ var OpenAIEmbeddingModel = class {
1703
1584
  };
1704
1585
  }
1705
1586
  };
1706
- var openaiTextEmbeddingResponseSchema = import_v49.z.object({
1707
- data: import_v49.z.array(import_v49.z.object({ embedding: import_v49.z.array(import_v49.z.number()) })),
1708
- usage: import_v49.z.object({ prompt_tokens: import_v49.z.number() }).nullish()
1587
+ var openaiTextEmbeddingResponseSchema = import_v47.z.object({
1588
+ data: import_v47.z.array(import_v47.z.object({ embedding: import_v47.z.array(import_v47.z.number()) })),
1589
+ usage: import_v47.z.object({ prompt_tokens: import_v47.z.number() }).nullish()
1709
1590
  });
1710
1591
 
1711
1592
  // src/image/openai-image-model.ts
1712
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1713
- var import_v410 = require("zod/v4");
1593
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1594
+ var import_v48 = require("zod/v4");
1714
1595
 
1715
1596
  // src/image/openai-image-options.ts
1716
1597
  var modelMaxImagesPerCall = {
@@ -1757,12 +1638,12 @@ var OpenAIImageModel = class {
1757
1638
  warnings.push({ type: "unsupported-setting", setting: "seed" });
1758
1639
  }
1759
1640
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1760
- const { value: response, responseHeaders } = await (0, import_provider_utils8.postJsonToApi)({
1641
+ const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
1761
1642
  url: this.config.url({
1762
1643
  path: "/images/generations",
1763
1644
  modelId: this.modelId
1764
1645
  }),
1765
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), headers),
1646
+ headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), headers),
1766
1647
  body: {
1767
1648
  model: this.modelId,
1768
1649
  prompt,
@@ -1772,7 +1653,7 @@ var OpenAIImageModel = class {
1772
1653
  ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1773
1654
  },
1774
1655
  failedResponseHandler: openaiFailedResponseHandler,
1775
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1656
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1776
1657
  openaiImageResponseSchema
1777
1658
  ),
1778
1659
  abortSignal,
@@ -1798,41 +1679,41 @@ var OpenAIImageModel = class {
1798
1679
  };
1799
1680
  }
1800
1681
  };
1801
- var openaiImageResponseSchema = import_v410.z.object({
1802
- data: import_v410.z.array(
1803
- import_v410.z.object({ b64_json: import_v410.z.string(), revised_prompt: import_v410.z.string().optional() })
1682
+ var openaiImageResponseSchema = import_v48.z.object({
1683
+ data: import_v48.z.array(
1684
+ import_v48.z.object({ b64_json: import_v48.z.string(), revised_prompt: import_v48.z.string().optional() })
1804
1685
  )
1805
1686
  });
1806
1687
 
1807
1688
  // src/transcription/openai-transcription-model.ts
1808
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1809
- var import_v412 = require("zod/v4");
1689
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1690
+ var import_v410 = require("zod/v4");
1810
1691
 
1811
1692
  // src/transcription/openai-transcription-options.ts
1812
- var import_v411 = require("zod/v4");
1813
- var openAITranscriptionProviderOptions = import_v411.z.object({
1693
+ var import_v49 = require("zod/v4");
1694
+ var openAITranscriptionProviderOptions = import_v49.z.object({
1814
1695
  /**
1815
1696
  * Additional information to include in the transcription response.
1816
1697
  */
1817
- include: import_v411.z.array(import_v411.z.string()).optional(),
1698
+ include: import_v49.z.array(import_v49.z.string()).optional(),
1818
1699
  /**
1819
1700
  * The language of the input audio in ISO-639-1 format.
1820
1701
  */
1821
- language: import_v411.z.string().optional(),
1702
+ language: import_v49.z.string().optional(),
1822
1703
  /**
1823
1704
  * An optional text to guide the model's style or continue a previous audio segment.
1824
1705
  */
1825
- prompt: import_v411.z.string().optional(),
1706
+ prompt: import_v49.z.string().optional(),
1826
1707
  /**
1827
1708
  * The sampling temperature, between 0 and 1.
1828
1709
  * @default 0
1829
1710
  */
1830
- temperature: import_v411.z.number().min(0).max(1).default(0).optional(),
1711
+ temperature: import_v49.z.number().min(0).max(1).default(0).optional(),
1831
1712
  /**
1832
1713
  * The timestamp granularities to populate for this transcription.
1833
1714
  * @default ['segment']
1834
1715
  */
1835
- timestampGranularities: import_v411.z.array(import_v411.z.enum(["word", "segment"])).default(["segment"]).optional()
1716
+ timestampGranularities: import_v49.z.array(import_v49.z.enum(["word", "segment"])).default(["segment"]).optional()
1836
1717
  });
1837
1718
 
1838
1719
  // src/transcription/openai-transcription-model.ts
@@ -1910,15 +1791,15 @@ var OpenAITranscriptionModel = class {
1910
1791
  providerOptions
1911
1792
  }) {
1912
1793
  const warnings = [];
1913
- const openAIOptions = await (0, import_provider_utils9.parseProviderOptions)({
1794
+ const openAIOptions = await (0, import_provider_utils7.parseProviderOptions)({
1914
1795
  provider: "openai",
1915
1796
  providerOptions,
1916
1797
  schema: openAITranscriptionProviderOptions
1917
1798
  });
1918
1799
  const formData = new FormData();
1919
- const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils9.convertBase64ToUint8Array)(audio)]);
1800
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils7.convertBase64ToUint8Array)(audio)]);
1920
1801
  formData.append("model", this.modelId);
1921
- const fileExtension = (0, import_provider_utils9.mediaTypeToExtension)(mediaType);
1802
+ const fileExtension = (0, import_provider_utils7.mediaTypeToExtension)(mediaType);
1922
1803
  formData.append(
1923
1804
  "file",
1924
1805
  new File([blob], "audio", { type: mediaType }),
@@ -1963,15 +1844,15 @@ var OpenAITranscriptionModel = class {
1963
1844
  value: response,
1964
1845
  responseHeaders,
1965
1846
  rawValue: rawResponse
1966
- } = await (0, import_provider_utils9.postFormDataToApi)({
1847
+ } = await (0, import_provider_utils7.postFormDataToApi)({
1967
1848
  url: this.config.url({
1968
1849
  path: "/audio/transcriptions",
1969
1850
  modelId: this.modelId
1970
1851
  }),
1971
- headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
1852
+ headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
1972
1853
  formData,
1973
1854
  failedResponseHandler: openaiFailedResponseHandler,
1974
- successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
1855
+ successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1975
1856
  openaiTranscriptionResponseSchema
1976
1857
  ),
1977
1858
  abortSignal: options.abortSignal,
@@ -2001,39 +1882,39 @@ var OpenAITranscriptionModel = class {
2001
1882
  };
2002
1883
  }
2003
1884
  };
2004
- var openaiTranscriptionResponseSchema = import_v412.z.object({
2005
- text: import_v412.z.string(),
2006
- language: import_v412.z.string().nullish(),
2007
- duration: import_v412.z.number().nullish(),
2008
- words: import_v412.z.array(
2009
- import_v412.z.object({
2010
- word: import_v412.z.string(),
2011
- start: import_v412.z.number(),
2012
- end: import_v412.z.number()
1885
+ var openaiTranscriptionResponseSchema = import_v410.z.object({
1886
+ text: import_v410.z.string(),
1887
+ language: import_v410.z.string().nullish(),
1888
+ duration: import_v410.z.number().nullish(),
1889
+ words: import_v410.z.array(
1890
+ import_v410.z.object({
1891
+ word: import_v410.z.string(),
1892
+ start: import_v410.z.number(),
1893
+ end: import_v410.z.number()
2013
1894
  })
2014
1895
  ).nullish(),
2015
- segments: import_v412.z.array(
2016
- import_v412.z.object({
2017
- id: import_v412.z.number(),
2018
- seek: import_v412.z.number(),
2019
- start: import_v412.z.number(),
2020
- end: import_v412.z.number(),
2021
- text: import_v412.z.string(),
2022
- tokens: import_v412.z.array(import_v412.z.number()),
2023
- temperature: import_v412.z.number(),
2024
- avg_logprob: import_v412.z.number(),
2025
- compression_ratio: import_v412.z.number(),
2026
- no_speech_prob: import_v412.z.number()
1896
+ segments: import_v410.z.array(
1897
+ import_v410.z.object({
1898
+ id: import_v410.z.number(),
1899
+ seek: import_v410.z.number(),
1900
+ start: import_v410.z.number(),
1901
+ end: import_v410.z.number(),
1902
+ text: import_v410.z.string(),
1903
+ tokens: import_v410.z.array(import_v410.z.number()),
1904
+ temperature: import_v410.z.number(),
1905
+ avg_logprob: import_v410.z.number(),
1906
+ compression_ratio: import_v410.z.number(),
1907
+ no_speech_prob: import_v410.z.number()
2027
1908
  })
2028
1909
  ).nullish()
2029
1910
  });
2030
1911
 
2031
1912
  // src/speech/openai-speech-model.ts
2032
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
2033
- var import_v413 = require("zod/v4");
2034
- var OpenAIProviderOptionsSchema = import_v413.z.object({
2035
- instructions: import_v413.z.string().nullish(),
2036
- speed: import_v413.z.number().min(0.25).max(4).default(1).nullish()
1913
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1914
+ var import_v411 = require("zod/v4");
1915
+ var OpenAIProviderOptionsSchema = import_v411.z.object({
1916
+ instructions: import_v411.z.string().nullish(),
1917
+ speed: import_v411.z.number().min(0.25).max(4).default(1).nullish()
2037
1918
  });
2038
1919
  var OpenAISpeechModel = class {
2039
1920
  constructor(modelId, config) {
@@ -2054,7 +1935,7 @@ var OpenAISpeechModel = class {
2054
1935
  providerOptions
2055
1936
  }) {
2056
1937
  const warnings = [];
2057
- const openAIOptions = await (0, import_provider_utils10.parseProviderOptions)({
1938
+ const openAIOptions = await (0, import_provider_utils8.parseProviderOptions)({
2058
1939
  provider: "openai",
2059
1940
  providerOptions,
2060
1941
  schema: OpenAIProviderOptionsSchema
@@ -2107,15 +1988,15 @@ var OpenAISpeechModel = class {
2107
1988
  value: audio,
2108
1989
  responseHeaders,
2109
1990
  rawValue: rawResponse
2110
- } = await (0, import_provider_utils10.postJsonToApi)({
1991
+ } = await (0, import_provider_utils8.postJsonToApi)({
2111
1992
  url: this.config.url({
2112
1993
  path: "/audio/speech",
2113
1994
  modelId: this.modelId
2114
1995
  }),
2115
- headers: (0, import_provider_utils10.combineHeaders)(this.config.headers(), options.headers),
1996
+ headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2116
1997
  body: requestBody,
2117
1998
  failedResponseHandler: openaiFailedResponseHandler,
2118
- successfulResponseHandler: (0, import_provider_utils10.createBinaryResponseHandler)(),
1999
+ successfulResponseHandler: (0, import_provider_utils8.createBinaryResponseHandler)(),
2119
2000
  abortSignal: options.abortSignal,
2120
2001
  fetch: this.config.fetch
2121
2002
  });
@@ -2136,37 +2017,37 @@ var OpenAISpeechModel = class {
2136
2017
  };
2137
2018
 
2138
2019
  // src/responses/openai-responses-language-model.ts
2139
- var import_provider8 = require("@ai-sdk/provider");
2020
+ var import_provider8 = require("@zenning/provider");
2140
2021
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
2141
- var import_v417 = require("zod/v4");
2022
+ var import_v418 = require("zod/v4");
2142
2023
 
2143
- // src/responses/convert-to-openai-responses-messages.ts
2144
- var import_provider6 = require("@ai-sdk/provider");
2145
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2146
- var import_v414 = require("zod/v4");
2147
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2024
+ // src/responses/convert-to-openai-responses-input.ts
2025
+ var import_provider6 = require("@zenning/provider");
2026
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
2027
+ var import_v412 = require("zod/v4");
2148
2028
  function isFileId(data, prefixes) {
2149
2029
  if (!prefixes) return false;
2150
2030
  return prefixes.some((prefix) => data.startsWith(prefix));
2151
2031
  }
2152
- async function convertToOpenAIResponsesMessages({
2032
+ async function convertToOpenAIResponsesInput({
2153
2033
  prompt,
2154
2034
  systemMessageMode,
2155
- fileIdPrefixes
2035
+ fileIdPrefixes,
2036
+ store
2156
2037
  }) {
2157
2038
  var _a, _b, _c, _d, _e, _f;
2158
- const messages = [];
2039
+ const input = [];
2159
2040
  const warnings = [];
2160
2041
  for (const { role, content } of prompt) {
2161
2042
  switch (role) {
2162
2043
  case "system": {
2163
2044
  switch (systemMessageMode) {
2164
2045
  case "system": {
2165
- messages.push({ role: "system", content });
2046
+ input.push({ role: "system", content });
2166
2047
  break;
2167
2048
  }
2168
2049
  case "developer": {
2169
- messages.push({ role: "developer", content });
2050
+ input.push({ role: "developer", content });
2170
2051
  break;
2171
2052
  }
2172
2053
  case "remove": {
@@ -2186,7 +2067,7 @@ async function convertToOpenAIResponsesMessages({
2186
2067
  break;
2187
2068
  }
2188
2069
  case "user": {
2189
- messages.push({
2070
+ input.push({
2190
2071
  role: "user",
2191
2072
  content: content.map((part, index) => {
2192
2073
  var _a2, _b2, _c2;
@@ -2200,7 +2081,7 @@ async function convertToOpenAIResponsesMessages({
2200
2081
  return {
2201
2082
  type: "input_image",
2202
2083
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2203
- image_url: `data:${mediaType};base64,${(0, import_provider_utils12.convertToBase64)(part.data)}`
2084
+ image_url: `data:${mediaType};base64,${(0, import_provider_utils9.convertToBase64)(part.data)}`
2204
2085
  },
2205
2086
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2206
2087
  };
@@ -2215,7 +2096,7 @@ async function convertToOpenAIResponsesMessages({
2215
2096
  type: "input_file",
2216
2097
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2217
2098
  filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2218
- file_data: `data:application/pdf;base64,${(0, import_provider_utils12.convertToBase64)(part.data)}`
2099
+ file_data: `data:application/pdf;base64,${(0, import_provider_utils9.convertToBase64)(part.data)}`
2219
2100
  }
2220
2101
  };
2221
2102
  } else {
@@ -2231,10 +2112,11 @@ async function convertToOpenAIResponsesMessages({
2231
2112
  }
2232
2113
  case "assistant": {
2233
2114
  const reasoningMessages = {};
2115
+ const toolCallParts = {};
2234
2116
  for (const part of content) {
2235
2117
  switch (part.type) {
2236
2118
  case "text": {
2237
- messages.push({
2119
+ input.push({
2238
2120
  role: "assistant",
2239
2121
  content: [{ type: "output_text", text: part.text }],
2240
2122
  id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
@@ -2242,10 +2124,11 @@ async function convertToOpenAIResponsesMessages({
2242
2124
  break;
2243
2125
  }
2244
2126
  case "tool-call": {
2127
+ toolCallParts[part.toolCallId] = part;
2245
2128
  if (part.providerExecuted) {
2246
2129
  break;
2247
2130
  }
2248
- messages.push({
2131
+ input.push({
2249
2132
  type: "function_call",
2250
2133
  call_id: part.toolCallId,
2251
2134
  name: part.toolName,
@@ -2254,15 +2137,20 @@ async function convertToOpenAIResponsesMessages({
2254
2137
  });
2255
2138
  break;
2256
2139
  }
2140
+ // assistant tool result parts are from provider-executed tools:
2257
2141
  case "tool-result": {
2258
- warnings.push({
2259
- type: "other",
2260
- message: `tool result parts in assistant messages are not supported for OpenAI responses`
2261
- });
2142
+ if (store) {
2143
+ input.push({ type: "item_reference", id: part.toolCallId });
2144
+ } else {
2145
+ warnings.push({
2146
+ type: "other",
2147
+ message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
2148
+ });
2149
+ }
2262
2150
  break;
2263
2151
  }
2264
2152
  case "reasoning": {
2265
- const providerOptions = await (0, import_provider_utils11.parseProviderOptions)({
2153
+ const providerOptions = await (0, import_provider_utils9.parseProviderOptions)({
2266
2154
  provider: "openai",
2267
2155
  providerOptions: part.providerOptions,
2268
2156
  schema: openaiResponsesReasoningProviderOptionsSchema
@@ -2286,7 +2174,7 @@ async function convertToOpenAIResponsesMessages({
2286
2174
  encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2287
2175
  summary: summaryParts
2288
2176
  };
2289
- messages.push(reasoningMessages[reasoningId]);
2177
+ input.push(reasoningMessages[reasoningId]);
2290
2178
  } else {
2291
2179
  existingReasoningMessage.summary.push(...summaryParts);
2292
2180
  }
@@ -2317,7 +2205,7 @@ async function convertToOpenAIResponsesMessages({
2317
2205
  contentValue = JSON.stringify(output.value);
2318
2206
  break;
2319
2207
  }
2320
- messages.push({
2208
+ input.push({
2321
2209
  type: "function_call_output",
2322
2210
  call_id: part.toolCallId,
2323
2211
  output: contentValue
@@ -2331,11 +2219,11 @@ async function convertToOpenAIResponsesMessages({
2331
2219
  }
2332
2220
  }
2333
2221
  }
2334
- return { messages, warnings };
2222
+ return { input, warnings };
2335
2223
  }
2336
- var openaiResponsesReasoningProviderOptionsSchema = import_v414.z.object({
2337
- itemId: import_v414.z.string().nullish(),
2338
- reasoningEncryptedContent: import_v414.z.string().nullish()
2224
+ var openaiResponsesReasoningProviderOptionsSchema = import_v412.z.object({
2225
+ itemId: import_v412.z.string().nullish(),
2226
+ reasoningEncryptedContent: import_v412.z.string().nullish()
2339
2227
  });
2340
2228
 
2341
2229
  // src/responses/map-openai-responses-finish-reason.ts
@@ -2357,57 +2245,158 @@ function mapOpenAIResponseFinishReason({
2357
2245
  }
2358
2246
 
2359
2247
  // src/responses/openai-responses-prepare-tools.ts
2360
- var import_provider7 = require("@ai-sdk/provider");
2248
+ var import_provider7 = require("@zenning/provider");
2361
2249
 
2362
2250
  // src/tool/code-interpreter.ts
2363
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2364
- var import_v415 = require("zod/v4");
2365
- var codeInterpreterInputSchema = import_v415.z.object({
2366
- code: import_v415.z.string().nullish(),
2367
- containerId: import_v415.z.string()
2251
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
2252
+ var import_v413 = require("zod/v4");
2253
+ var codeInterpreterInputSchema = import_v413.z.object({
2254
+ code: import_v413.z.string().nullish(),
2255
+ containerId: import_v413.z.string()
2368
2256
  });
2369
- var codeInterpreterOutputSchema = import_v415.z.object({
2370
- outputs: import_v415.z.array(
2371
- import_v415.z.discriminatedUnion("type", [
2372
- import_v415.z.object({ type: import_v415.z.literal("logs"), logs: import_v415.z.string() }),
2373
- import_v415.z.object({ type: import_v415.z.literal("image"), url: import_v415.z.string() })
2257
+ var codeInterpreterOutputSchema = import_v413.z.object({
2258
+ outputs: import_v413.z.array(
2259
+ import_v413.z.discriminatedUnion("type", [
2260
+ import_v413.z.object({ type: import_v413.z.literal("logs"), logs: import_v413.z.string() }),
2261
+ import_v413.z.object({ type: import_v413.z.literal("image"), url: import_v413.z.string() })
2374
2262
  ])
2375
2263
  ).nullish()
2376
2264
  });
2377
- var codeInterpreterArgsSchema = import_v415.z.object({
2378
- container: import_v415.z.union([
2379
- import_v415.z.string(),
2380
- import_v415.z.object({
2381
- fileIds: import_v415.z.array(import_v415.z.string()).optional()
2265
+ var codeInterpreterArgsSchema = import_v413.z.object({
2266
+ container: import_v413.z.union([
2267
+ import_v413.z.string(),
2268
+ import_v413.z.object({
2269
+ fileIds: import_v413.z.array(import_v413.z.string()).optional()
2382
2270
  })
2383
2271
  ]).optional()
2384
2272
  });
2385
- var codeInterpreterToolFactory = (0, import_provider_utils13.createProviderDefinedToolFactoryWithOutputSchema)({
2273
+ var codeInterpreterToolFactory = (0, import_provider_utils10.createProviderDefinedToolFactoryWithOutputSchema)({
2386
2274
  id: "openai.code_interpreter",
2387
2275
  name: "code_interpreter",
2388
2276
  inputSchema: codeInterpreterInputSchema,
2389
2277
  outputSchema: codeInterpreterOutputSchema
2390
2278
  });
2391
2279
 
2280
+ // src/tool/file-search.ts
2281
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2282
+ var import_v414 = require("zod/v4");
2283
+ var comparisonFilterSchema = import_v414.z.object({
2284
+ key: import_v414.z.string(),
2285
+ type: import_v414.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
2286
+ value: import_v414.z.union([import_v414.z.string(), import_v414.z.number(), import_v414.z.boolean()])
2287
+ });
2288
+ var compoundFilterSchema = import_v414.z.object({
2289
+ type: import_v414.z.enum(["and", "or"]),
2290
+ filters: import_v414.z.array(
2291
+ import_v414.z.union([comparisonFilterSchema, import_v414.z.lazy(() => compoundFilterSchema)])
2292
+ )
2293
+ });
2294
+ var fileSearchArgsSchema = import_v414.z.object({
2295
+ vectorStoreIds: import_v414.z.array(import_v414.z.string()),
2296
+ maxNumResults: import_v414.z.number().optional(),
2297
+ ranking: import_v414.z.object({
2298
+ ranker: import_v414.z.string().optional(),
2299
+ scoreThreshold: import_v414.z.number().optional()
2300
+ }).optional(),
2301
+ filters: import_v414.z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
2302
+ });
2303
+ var fileSearchOutputSchema = import_v414.z.object({
2304
+ queries: import_v414.z.array(import_v414.z.string()),
2305
+ results: import_v414.z.array(
2306
+ import_v414.z.object({
2307
+ attributes: import_v414.z.record(import_v414.z.string(), import_v414.z.unknown()),
2308
+ fileId: import_v414.z.string(),
2309
+ filename: import_v414.z.string(),
2310
+ score: import_v414.z.number(),
2311
+ text: import_v414.z.string()
2312
+ })
2313
+ ).nullable()
2314
+ });
2315
+ var fileSearch = (0, import_provider_utils11.createProviderDefinedToolFactoryWithOutputSchema)({
2316
+ id: "openai.file_search",
2317
+ name: "file_search",
2318
+ inputSchema: import_v414.z.object({}),
2319
+ outputSchema: fileSearchOutputSchema
2320
+ });
2321
+
2392
2322
  // src/tool/web-search.ts
2393
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2394
- var import_v416 = require("zod/v4");
2395
- var webSearchArgsSchema = import_v416.z.object({
2396
- filters: import_v416.z.object({
2397
- allowedDomains: import_v416.z.array(import_v416.z.string()).optional()
2323
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2324
+ var import_v415 = require("zod/v4");
2325
+ var webSearchArgsSchema = import_v415.z.object({
2326
+ filters: import_v415.z.object({
2327
+ allowedDomains: import_v415.z.array(import_v415.z.string()).optional()
2398
2328
  }).optional(),
2329
+ searchContextSize: import_v415.z.enum(["low", "medium", "high"]).optional(),
2330
+ userLocation: import_v415.z.object({
2331
+ type: import_v415.z.literal("approximate"),
2332
+ country: import_v415.z.string().optional(),
2333
+ city: import_v415.z.string().optional(),
2334
+ region: import_v415.z.string().optional(),
2335
+ timezone: import_v415.z.string().optional()
2336
+ }).optional()
2337
+ });
2338
+ var webSearchToolFactory = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2339
+ id: "openai.web_search",
2340
+ name: "web_search",
2341
+ inputSchema: import_v415.z.object({
2342
+ action: import_v415.z.discriminatedUnion("type", [
2343
+ import_v415.z.object({
2344
+ type: import_v415.z.literal("search"),
2345
+ query: import_v415.z.string().nullish()
2346
+ }),
2347
+ import_v415.z.object({
2348
+ type: import_v415.z.literal("open_page"),
2349
+ url: import_v415.z.string()
2350
+ }),
2351
+ import_v415.z.object({
2352
+ type: import_v415.z.literal("find"),
2353
+ url: import_v415.z.string(),
2354
+ pattern: import_v415.z.string()
2355
+ })
2356
+ ]).nullish()
2357
+ })
2358
+ });
2359
+
2360
+ // src/tool/web-search-preview.ts
2361
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2362
+ var import_v416 = require("zod/v4");
2363
+ var webSearchPreviewArgsSchema = import_v416.z.object({
2364
+ /**
2365
+ * Search context size to use for the web search.
2366
+ * - high: Most comprehensive context, highest cost, slower response
2367
+ * - medium: Balanced context, cost, and latency (default)
2368
+ * - low: Least context, lowest cost, fastest response
2369
+ */
2399
2370
  searchContextSize: import_v416.z.enum(["low", "medium", "high"]).optional(),
2371
+ /**
2372
+ * User location information to provide geographically relevant search results.
2373
+ */
2400
2374
  userLocation: import_v416.z.object({
2375
+ /**
2376
+ * Type of location (always 'approximate')
2377
+ */
2401
2378
  type: import_v416.z.literal("approximate"),
2379
+ /**
2380
+ * Two-letter ISO country code (e.g., 'US', 'GB')
2381
+ */
2402
2382
  country: import_v416.z.string().optional(),
2383
+ /**
2384
+ * City name (free text, e.g., 'Minneapolis')
2385
+ */
2403
2386
  city: import_v416.z.string().optional(),
2387
+ /**
2388
+ * Region name (free text, e.g., 'Minnesota')
2389
+ */
2404
2390
  region: import_v416.z.string().optional(),
2391
+ /**
2392
+ * IANA timezone (e.g., 'America/Chicago')
2393
+ */
2405
2394
  timezone: import_v416.z.string().optional()
2406
2395
  }).optional()
2407
2396
  });
2408
- var webSearchToolFactory = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2409
- id: "openai.web_search",
2410
- name: "web_search",
2397
+ var webSearchPreview = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2398
+ id: "openai.web_search_preview",
2399
+ name: "web_search_preview",
2411
2400
  inputSchema: import_v416.z.object({
2412
2401
  action: import_v416.z.discriminatedUnion("type", [
2413
2402
  import_v416.z.object({
@@ -2427,6 +2416,33 @@ var webSearchToolFactory = (0, import_provider_utils14.createProviderDefinedTool
2427
2416
  })
2428
2417
  });
2429
2418
 
2419
+ // src/tool/image-generation.ts
2420
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2421
+ var import_v417 = require("zod/v4");
2422
+ var imageGenerationArgsSchema = import_v417.z.object({
2423
+ background: import_v417.z.enum(["auto", "opaque", "transparent"]).optional(),
2424
+ inputFidelity: import_v417.z.enum(["low", "high"]).optional(),
2425
+ inputImageMask: import_v417.z.object({
2426
+ fileId: import_v417.z.string().optional(),
2427
+ imageUrl: import_v417.z.string().optional()
2428
+ }).optional(),
2429
+ model: import_v417.z.string().optional(),
2430
+ moderation: import_v417.z.enum(["auto"]).optional(),
2431
+ outputCompression: import_v417.z.number().int().min(0).max(100).optional(),
2432
+ outputFormat: import_v417.z.enum(["png", "jpeg", "webp"]).optional(),
2433
+ quality: import_v417.z.enum(["auto", "low", "medium", "high"]).optional(),
2434
+ size: import_v417.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2435
+ }).strict();
2436
+ var imageGenerationOutputSchema = import_v417.z.object({
2437
+ result: import_v417.z.string()
2438
+ });
2439
+ var imageGenerationToolFactory = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
2440
+ id: "openai.image_generation",
2441
+ name: "image_generation",
2442
+ inputSchema: import_v417.z.object({}),
2443
+ outputSchema: imageGenerationOutputSchema
2444
+ });
2445
+
2430
2446
  // src/responses/openai-responses-prepare-tools.ts
2431
2447
  function prepareResponsesTools({
2432
2448
  tools,
@@ -2458,7 +2474,10 @@ function prepareResponsesTools({
2458
2474
  type: "file_search",
2459
2475
  vector_store_ids: args.vectorStoreIds,
2460
2476
  max_num_results: args.maxNumResults,
2461
- ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
2477
+ ranking_options: args.ranking ? {
2478
+ ranker: args.ranking.ranker,
2479
+ score_threshold: args.ranking.scoreThreshold
2480
+ } : void 0,
2462
2481
  filters: args.filters
2463
2482
  });
2464
2483
  break;
@@ -2490,8 +2509,23 @@ function prepareResponsesTools({
2490
2509
  });
2491
2510
  break;
2492
2511
  }
2493
- default: {
2494
- toolWarnings.push({ type: "unsupported-tool", tool });
2512
+ case "openai.image_generation": {
2513
+ const args = imageGenerationArgsSchema.parse(tool.args);
2514
+ openaiTools.push({
2515
+ type: "image_generation",
2516
+ background: args.background,
2517
+ input_fidelity: args.inputFidelity,
2518
+ input_image_mask: args.inputImageMask ? {
2519
+ file_id: args.inputImageMask.fileId,
2520
+ image_url: args.inputImageMask.imageUrl
2521
+ } : void 0,
2522
+ model: args.model,
2523
+ size: args.size,
2524
+ quality: args.quality,
2525
+ moderation: args.moderation,
2526
+ output_format: args.outputFormat,
2527
+ output_compression: args.outputCompression
2528
+ });
2495
2529
  break;
2496
2530
  }
2497
2531
  }
@@ -2514,7 +2548,7 @@ function prepareResponsesTools({
2514
2548
  case "tool":
2515
2549
  return {
2516
2550
  tools: openaiTools,
2517
- 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 },
2551
+ 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 },
2518
2552
  toolWarnings
2519
2553
  };
2520
2554
  default: {
@@ -2527,47 +2561,66 @@ function prepareResponsesTools({
2527
2561
  }
2528
2562
 
2529
2563
  // src/responses/openai-responses-language-model.ts
2530
- var webSearchCallItem = import_v417.z.object({
2531
- type: import_v417.z.literal("web_search_call"),
2532
- id: import_v417.z.string(),
2533
- status: import_v417.z.string(),
2534
- action: import_v417.z.discriminatedUnion("type", [
2535
- import_v417.z.object({
2536
- type: import_v417.z.literal("search"),
2537
- query: import_v417.z.string().nullish()
2564
+ var webSearchCallItem = import_v418.z.object({
2565
+ type: import_v418.z.literal("web_search_call"),
2566
+ id: import_v418.z.string(),
2567
+ status: import_v418.z.string(),
2568
+ action: import_v418.z.discriminatedUnion("type", [
2569
+ import_v418.z.object({
2570
+ type: import_v418.z.literal("search"),
2571
+ query: import_v418.z.string().nullish()
2538
2572
  }),
2539
- import_v417.z.object({
2540
- type: import_v417.z.literal("open_page"),
2541
- url: import_v417.z.string()
2573
+ import_v418.z.object({
2574
+ type: import_v418.z.literal("open_page"),
2575
+ url: import_v418.z.string()
2542
2576
  }),
2543
- import_v417.z.object({
2544
- type: import_v417.z.literal("find"),
2545
- url: import_v417.z.string(),
2546
- pattern: import_v417.z.string()
2577
+ import_v418.z.object({
2578
+ type: import_v418.z.literal("find"),
2579
+ url: import_v418.z.string(),
2580
+ pattern: import_v418.z.string()
2547
2581
  })
2548
2582
  ]).nullish()
2549
2583
  });
2550
- var codeInterpreterCallItem = import_v417.z.object({
2551
- type: import_v417.z.literal("code_interpreter_call"),
2552
- id: import_v417.z.string(),
2553
- code: import_v417.z.string().nullable(),
2554
- container_id: import_v417.z.string(),
2555
- outputs: import_v417.z.array(
2556
- import_v417.z.discriminatedUnion("type", [
2557
- import_v417.z.object({ type: import_v417.z.literal("logs"), logs: import_v417.z.string() }),
2558
- import_v417.z.object({ type: import_v417.z.literal("image"), url: import_v417.z.string() })
2584
+ var fileSearchCallItem = import_v418.z.object({
2585
+ type: import_v418.z.literal("file_search_call"),
2586
+ id: import_v418.z.string(),
2587
+ queries: import_v418.z.array(import_v418.z.string()),
2588
+ results: import_v418.z.array(
2589
+ import_v418.z.object({
2590
+ attributes: import_v418.z.record(import_v418.z.string(), import_v418.z.unknown()),
2591
+ file_id: import_v418.z.string(),
2592
+ filename: import_v418.z.string(),
2593
+ score: import_v418.z.number(),
2594
+ text: import_v418.z.string()
2595
+ })
2596
+ ).nullish()
2597
+ });
2598
+ var codeInterpreterCallItem = import_v418.z.object({
2599
+ type: import_v418.z.literal("code_interpreter_call"),
2600
+ id: import_v418.z.string(),
2601
+ code: import_v418.z.string().nullable(),
2602
+ container_id: import_v418.z.string(),
2603
+ outputs: import_v418.z.array(
2604
+ import_v418.z.discriminatedUnion("type", [
2605
+ import_v418.z.object({ type: import_v418.z.literal("logs"), logs: import_v418.z.string() }),
2606
+ import_v418.z.object({ type: import_v418.z.literal("image"), url: import_v418.z.string() })
2559
2607
  ])
2560
2608
  ).nullable()
2561
2609
  });
2610
+ var imageGenerationCallItem = import_v418.z.object({
2611
+ type: import_v418.z.literal("image_generation_call"),
2612
+ id: import_v418.z.string(),
2613
+ result: import_v418.z.string()
2614
+ });
2562
2615
  var TOP_LOGPROBS_MAX = 20;
2563
- var LOGPROBS_SCHEMA = import_v417.z.array(
2564
- import_v417.z.object({
2565
- token: import_v417.z.string(),
2566
- logprob: import_v417.z.number(),
2567
- top_logprobs: import_v417.z.array(
2568
- import_v417.z.object({
2569
- token: import_v417.z.string(),
2570
- logprob: import_v417.z.number()
2616
+ var LOGPROBS_SCHEMA = import_v418.z.array(
2617
+ import_v418.z.object({
2618
+ token: import_v418.z.string(),
2619
+ logprob: import_v418.z.number(),
2620
+ top_logprobs: import_v418.z.array(
2621
+ import_v418.z.object({
2622
+ token: import_v418.z.string(),
2623
+ logprob: import_v418.z.number()
2571
2624
  })
2572
2625
  )
2573
2626
  })
@@ -2624,32 +2677,44 @@ var OpenAIResponsesLanguageModel = class {
2624
2677
  if (stopSequences != null) {
2625
2678
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2626
2679
  }
2627
- const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
2628
- prompt,
2629
- systemMessageMode: modelConfig.systemMessageMode,
2630
- fileIdPrefixes: this.config.fileIdPrefixes
2631
- });
2632
- warnings.push(...messageWarnings);
2633
2680
  const openaiOptions = await (0, import_provider_utils15.parseProviderOptions)({
2634
2681
  provider: "openai",
2635
2682
  providerOptions,
2636
2683
  schema: openaiResponsesProviderOptionsSchema
2637
2684
  });
2638
- const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2685
+ const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2686
+ prompt,
2687
+ systemMessageMode: modelConfig.systemMessageMode,
2688
+ fileIdPrefixes: this.config.fileIdPrefixes,
2689
+ store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
2690
+ });
2691
+ warnings.push(...inputWarnings);
2692
+ const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
2639
2693
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
2694
+ function addInclude(key) {
2695
+ include = include != null ? [...include, key] : [key];
2696
+ }
2697
+ function hasOpenAITool(id) {
2698
+ return (tools == null ? void 0 : tools.find(
2699
+ (tool) => tool.type === "provider-defined" && tool.id === id
2700
+ )) != null;
2701
+ }
2640
2702
  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;
2641
- include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2642
- const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2703
+ if (topLogprobs) {
2704
+ addInclude("message.output_text.logprobs");
2705
+ }
2706
+ const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
2643
2707
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2644
- )) == null ? void 0 : _b.name;
2645
- include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2646
- const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2647
- (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2648
2708
  )) == null ? void 0 : _c.name;
2649
- include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2709
+ if (webSearchToolName) {
2710
+ addInclude("web_search_call.action.sources");
2711
+ }
2712
+ if (hasOpenAITool("openai.code_interpreter")) {
2713
+ addInclude("code_interpreter_call.outputs");
2714
+ }
2650
2715
  const baseArgs = {
2651
2716
  model: this.modelId,
2652
- input: messages,
2717
+ input,
2653
2718
  temperature,
2654
2719
  top_p: topP,
2655
2720
  max_output_tokens: maxOutputTokens,
@@ -2670,6 +2735,7 @@ var OpenAIResponsesLanguageModel = class {
2670
2735
  }
2671
2736
  },
2672
2737
  // provider options:
2738
+ max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
2673
2739
  metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
2674
2740
  parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
2675
2741
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
@@ -2765,7 +2831,7 @@ var OpenAIResponsesLanguageModel = class {
2765
2831
  };
2766
2832
  }
2767
2833
  async doGenerate(options) {
2768
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2834
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2769
2835
  const {
2770
2836
  args: body,
2771
2837
  warnings,
@@ -2785,96 +2851,82 @@ var OpenAIResponsesLanguageModel = class {
2785
2851
  body,
2786
2852
  failedResponseHandler: openaiFailedResponseHandler,
2787
2853
  successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
2788
- import_v417.z.object({
2789
- id: import_v417.z.string(),
2790
- created_at: import_v417.z.number(),
2791
- error: import_v417.z.object({
2792
- code: import_v417.z.string(),
2793
- message: import_v417.z.string()
2854
+ import_v418.z.object({
2855
+ id: import_v418.z.string(),
2856
+ created_at: import_v418.z.number(),
2857
+ error: import_v418.z.object({
2858
+ code: import_v418.z.string(),
2859
+ message: import_v418.z.string()
2794
2860
  }).nullish(),
2795
- model: import_v417.z.string(),
2796
- output: import_v417.z.array(
2797
- import_v417.z.discriminatedUnion("type", [
2798
- import_v417.z.object({
2799
- type: import_v417.z.literal("message"),
2800
- role: import_v417.z.literal("assistant"),
2801
- id: import_v417.z.string(),
2802
- content: import_v417.z.array(
2803
- import_v417.z.object({
2804
- type: import_v417.z.literal("output_text"),
2805
- text: import_v417.z.string(),
2861
+ model: import_v418.z.string(),
2862
+ output: import_v418.z.array(
2863
+ import_v418.z.discriminatedUnion("type", [
2864
+ import_v418.z.object({
2865
+ type: import_v418.z.literal("message"),
2866
+ role: import_v418.z.literal("assistant"),
2867
+ id: import_v418.z.string(),
2868
+ content: import_v418.z.array(
2869
+ import_v418.z.object({
2870
+ type: import_v418.z.literal("output_text"),
2871
+ text: import_v418.z.string(),
2806
2872
  logprobs: LOGPROBS_SCHEMA.nullish(),
2807
- annotations: import_v417.z.array(
2808
- import_v417.z.discriminatedUnion("type", [
2809
- import_v417.z.object({
2810
- type: import_v417.z.literal("url_citation"),
2811
- start_index: import_v417.z.number(),
2812
- end_index: import_v417.z.number(),
2813
- url: import_v417.z.string(),
2814
- title: import_v417.z.string()
2873
+ annotations: import_v418.z.array(
2874
+ import_v418.z.discriminatedUnion("type", [
2875
+ import_v418.z.object({
2876
+ type: import_v418.z.literal("url_citation"),
2877
+ start_index: import_v418.z.number(),
2878
+ end_index: import_v418.z.number(),
2879
+ url: import_v418.z.string(),
2880
+ title: import_v418.z.string()
2815
2881
  }),
2816
- import_v417.z.object({
2817
- type: import_v417.z.literal("file_citation"),
2818
- file_id: import_v417.z.string(),
2819
- filename: import_v417.z.string().nullish(),
2820
- index: import_v417.z.number().nullish(),
2821
- start_index: import_v417.z.number().nullish(),
2822
- end_index: import_v417.z.number().nullish(),
2823
- quote: import_v417.z.string().nullish()
2882
+ import_v418.z.object({
2883
+ type: import_v418.z.literal("file_citation"),
2884
+ file_id: import_v418.z.string(),
2885
+ filename: import_v418.z.string().nullish(),
2886
+ index: import_v418.z.number().nullish(),
2887
+ start_index: import_v418.z.number().nullish(),
2888
+ end_index: import_v418.z.number().nullish(),
2889
+ quote: import_v418.z.string().nullish()
2824
2890
  }),
2825
- import_v417.z.object({
2826
- type: import_v417.z.literal("container_file_citation")
2891
+ import_v418.z.object({
2892
+ type: import_v418.z.literal("container_file_citation")
2827
2893
  })
2828
2894
  ])
2829
2895
  )
2830
2896
  })
2831
2897
  )
2832
2898
  }),
2833
- codeInterpreterCallItem,
2834
- import_v417.z.object({
2835
- type: import_v417.z.literal("function_call"),
2836
- call_id: import_v417.z.string(),
2837
- name: import_v417.z.string(),
2838
- arguments: import_v417.z.string(),
2839
- id: import_v417.z.string()
2840
- }),
2841
2899
  webSearchCallItem,
2842
- import_v417.z.object({
2843
- type: import_v417.z.literal("computer_call"),
2844
- id: import_v417.z.string(),
2845
- status: import_v417.z.string().optional()
2900
+ fileSearchCallItem,
2901
+ codeInterpreterCallItem,
2902
+ imageGenerationCallItem,
2903
+ import_v418.z.object({
2904
+ type: import_v418.z.literal("function_call"),
2905
+ call_id: import_v418.z.string(),
2906
+ name: import_v418.z.string(),
2907
+ arguments: import_v418.z.string(),
2908
+ id: import_v418.z.string()
2846
2909
  }),
2847
- import_v417.z.object({
2848
- type: import_v417.z.literal("file_search_call"),
2849
- id: import_v417.z.string(),
2850
- status: import_v417.z.string().optional(),
2851
- queries: import_v417.z.array(import_v417.z.string()).nullish(),
2852
- results: import_v417.z.array(
2853
- import_v417.z.object({
2854
- attributes: import_v417.z.object({
2855
- file_id: import_v417.z.string(),
2856
- filename: import_v417.z.string(),
2857
- score: import_v417.z.number(),
2858
- text: import_v417.z.string()
2859
- })
2860
- })
2861
- ).nullish()
2910
+ import_v418.z.object({
2911
+ type: import_v418.z.literal("computer_call"),
2912
+ id: import_v418.z.string(),
2913
+ status: import_v418.z.string().optional()
2862
2914
  }),
2863
- import_v417.z.object({
2864
- type: import_v417.z.literal("reasoning"),
2865
- id: import_v417.z.string(),
2866
- encrypted_content: import_v417.z.string().nullish(),
2867
- summary: import_v417.z.array(
2868
- import_v417.z.object({
2869
- type: import_v417.z.literal("summary_text"),
2870
- text: import_v417.z.string()
2915
+ import_v418.z.object({
2916
+ type: import_v418.z.literal("reasoning"),
2917
+ id: import_v418.z.string(),
2918
+ encrypted_content: import_v418.z.string().nullish(),
2919
+ summary: import_v418.z.array(
2920
+ import_v418.z.object({
2921
+ type: import_v418.z.literal("summary_text"),
2922
+ text: import_v418.z.string()
2871
2923
  })
2872
2924
  )
2873
2925
  })
2874
2926
  ])
2875
2927
  ),
2876
- service_tier: import_v417.z.string().nullish(),
2877
- incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullable(),
2928
+ service_tier: import_v418.z.string().nullish(),
2929
+ incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullable(),
2878
2930
  usage: usageSchema2
2879
2931
  })
2880
2932
  ),
@@ -2915,6 +2967,25 @@ var OpenAIResponsesLanguageModel = class {
2915
2967
  }
2916
2968
  break;
2917
2969
  }
2970
+ case "image_generation_call": {
2971
+ content.push({
2972
+ type: "tool-call",
2973
+ toolCallId: part.id,
2974
+ toolName: "image_generation",
2975
+ input: "{}",
2976
+ providerExecuted: true
2977
+ });
2978
+ content.push({
2979
+ type: "tool-result",
2980
+ toolCallId: part.id,
2981
+ toolName: "image_generation",
2982
+ result: {
2983
+ result: part.result
2984
+ },
2985
+ providerExecuted: true
2986
+ });
2987
+ break;
2988
+ }
2918
2989
  case "message": {
2919
2990
  for (const contentPart of part.content) {
2920
2991
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
@@ -2945,7 +3016,10 @@ var OpenAIResponsesLanguageModel = class {
2945
3016
  id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils15.generateId)(),
2946
3017
  mediaType: "text/plain",
2947
3018
  title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
2948
- filename: (_l = annotation.filename) != null ? _l : annotation.file_id
3019
+ filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
3020
+ fileId: annotation.file_id,
3021
+ startIndex: (_m = annotation.start_index) != null ? _m : void 0,
3022
+ endIndex: (_n = annotation.end_index) != null ? _n : void 0
2949
3023
  });
2950
3024
  }
2951
3025
  }
@@ -3009,7 +3083,7 @@ var OpenAIResponsesLanguageModel = class {
3009
3083
  type: "tool-call",
3010
3084
  toolCallId: part.id,
3011
3085
  toolName: "file_search",
3012
- input: "",
3086
+ input: "{}",
3013
3087
  providerExecuted: true
3014
3088
  });
3015
3089
  content.push({
@@ -3017,10 +3091,14 @@ var OpenAIResponsesLanguageModel = class {
3017
3091
  toolCallId: part.id,
3018
3092
  toolName: "file_search",
3019
3093
  result: {
3020
- type: "file_search_tool_result",
3021
- status: part.status || "completed",
3022
- ...part.queries && { queries: part.queries },
3023
- ...part.results && { results: part.results }
3094
+ queries: part.queries,
3095
+ results: (_p = (_o = part.results) == null ? void 0 : _o.map((result) => ({
3096
+ attributes: result.attributes,
3097
+ fileId: result.file_id,
3098
+ filename: result.filename,
3099
+ score: result.score,
3100
+ text: result.text
3101
+ }))) != null ? _p : null
3024
3102
  },
3025
3103
  providerExecuted: true
3026
3104
  });
@@ -3062,15 +3140,15 @@ var OpenAIResponsesLanguageModel = class {
3062
3140
  return {
3063
3141
  content,
3064
3142
  finishReason: mapOpenAIResponseFinishReason({
3065
- finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
3143
+ finishReason: (_q = response.incomplete_details) == null ? void 0 : _q.reason,
3066
3144
  hasFunctionCall
3067
3145
  }),
3068
3146
  usage: {
3069
3147
  inputTokens: response.usage.input_tokens,
3070
3148
  outputTokens: response.usage.output_tokens,
3071
3149
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
3072
- reasoningTokens: (_o = (_n = response.usage.output_tokens_details) == null ? void 0 : _n.reasoning_tokens) != null ? _o : void 0,
3073
- cachedInputTokens: (_q = (_p = response.usage.input_tokens_details) == null ? void 0 : _p.cached_tokens) != null ? _q : void 0
3150
+ reasoningTokens: (_s = (_r = response.usage.output_tokens_details) == null ? void 0 : _r.reasoning_tokens) != null ? _s : void 0,
3151
+ cachedInputTokens: (_u = (_t = response.usage.input_tokens_details) == null ? void 0 : _t.cached_tokens) != null ? _u : void 0
3074
3152
  },
3075
3153
  request: { body },
3076
3154
  response: {
@@ -3127,7 +3205,7 @@ var OpenAIResponsesLanguageModel = class {
3127
3205
  controller.enqueue({ type: "stream-start", warnings });
3128
3206
  },
3129
3207
  transform(chunk, controller) {
3130
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
3208
+ 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;
3131
3209
  if (options.includeRawChunks) {
3132
3210
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3133
3211
  }
@@ -3169,14 +3247,20 @@ var OpenAIResponsesLanguageModel = class {
3169
3247
  toolName: "computer_use"
3170
3248
  });
3171
3249
  } else if (value.item.type === "file_search_call") {
3172
- ongoingToolCalls[value.output_index] = {
3250
+ controller.enqueue({
3251
+ type: "tool-call",
3252
+ toolCallId: value.item.id,
3173
3253
  toolName: "file_search",
3174
- toolCallId: value.item.id
3175
- };
3254
+ input: "{}",
3255
+ providerExecuted: true
3256
+ });
3257
+ } else if (value.item.type === "image_generation_call") {
3176
3258
  controller.enqueue({
3177
- type: "tool-input-start",
3178
- id: value.item.id,
3179
- toolName: "file_search"
3259
+ type: "tool-call",
3260
+ toolCallId: value.item.id,
3261
+ toolName: "image_generation",
3262
+ input: "{}",
3263
+ providerExecuted: true
3180
3264
  });
3181
3265
  } else if (value.item.type === "message") {
3182
3266
  controller.enqueue({
@@ -3268,26 +3352,19 @@ var OpenAIResponsesLanguageModel = class {
3268
3352
  });
3269
3353
  } else if (value.item.type === "file_search_call") {
3270
3354
  ongoingToolCalls[value.output_index] = void 0;
3271
- controller.enqueue({
3272
- type: "tool-input-end",
3273
- id: value.item.id
3274
- });
3275
- controller.enqueue({
3276
- type: "tool-call",
3277
- toolCallId: value.item.id,
3278
- toolName: "file_search",
3279
- input: "",
3280
- providerExecuted: true
3281
- });
3282
3355
  controller.enqueue({
3283
3356
  type: "tool-result",
3284
3357
  toolCallId: value.item.id,
3285
3358
  toolName: "file_search",
3286
3359
  result: {
3287
- type: "file_search_tool_result",
3288
- status: value.item.status || "completed",
3289
- ...value.item.queries && { queries: value.item.queries },
3290
- ...value.item.results && { results: value.item.results }
3360
+ queries: value.item.queries,
3361
+ results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
3362
+ attributes: result.attributes,
3363
+ fileId: result.file_id,
3364
+ filename: result.filename,
3365
+ score: result.score,
3366
+ text: result.text
3367
+ }))) != null ? _c : null
3291
3368
  },
3292
3369
  providerExecuted: true
3293
3370
  });
@@ -3311,6 +3388,16 @@ var OpenAIResponsesLanguageModel = class {
3311
3388
  },
3312
3389
  providerExecuted: true
3313
3390
  });
3391
+ } else if (value.item.type === "image_generation_call") {
3392
+ controller.enqueue({
3393
+ type: "tool-result",
3394
+ toolCallId: value.item.id,
3395
+ toolName: "image_generation",
3396
+ result: {
3397
+ result: value.item.result
3398
+ },
3399
+ providerExecuted: true
3400
+ });
3314
3401
  } else if (value.item.type === "message") {
3315
3402
  controller.enqueue({
3316
3403
  type: "text-end",
@@ -3325,7 +3412,7 @@ var OpenAIResponsesLanguageModel = class {
3325
3412
  providerMetadata: {
3326
3413
  openai: {
3327
3414
  itemId: value.item.id,
3328
- reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
3415
+ reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
3329
3416
  }
3330
3417
  }
3331
3418
  });
@@ -3355,12 +3442,12 @@ var OpenAIResponsesLanguageModel = class {
3355
3442
  id: value.item_id,
3356
3443
  delta: value.delta
3357
3444
  });
3358
- if (((_d = (_c = options.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.logprobs) && value.logprobs) {
3445
+ if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
3359
3446
  logprobs.push(value.logprobs);
3360
3447
  }
3361
3448
  } else if (isResponseReasoningSummaryPartAddedChunk(value)) {
3362
3449
  if (value.summary_index > 0) {
3363
- (_e = activeReasoning[value.item_id]) == null ? void 0 : _e.summaryParts.push(
3450
+ (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.summaryParts.push(
3364
3451
  value.summary_index
3365
3452
  );
3366
3453
  controller.enqueue({
@@ -3369,7 +3456,7 @@ var OpenAIResponsesLanguageModel = class {
3369
3456
  providerMetadata: {
3370
3457
  openai: {
3371
3458
  itemId: value.item_id,
3372
- reasoningEncryptedContent: (_g = (_f = activeReasoning[value.item_id]) == null ? void 0 : _f.encryptedContent) != null ? _g : null
3459
+ reasoningEncryptedContent: (_i = (_h = activeReasoning[value.item_id]) == null ? void 0 : _h.encryptedContent) != null ? _i : null
3373
3460
  }
3374
3461
  }
3375
3462
  });
@@ -3387,14 +3474,14 @@ var OpenAIResponsesLanguageModel = class {
3387
3474
  });
3388
3475
  } else if (isResponseFinishedChunk(value)) {
3389
3476
  finishReason = mapOpenAIResponseFinishReason({
3390
- finishReason: (_h = value.response.incomplete_details) == null ? void 0 : _h.reason,
3477
+ finishReason: (_j = value.response.incomplete_details) == null ? void 0 : _j.reason,
3391
3478
  hasFunctionCall
3392
3479
  });
3393
3480
  usage.inputTokens = value.response.usage.input_tokens;
3394
3481
  usage.outputTokens = value.response.usage.output_tokens;
3395
3482
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
3396
- usage.reasoningTokens = (_j = (_i = value.response.usage.output_tokens_details) == null ? void 0 : _i.reasoning_tokens) != null ? _j : void 0;
3397
- usage.cachedInputTokens = (_l = (_k = value.response.usage.input_tokens_details) == null ? void 0 : _k.cached_tokens) != null ? _l : void 0;
3483
+ usage.reasoningTokens = (_l = (_k = value.response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0;
3484
+ usage.cachedInputTokens = (_n = (_m = value.response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0;
3398
3485
  if (typeof value.response.service_tier === "string") {
3399
3486
  serviceTier = value.response.service_tier;
3400
3487
  }
@@ -3403,7 +3490,7 @@ var OpenAIResponsesLanguageModel = class {
3403
3490
  controller.enqueue({
3404
3491
  type: "source",
3405
3492
  sourceType: "url",
3406
- id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils15.generateId)(),
3493
+ id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils15.generateId)(),
3407
3494
  url: value.annotation.url,
3408
3495
  title: value.annotation.title
3409
3496
  });
@@ -3411,10 +3498,13 @@ var OpenAIResponsesLanguageModel = class {
3411
3498
  controller.enqueue({
3412
3499
  type: "source",
3413
3500
  sourceType: "document",
3414
- id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils15.generateId)(),
3501
+ id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils15.generateId)(),
3415
3502
  mediaType: "text/plain",
3416
- title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
3417
- filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
3503
+ title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
3504
+ filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id,
3505
+ fileId: value.annotation.file_id,
3506
+ startIndex: (_x = value.annotation.start_index) != null ? _x : void 0,
3507
+ endIndex: (_y = value.annotation.end_index) != null ? _y : void 0
3418
3508
  });
3419
3509
  }
3420
3510
  } else if (isErrorChunk(value)) {
@@ -3447,177 +3537,155 @@ var OpenAIResponsesLanguageModel = class {
3447
3537
  };
3448
3538
  }
3449
3539
  };
3450
- var usageSchema2 = import_v417.z.object({
3451
- input_tokens: import_v417.z.number(),
3452
- input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
3453
- output_tokens: import_v417.z.number(),
3454
- output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
3540
+ var usageSchema2 = import_v418.z.object({
3541
+ input_tokens: import_v418.z.number(),
3542
+ input_tokens_details: import_v418.z.object({ cached_tokens: import_v418.z.number().nullish() }).nullish(),
3543
+ output_tokens: import_v418.z.number(),
3544
+ output_tokens_details: import_v418.z.object({ reasoning_tokens: import_v418.z.number().nullish() }).nullish()
3455
3545
  });
3456
- var textDeltaChunkSchema = import_v417.z.object({
3457
- type: import_v417.z.literal("response.output_text.delta"),
3458
- item_id: import_v417.z.string(),
3459
- delta: import_v417.z.string(),
3546
+ var textDeltaChunkSchema = import_v418.z.object({
3547
+ type: import_v418.z.literal("response.output_text.delta"),
3548
+ item_id: import_v418.z.string(),
3549
+ delta: import_v418.z.string(),
3460
3550
  logprobs: LOGPROBS_SCHEMA.nullish()
3461
3551
  });
3462
- var errorChunkSchema = import_v417.z.object({
3463
- type: import_v417.z.literal("error"),
3464
- code: import_v417.z.string(),
3465
- message: import_v417.z.string(),
3466
- param: import_v417.z.string().nullish(),
3467
- sequence_number: import_v417.z.number()
3552
+ var errorChunkSchema = import_v418.z.object({
3553
+ type: import_v418.z.literal("error"),
3554
+ code: import_v418.z.string(),
3555
+ message: import_v418.z.string(),
3556
+ param: import_v418.z.string().nullish(),
3557
+ sequence_number: import_v418.z.number()
3468
3558
  });
3469
- var responseFinishedChunkSchema = import_v417.z.object({
3470
- type: import_v417.z.enum(["response.completed", "response.incomplete"]),
3471
- response: import_v417.z.object({
3472
- incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
3559
+ var responseFinishedChunkSchema = import_v418.z.object({
3560
+ type: import_v418.z.enum(["response.completed", "response.incomplete"]),
3561
+ response: import_v418.z.object({
3562
+ incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullish(),
3473
3563
  usage: usageSchema2,
3474
- service_tier: import_v417.z.string().nullish()
3564
+ service_tier: import_v418.z.string().nullish()
3475
3565
  })
3476
3566
  });
3477
- var responseCreatedChunkSchema = import_v417.z.object({
3478
- type: import_v417.z.literal("response.created"),
3479
- response: import_v417.z.object({
3480
- id: import_v417.z.string(),
3481
- created_at: import_v417.z.number(),
3482
- model: import_v417.z.string(),
3483
- service_tier: import_v417.z.string().nullish()
3567
+ var responseCreatedChunkSchema = import_v418.z.object({
3568
+ type: import_v418.z.literal("response.created"),
3569
+ response: import_v418.z.object({
3570
+ id: import_v418.z.string(),
3571
+ created_at: import_v418.z.number(),
3572
+ model: import_v418.z.string(),
3573
+ service_tier: import_v418.z.string().nullish()
3484
3574
  })
3485
3575
  });
3486
- var responseOutputItemAddedSchema = import_v417.z.object({
3487
- type: import_v417.z.literal("response.output_item.added"),
3488
- output_index: import_v417.z.number(),
3489
- item: import_v417.z.discriminatedUnion("type", [
3490
- import_v417.z.object({
3491
- type: import_v417.z.literal("message"),
3492
- id: import_v417.z.string()
3576
+ var responseOutputItemAddedSchema = import_v418.z.object({
3577
+ type: import_v418.z.literal("response.output_item.added"),
3578
+ output_index: import_v418.z.number(),
3579
+ item: import_v418.z.discriminatedUnion("type", [
3580
+ import_v418.z.object({
3581
+ type: import_v418.z.literal("message"),
3582
+ id: import_v418.z.string()
3493
3583
  }),
3494
- import_v417.z.object({
3495
- type: import_v417.z.literal("reasoning"),
3496
- id: import_v417.z.string(),
3497
- encrypted_content: import_v417.z.string().nullish()
3584
+ import_v418.z.object({
3585
+ type: import_v418.z.literal("reasoning"),
3586
+ id: import_v418.z.string(),
3587
+ encrypted_content: import_v418.z.string().nullish()
3498
3588
  }),
3499
- import_v417.z.object({
3500
- type: import_v417.z.literal("function_call"),
3501
- id: import_v417.z.string(),
3502
- call_id: import_v417.z.string(),
3503
- name: import_v417.z.string(),
3504
- arguments: import_v417.z.string()
3589
+ import_v418.z.object({
3590
+ type: import_v418.z.literal("function_call"),
3591
+ id: import_v418.z.string(),
3592
+ call_id: import_v418.z.string(),
3593
+ name: import_v418.z.string(),
3594
+ arguments: import_v418.z.string()
3505
3595
  }),
3506
- import_v417.z.object({
3507
- type: import_v417.z.literal("web_search_call"),
3508
- id: import_v417.z.string(),
3509
- status: import_v417.z.string(),
3510
- action: import_v417.z.object({
3511
- type: import_v417.z.literal("search"),
3512
- query: import_v417.z.string().optional()
3596
+ import_v418.z.object({
3597
+ type: import_v418.z.literal("web_search_call"),
3598
+ id: import_v418.z.string(),
3599
+ status: import_v418.z.string(),
3600
+ action: import_v418.z.object({
3601
+ type: import_v418.z.literal("search"),
3602
+ query: import_v418.z.string().optional()
3513
3603
  }).nullish()
3514
3604
  }),
3515
- import_v417.z.object({
3516
- type: import_v417.z.literal("computer_call"),
3517
- id: import_v417.z.string(),
3518
- status: import_v417.z.string()
3605
+ import_v418.z.object({
3606
+ type: import_v418.z.literal("computer_call"),
3607
+ id: import_v418.z.string(),
3608
+ status: import_v418.z.string()
3519
3609
  }),
3520
- import_v417.z.object({
3521
- type: import_v417.z.literal("file_search_call"),
3522
- id: import_v417.z.string(),
3523
- status: import_v417.z.string(),
3524
- queries: import_v417.z.array(import_v417.z.string()).nullish(),
3525
- results: import_v417.z.array(
3526
- import_v417.z.object({
3527
- attributes: import_v417.z.object({
3528
- file_id: import_v417.z.string(),
3529
- filename: import_v417.z.string(),
3530
- score: import_v417.z.number(),
3531
- text: import_v417.z.string()
3532
- })
3533
- })
3534
- ).optional()
3610
+ import_v418.z.object({
3611
+ type: import_v418.z.literal("file_search_call"),
3612
+ id: import_v418.z.string()
3613
+ }),
3614
+ import_v418.z.object({
3615
+ type: import_v418.z.literal("image_generation_call"),
3616
+ id: import_v418.z.string()
3535
3617
  })
3536
3618
  ])
3537
3619
  });
3538
- var responseOutputItemDoneSchema = import_v417.z.object({
3539
- type: import_v417.z.literal("response.output_item.done"),
3540
- output_index: import_v417.z.number(),
3541
- item: import_v417.z.discriminatedUnion("type", [
3542
- import_v417.z.object({
3543
- type: import_v417.z.literal("message"),
3544
- id: import_v417.z.string()
3620
+ var responseOutputItemDoneSchema = import_v418.z.object({
3621
+ type: import_v418.z.literal("response.output_item.done"),
3622
+ output_index: import_v418.z.number(),
3623
+ item: import_v418.z.discriminatedUnion("type", [
3624
+ import_v418.z.object({
3625
+ type: import_v418.z.literal("message"),
3626
+ id: import_v418.z.string()
3545
3627
  }),
3546
- import_v417.z.object({
3547
- type: import_v417.z.literal("reasoning"),
3548
- id: import_v417.z.string(),
3549
- encrypted_content: import_v417.z.string().nullish()
3628
+ import_v418.z.object({
3629
+ type: import_v418.z.literal("reasoning"),
3630
+ id: import_v418.z.string(),
3631
+ encrypted_content: import_v418.z.string().nullish()
3550
3632
  }),
3551
- import_v417.z.object({
3552
- type: import_v417.z.literal("function_call"),
3553
- id: import_v417.z.string(),
3554
- call_id: import_v417.z.string(),
3555
- name: import_v417.z.string(),
3556
- arguments: import_v417.z.string(),
3557
- status: import_v417.z.literal("completed")
3633
+ import_v418.z.object({
3634
+ type: import_v418.z.literal("function_call"),
3635
+ id: import_v418.z.string(),
3636
+ call_id: import_v418.z.string(),
3637
+ name: import_v418.z.string(),
3638
+ arguments: import_v418.z.string(),
3639
+ status: import_v418.z.literal("completed")
3558
3640
  }),
3559
3641
  codeInterpreterCallItem,
3642
+ imageGenerationCallItem,
3560
3643
  webSearchCallItem,
3561
- import_v417.z.object({
3562
- type: import_v417.z.literal("computer_call"),
3563
- id: import_v417.z.string(),
3564
- status: import_v417.z.literal("completed")
3565
- }),
3566
- import_v417.z.object({
3567
- type: import_v417.z.literal("file_search_call"),
3568
- id: import_v417.z.string(),
3569
- status: import_v417.z.literal("completed"),
3570
- queries: import_v417.z.array(import_v417.z.string()).nullish(),
3571
- results: import_v417.z.array(
3572
- import_v417.z.object({
3573
- attributes: import_v417.z.object({
3574
- file_id: import_v417.z.string(),
3575
- filename: import_v417.z.string(),
3576
- score: import_v417.z.number(),
3577
- text: import_v417.z.string()
3578
- })
3579
- })
3580
- ).nullish()
3644
+ fileSearchCallItem,
3645
+ import_v418.z.object({
3646
+ type: import_v418.z.literal("computer_call"),
3647
+ id: import_v418.z.string(),
3648
+ status: import_v418.z.literal("completed")
3581
3649
  })
3582
3650
  ])
3583
3651
  });
3584
- var responseFunctionCallArgumentsDeltaSchema = import_v417.z.object({
3585
- type: import_v417.z.literal("response.function_call_arguments.delta"),
3586
- item_id: import_v417.z.string(),
3587
- output_index: import_v417.z.number(),
3588
- delta: import_v417.z.string()
3652
+ var responseFunctionCallArgumentsDeltaSchema = import_v418.z.object({
3653
+ type: import_v418.z.literal("response.function_call_arguments.delta"),
3654
+ item_id: import_v418.z.string(),
3655
+ output_index: import_v418.z.number(),
3656
+ delta: import_v418.z.string()
3589
3657
  });
3590
- var responseAnnotationAddedSchema = import_v417.z.object({
3591
- type: import_v417.z.literal("response.output_text.annotation.added"),
3592
- annotation: import_v417.z.discriminatedUnion("type", [
3593
- import_v417.z.object({
3594
- type: import_v417.z.literal("url_citation"),
3595
- url: import_v417.z.string(),
3596
- title: import_v417.z.string()
3658
+ var responseAnnotationAddedSchema = import_v418.z.object({
3659
+ type: import_v418.z.literal("response.output_text.annotation.added"),
3660
+ annotation: import_v418.z.discriminatedUnion("type", [
3661
+ import_v418.z.object({
3662
+ type: import_v418.z.literal("url_citation"),
3663
+ url: import_v418.z.string(),
3664
+ title: import_v418.z.string()
3597
3665
  }),
3598
- import_v417.z.object({
3599
- type: import_v417.z.literal("file_citation"),
3600
- file_id: import_v417.z.string(),
3601
- filename: import_v417.z.string().nullish(),
3602
- index: import_v417.z.number().nullish(),
3603
- start_index: import_v417.z.number().nullish(),
3604
- end_index: import_v417.z.number().nullish(),
3605
- quote: import_v417.z.string().nullish()
3666
+ import_v418.z.object({
3667
+ type: import_v418.z.literal("file_citation"),
3668
+ file_id: import_v418.z.string(),
3669
+ filename: import_v418.z.string().nullish(),
3670
+ index: import_v418.z.number().nullish(),
3671
+ start_index: import_v418.z.number().nullish(),
3672
+ end_index: import_v418.z.number().nullish(),
3673
+ quote: import_v418.z.string().nullish()
3606
3674
  })
3607
3675
  ])
3608
3676
  });
3609
- var responseReasoningSummaryPartAddedSchema = import_v417.z.object({
3610
- type: import_v417.z.literal("response.reasoning_summary_part.added"),
3611
- item_id: import_v417.z.string(),
3612
- summary_index: import_v417.z.number()
3677
+ var responseReasoningSummaryPartAddedSchema = import_v418.z.object({
3678
+ type: import_v418.z.literal("response.reasoning_summary_part.added"),
3679
+ item_id: import_v418.z.string(),
3680
+ summary_index: import_v418.z.number()
3613
3681
  });
3614
- var responseReasoningSummaryTextDeltaSchema = import_v417.z.object({
3615
- type: import_v417.z.literal("response.reasoning_summary_text.delta"),
3616
- item_id: import_v417.z.string(),
3617
- summary_index: import_v417.z.number(),
3618
- delta: import_v417.z.string()
3682
+ var responseReasoningSummaryTextDeltaSchema = import_v418.z.object({
3683
+ type: import_v418.z.literal("response.reasoning_summary_text.delta"),
3684
+ item_id: import_v418.z.string(),
3685
+ summary_index: import_v418.z.number(),
3686
+ delta: import_v418.z.string()
3619
3687
  });
3620
- var openaiResponsesChunkSchema = import_v417.z.union([
3688
+ var openaiResponsesChunkSchema = import_v418.z.union([
3621
3689
  textDeltaChunkSchema,
3622
3690
  responseFinishedChunkSchema,
3623
3691
  responseCreatedChunkSchema,
@@ -3628,7 +3696,7 @@ var openaiResponsesChunkSchema = import_v417.z.union([
3628
3696
  responseReasoningSummaryPartAddedSchema,
3629
3697
  responseReasoningSummaryTextDeltaSchema,
3630
3698
  errorChunkSchema,
3631
- import_v417.z.object({ type: import_v417.z.string() }).loose()
3699
+ import_v418.z.object({ type: import_v418.z.string() }).loose()
3632
3700
  // fallback for unknown chunks
3633
3701
  ]);
3634
3702
  function isTextDeltaChunk(chunk) {
@@ -3701,27 +3769,15 @@ function getResponsesModelConfig(modelId) {
3701
3769
  isReasoningModel: false
3702
3770
  };
3703
3771
  }
3704
- var openaiResponsesProviderOptionsSchema = import_v417.z.object({
3705
- metadata: import_v417.z.any().nullish(),
3706
- parallelToolCalls: import_v417.z.boolean().nullish(),
3707
- previousResponseId: import_v417.z.string().nullish(),
3708
- store: import_v417.z.boolean().nullish(),
3709
- user: import_v417.z.string().nullish(),
3710
- reasoningEffort: import_v417.z.string().nullish(),
3711
- strictJsonSchema: import_v417.z.boolean().nullish(),
3712
- instructions: import_v417.z.string().nullish(),
3713
- reasoningSummary: import_v417.z.string().nullish(),
3714
- serviceTier: import_v417.z.enum(["auto", "flex", "priority"]).nullish(),
3715
- include: import_v417.z.array(
3716
- import_v417.z.enum([
3772
+ var openaiResponsesProviderOptionsSchema = import_v418.z.object({
3773
+ include: import_v418.z.array(
3774
+ import_v418.z.enum([
3717
3775
  "reasoning.encrypted_content",
3718
3776
  "file_search_call.results",
3719
3777
  "message.output_text.logprobs"
3720
3778
  ])
3721
3779
  ).nullish(),
3722
- textVerbosity: import_v417.z.enum(["low", "medium", "high"]).nullish(),
3723
- promptCacheKey: import_v417.z.string().nullish(),
3724
- safetyIdentifier: import_v417.z.string().nullish(),
3780
+ instructions: import_v418.z.string().nullish(),
3725
3781
  /**
3726
3782
  * Return the log probabilities of the tokens.
3727
3783
  *
@@ -3734,7 +3790,25 @@ var openaiResponsesProviderOptionsSchema = import_v417.z.object({
3734
3790
  * @see https://platform.openai.com/docs/api-reference/responses/create
3735
3791
  * @see https://cookbook.openai.com/examples/using_logprobs
3736
3792
  */
3737
- logprobs: import_v417.z.union([import_v417.z.boolean(), import_v417.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
3793
+ logprobs: import_v418.z.union([import_v418.z.boolean(), import_v418.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3794
+ /**
3795
+ * The maximum number of total calls to built-in tools that can be processed in a response.
3796
+ * This maximum number applies across all built-in tool calls, not per individual tool.
3797
+ * Any further attempts to call a tool by the model will be ignored.
3798
+ */
3799
+ maxToolCalls: import_v418.z.number().nullish(),
3800
+ metadata: import_v418.z.any().nullish(),
3801
+ parallelToolCalls: import_v418.z.boolean().nullish(),
3802
+ previousResponseId: import_v418.z.string().nullish(),
3803
+ promptCacheKey: import_v418.z.string().nullish(),
3804
+ reasoningEffort: import_v418.z.string().nullish(),
3805
+ reasoningSummary: import_v418.z.string().nullish(),
3806
+ safetyIdentifier: import_v418.z.string().nullish(),
3807
+ serviceTier: import_v418.z.enum(["auto", "flex", "priority"]).nullish(),
3808
+ store: import_v418.z.boolean().nullish(),
3809
+ strictJsonSchema: import_v418.z.boolean().nullish(),
3810
+ textVerbosity: import_v418.z.enum(["low", "medium", "high"]).nullish(),
3811
+ user: import_v418.z.string().nullish()
3738
3812
  });
3739
3813
  // Annotate the CommonJS export names for ESM import in node:
3740
3814
  0 && (module.exports = {