@ai-sdk/openai 2.0.110 → 2.0.111

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.
@@ -81,7 +81,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
81
81
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
82
82
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
83
83
  const isReasoningModel = !(modelId.startsWith("gpt-3") || modelId.startsWith("gpt-4") || modelId.startsWith("chatgpt-4o") || modelId.startsWith("gpt-5-chat"));
84
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
84
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4") || modelId.startsWith("gpt-5.6");
85
85
  const systemMessageMode = isReasoningModel ? "developer" : "system";
86
86
  return {
87
87
  supportsFlexProcessing,
@@ -95,22 +95,46 @@ function getOpenAILanguageModelCapabilities(modelId) {
95
95
  // src/chat/convert-to-openai-chat-messages.ts
96
96
  var import_provider = require("@ai-sdk/provider");
97
97
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
98
+ function getPromptCacheBreakpoint(providerOptions) {
99
+ var _a;
100
+ return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
101
+ }
98
102
  function convertToOpenAIChatMessages({
99
103
  prompt,
100
104
  systemMessageMode = "system"
101
105
  }) {
102
106
  const messages = [];
103
107
  const warnings = [];
104
- for (const { role, content } of prompt) {
108
+ for (const { role, content, providerOptions } of prompt) {
105
109
  switch (role) {
106
110
  case "system": {
107
111
  switch (systemMessageMode) {
108
112
  case "system": {
109
- messages.push({ role: "system", content });
113
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
114
+ messages.push({
115
+ role: "system",
116
+ content: promptCacheBreakpoint == null ? content : [
117
+ {
118
+ type: "text",
119
+ text: content,
120
+ prompt_cache_breakpoint: promptCacheBreakpoint
121
+ }
122
+ ]
123
+ });
110
124
  break;
111
125
  }
112
126
  case "developer": {
113
- messages.push({ role: "developer", content });
127
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
128
+ messages.push({
129
+ role: "developer",
130
+ content: promptCacheBreakpoint == null ? content : [
131
+ {
132
+ type: "text",
133
+ text: content,
134
+ prompt_cache_breakpoint: promptCacheBreakpoint
135
+ }
136
+ ]
137
+ });
114
138
  break;
115
139
  }
116
140
  case "remove": {
@@ -130,7 +154,7 @@ function convertToOpenAIChatMessages({
130
154
  break;
131
155
  }
132
156
  case "user": {
133
- if (content.length === 1 && content[0].type === "text") {
157
+ if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
134
158
  messages.push({ role: "user", content: content[0].text });
135
159
  break;
136
160
  }
@@ -140,9 +164,21 @@ function convertToOpenAIChatMessages({
140
164
  var _a, _b, _c;
141
165
  switch (part.type) {
142
166
  case "text": {
143
- return { type: "text", text: part.text };
167
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
168
+ part.providerOptions
169
+ );
170
+ return {
171
+ type: "text",
172
+ text: part.text,
173
+ ...promptCacheBreakpoint != null && {
174
+ prompt_cache_breakpoint: promptCacheBreakpoint
175
+ }
176
+ };
144
177
  }
145
178
  case "file": {
179
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
180
+ part.providerOptions
181
+ );
146
182
  if (part.mediaType.startsWith("image/")) {
147
183
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
148
184
  return {
@@ -151,6 +187,9 @@ function convertToOpenAIChatMessages({
151
187
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`,
152
188
  // OpenAI specific extension: image detail
153
189
  detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
190
+ },
191
+ ...promptCacheBreakpoint != null && {
192
+ prompt_cache_breakpoint: promptCacheBreakpoint
154
193
  }
155
194
  };
156
195
  } else if (part.mediaType.startsWith("audio/")) {
@@ -166,6 +205,9 @@ function convertToOpenAIChatMessages({
166
205
  input_audio: {
167
206
  data: (0, import_provider_utils2.convertToBase64)(part.data),
168
207
  format: "wav"
208
+ },
209
+ ...promptCacheBreakpoint != null && {
210
+ prompt_cache_breakpoint: promptCacheBreakpoint
169
211
  }
170
212
  };
171
213
  }
@@ -176,6 +218,9 @@ function convertToOpenAIChatMessages({
176
218
  input_audio: {
177
219
  data: (0, import_provider_utils2.convertToBase64)(part.data),
178
220
  format: "mp3"
221
+ },
222
+ ...promptCacheBreakpoint != null && {
223
+ prompt_cache_breakpoint: promptCacheBreakpoint
179
224
  }
180
225
  };
181
226
  }
@@ -196,6 +241,9 @@ function convertToOpenAIChatMessages({
196
241
  file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
197
242
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
198
243
  file_data: `data:application/pdf;base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`
244
+ },
245
+ ...promptCacheBreakpoint != null && {
246
+ prompt_cache_breakpoint: promptCacheBreakpoint
199
247
  }
200
248
  };
201
249
  } else {
@@ -211,11 +259,24 @@ function convertToOpenAIChatMessages({
211
259
  }
212
260
  case "assistant": {
213
261
  let text = "";
262
+ const textParts = [];
263
+ let hasPromptCacheBreakpoint = false;
214
264
  const toolCalls = [];
215
265
  for (const part of content) {
216
266
  switch (part.type) {
217
267
  case "text": {
268
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
269
+ part.providerOptions
270
+ );
218
271
  text += part.text;
272
+ textParts.push({
273
+ type: "text",
274
+ text: part.text,
275
+ ...promptCacheBreakpoint != null && {
276
+ prompt_cache_breakpoint: promptCacheBreakpoint
277
+ }
278
+ });
279
+ hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
219
280
  break;
220
281
  }
221
282
  case "tool-call": {
@@ -233,7 +294,7 @@ function convertToOpenAIChatMessages({
233
294
  }
234
295
  messages.push({
235
296
  role: "assistant",
236
- content: text,
297
+ content: hasPromptCacheBreakpoint ? textParts : text,
237
298
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0
238
299
  });
239
300
  break;
@@ -241,6 +302,9 @@ function convertToOpenAIChatMessages({
241
302
  case "tool": {
242
303
  for (const toolResponse of content) {
243
304
  const output = toolResponse.output;
305
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
306
+ toolResponse.providerOptions
307
+ );
244
308
  let contentValue;
245
309
  switch (output.type) {
246
310
  case "text":
@@ -256,7 +320,13 @@ function convertToOpenAIChatMessages({
256
320
  messages.push({
257
321
  role: "tool",
258
322
  tool_call_id: toolResponse.toolCallId,
259
- content: contentValue
323
+ content: promptCacheBreakpoint == null ? contentValue : [
324
+ {
325
+ type: "text",
326
+ text: contentValue,
327
+ prompt_cache_breakpoint: promptCacheBreakpoint
328
+ }
329
+ ]
260
330
  });
261
331
  }
262
332
  break;
@@ -359,7 +429,8 @@ var openaiChatResponseSchema = (0, import_provider_utils3.lazyValidator)(
359
429
  completion_tokens: import_v42.z.number().nullish(),
360
430
  total_tokens: import_v42.z.number().nullish(),
361
431
  prompt_tokens_details: import_v42.z.object({
362
- cached_tokens: import_v42.z.number().nullish()
432
+ cached_tokens: import_v42.z.number().nullish(),
433
+ cache_write_tokens: import_v42.z.number().nullish()
363
434
  }).nullish(),
364
435
  completion_tokens_details: import_v42.z.object({
365
436
  reasoning_tokens: import_v42.z.number().nullish(),
@@ -428,7 +499,8 @@ var openaiChatChunkSchema = (0, import_provider_utils3.lazyValidator)(
428
499
  completion_tokens: import_v42.z.number().nullish(),
429
500
  total_tokens: import_v42.z.number().nullish(),
430
501
  prompt_tokens_details: import_v42.z.object({
431
- cached_tokens: import_v42.z.number().nullish()
502
+ cached_tokens: import_v42.z.number().nullish(),
503
+ cache_write_tokens: import_v42.z.number().nullish()
432
504
  }).nullish(),
433
505
  completion_tokens_details: import_v42.z.object({
434
506
  reasoning_tokens: import_v42.z.number().nullish(),
@@ -477,7 +549,7 @@ var openaiChatLanguageModelOptions = (0, import_provider_utils4.lazyValidator)(
477
549
  /**
478
550
  * Reasoning effort for reasoning models. Defaults to `medium`.
479
551
  */
480
- reasoningEffort: import_v43.z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
552
+ reasoningEffort: import_v43.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
481
553
  /**
482
554
  * Maximum number of completion tokens to generate. Useful for reasoning models.
483
555
  */
@@ -527,11 +599,22 @@ var openaiChatLanguageModelOptions = (0, import_provider_utils4.lazyValidator)(
527
599
  * Useful for improving cache hit rates and working around automatic caching issues.
528
600
  */
529
601
  promptCacheKey: import_v43.z.string().optional(),
602
+ /**
603
+ * Prompt cache behavior for GPT-5.6 and later models.
604
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
605
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
606
+ */
607
+ promptCacheOptions: import_v43.z.object({
608
+ mode: import_v43.z.enum(["implicit", "explicit"]).optional(),
609
+ ttl: import_v43.z.literal("30m").optional()
610
+ }).optional(),
530
611
  /**
531
612
  * The retention policy for the prompt cache.
532
613
  * - 'in_memory': Default. Standard prompt caching behavior.
533
614
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
534
- * Currently only available for 5.1 series models.
615
+ * Available for models before GPT-5.6 that support extended caching.
616
+ *
617
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
535
618
  *
536
619
  * @default 'in_memory'
537
620
  */
@@ -703,6 +786,7 @@ var OpenAIChatLanguageModel = class {
703
786
  reasoning_effort: openaiOptions.reasoningEffort,
704
787
  service_tier: openaiOptions.serviceTier,
705
788
  prompt_cache_key: openaiOptions.promptCacheKey,
789
+ prompt_cache_options: openaiOptions.promptCacheOptions,
706
790
  prompt_cache_retention: openaiOptions.promptCacheRetention,
707
791
  safety_identifier: openaiOptions.safetyIdentifier,
708
792
  // messages:
@@ -868,6 +952,11 @@ var OpenAIChatLanguageModel = class {
868
952
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
869
953
  providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
870
954
  }
955
+ if ((promptTokenDetails == null ? void 0 : promptTokenDetails.cache_write_tokens) != null) {
956
+ providerMetadata.openai.usage = {
957
+ cacheWriteTokens: promptTokenDetails.cache_write_tokens
958
+ };
959
+ }
871
960
  if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
872
961
  providerMetadata.openai.logprobs = choice.logprobs.content;
873
962
  }
@@ -931,7 +1020,7 @@ var OpenAIChatLanguageModel = class {
931
1020
  controller.enqueue({ type: "stream-start", warnings });
932
1021
  },
933
1022
  transform(chunk, controller) {
934
- 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;
1023
+ 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;
935
1024
  if (options.includeRawChunks) {
936
1025
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
937
1026
  }
@@ -962,18 +1051,23 @@ var OpenAIChatLanguageModel = class {
962
1051
  usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
963
1052
  usage.reasoningTokens = (_e = (_d = value.usage.completion_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
964
1053
  usage.cachedInputTokens = (_g = (_f = value.usage.prompt_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0;
965
- if (((_h = value.usage.completion_tokens_details) == null ? void 0 : _h.accepted_prediction_tokens) != null) {
966
- providerMetadata.openai.acceptedPredictionTokens = (_i = value.usage.completion_tokens_details) == null ? void 0 : _i.accepted_prediction_tokens;
1054
+ if (((_h = value.usage.prompt_tokens_details) == null ? void 0 : _h.cache_write_tokens) != null) {
1055
+ providerMetadata.openai.usage = {
1056
+ cacheWriteTokens: value.usage.prompt_tokens_details.cache_write_tokens
1057
+ };
1058
+ }
1059
+ if (((_i = value.usage.completion_tokens_details) == null ? void 0 : _i.accepted_prediction_tokens) != null) {
1060
+ providerMetadata.openai.acceptedPredictionTokens = (_j = value.usage.completion_tokens_details) == null ? void 0 : _j.accepted_prediction_tokens;
967
1061
  }
968
- if (((_j = value.usage.completion_tokens_details) == null ? void 0 : _j.rejected_prediction_tokens) != null) {
969
- providerMetadata.openai.rejectedPredictionTokens = (_k = value.usage.completion_tokens_details) == null ? void 0 : _k.rejected_prediction_tokens;
1062
+ if (((_k = value.usage.completion_tokens_details) == null ? void 0 : _k.rejected_prediction_tokens) != null) {
1063
+ providerMetadata.openai.rejectedPredictionTokens = (_l = value.usage.completion_tokens_details) == null ? void 0 : _l.rejected_prediction_tokens;
970
1064
  }
971
1065
  }
972
1066
  const choice = value.choices[0];
973
1067
  if ((choice == null ? void 0 : choice.finish_reason) != null) {
974
1068
  finishReason = mapOpenAIFinishReason(choice.finish_reason);
975
1069
  }
976
- if (((_l = choice == null ? void 0 : choice.logprobs) == null ? void 0 : _l.content) != null) {
1070
+ if (((_m = choice == null ? void 0 : choice.logprobs) == null ? void 0 : _m.content) != null) {
977
1071
  providerMetadata.openai.logprobs = choice.logprobs.content;
978
1072
  }
979
1073
  if ((choice == null ? void 0 : choice.delta) == null) {
@@ -1007,7 +1101,7 @@ var OpenAIChatLanguageModel = class {
1007
1101
  message: `Expected 'id' to be a string.`
1008
1102
  });
1009
1103
  }
1010
- if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
1104
+ if (((_n = toolCallDelta.function) == null ? void 0 : _n.name) == null) {
1011
1105
  throw new import_provider3.InvalidResponseDataError({
1012
1106
  data: toolCallDelta,
1013
1107
  message: `Expected 'function.name' to be a string.`
@@ -1023,12 +1117,12 @@ var OpenAIChatLanguageModel = class {
1023
1117
  type: "function",
1024
1118
  function: {
1025
1119
  name: toolCallDelta.function.name,
1026
- arguments: (_n = toolCallDelta.function.arguments) != null ? _n : ""
1120
+ arguments: (_o = toolCallDelta.function.arguments) != null ? _o : ""
1027
1121
  },
1028
1122
  hasFinished: false
1029
1123
  };
1030
1124
  const toolCall2 = toolCalls[index];
1031
- if (((_o = toolCall2.function) == null ? void 0 : _o.name) != null && ((_p = toolCall2.function) == null ? void 0 : _p.arguments) != null) {
1125
+ if (((_p = toolCall2.function) == null ? void 0 : _p.name) != null && ((_q = toolCall2.function) == null ? void 0 : _q.arguments) != null) {
1032
1126
  if (toolCall2.function.arguments.length > 0) {
1033
1127
  controller.enqueue({
1034
1128
  type: "tool-input-delta",
@@ -1043,7 +1137,7 @@ var OpenAIChatLanguageModel = class {
1043
1137
  });
1044
1138
  controller.enqueue({
1045
1139
  type: "tool-call",
1046
- toolCallId: (_q = toolCall2.id) != null ? _q : (0, import_provider_utils5.generateId)(),
1140
+ toolCallId: (_r = toolCall2.id) != null ? _r : (0, import_provider_utils5.generateId)(),
1047
1141
  toolName: toolCall2.function.name,
1048
1142
  input: toolCall2.function.arguments
1049
1143
  });
@@ -1056,22 +1150,22 @@ var OpenAIChatLanguageModel = class {
1056
1150
  if (toolCall.hasFinished) {
1057
1151
  continue;
1058
1152
  }
1059
- if (((_r = toolCallDelta.function) == null ? void 0 : _r.arguments) != null) {
1060
- toolCall.function.arguments += (_t = (_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null ? _t : "";
1153
+ if (((_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null) {
1154
+ toolCall.function.arguments += (_u = (_t = toolCallDelta.function) == null ? void 0 : _t.arguments) != null ? _u : "";
1061
1155
  }
1062
1156
  controller.enqueue({
1063
1157
  type: "tool-input-delta",
1064
1158
  id: toolCall.id,
1065
- delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
1159
+ delta: (_v = toolCallDelta.function.arguments) != null ? _v : ""
1066
1160
  });
1067
- 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)) {
1161
+ if (((_w = toolCall.function) == null ? void 0 : _w.name) != null && ((_x = toolCall.function) == null ? void 0 : _x.arguments) != null && (0, import_provider_utils5.isParsableJson)(toolCall.function.arguments)) {
1068
1162
  controller.enqueue({
1069
1163
  type: "tool-input-end",
1070
1164
  id: toolCall.id
1071
1165
  });
1072
1166
  controller.enqueue({
1073
1167
  type: "tool-call",
1074
- toolCallId: (_x = toolCall.id) != null ? _x : (0, import_provider_utils5.generateId)(),
1168
+ toolCallId: (_y = toolCall.id) != null ? _y : (0, import_provider_utils5.generateId)(),
1075
1169
  toolName: toolCall.function.name,
1076
1170
  input: toolCall.function.arguments
1077
1171
  });
@@ -2269,6 +2363,10 @@ var localShell = (0, import_provider_utils20.createProviderDefinedToolFactoryWit
2269
2363
  });
2270
2364
 
2271
2365
  // src/responses/convert-to-openai-responses-input.ts
2366
+ function getPromptCacheBreakpoint2(providerOptions) {
2367
+ var _a;
2368
+ return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
2369
+ }
2272
2370
  function isFileId(data, prefixes) {
2273
2371
  if (!prefixes) return false;
2274
2372
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -2283,16 +2381,36 @@ async function convertToOpenAIResponsesInput({
2283
2381
  var _a, _b, _c, _d, _e, _f;
2284
2382
  let input = [];
2285
2383
  const warnings = [];
2286
- for (const { role, content } of prompt) {
2384
+ for (const { role, content, providerOptions } of prompt) {
2287
2385
  switch (role) {
2288
2386
  case "system": {
2289
2387
  switch (systemMessageMode) {
2290
2388
  case "system": {
2291
- input.push({ role: "system", content });
2389
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
2390
+ input.push({
2391
+ role: "system",
2392
+ content: promptCacheBreakpoint == null ? content : [
2393
+ {
2394
+ type: "input_text",
2395
+ text: content,
2396
+ prompt_cache_breakpoint: promptCacheBreakpoint
2397
+ }
2398
+ ]
2399
+ });
2292
2400
  break;
2293
2401
  }
2294
2402
  case "developer": {
2295
- input.push({ role: "developer", content });
2403
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
2404
+ input.push({
2405
+ role: "developer",
2406
+ content: promptCacheBreakpoint == null ? content : [
2407
+ {
2408
+ type: "input_text",
2409
+ text: content,
2410
+ prompt_cache_breakpoint: promptCacheBreakpoint
2411
+ }
2412
+ ]
2413
+ });
2296
2414
  break;
2297
2415
  }
2298
2416
  case "remove": {
@@ -2318,9 +2436,21 @@ async function convertToOpenAIResponsesInput({
2318
2436
  var _a2, _b2, _c2;
2319
2437
  switch (part.type) {
2320
2438
  case "text": {
2321
- return { type: "input_text", text: part.text };
2439
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2440
+ part.providerOptions
2441
+ );
2442
+ return {
2443
+ type: "input_text",
2444
+ text: part.text,
2445
+ ...promptCacheBreakpoint != null && {
2446
+ prompt_cache_breakpoint: promptCacheBreakpoint
2447
+ }
2448
+ };
2322
2449
  }
2323
2450
  case "file": {
2451
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2452
+ part.providerOptions
2453
+ );
2324
2454
  if (part.mediaType.startsWith("image/")) {
2325
2455
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2326
2456
  return {
@@ -2328,13 +2458,19 @@ async function convertToOpenAIResponsesInput({
2328
2458
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2329
2459
  image_url: `data:${mediaType};base64,${(0, import_provider_utils21.convertToBase64)(part.data)}`
2330
2460
  },
2331
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2461
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail,
2462
+ ...promptCacheBreakpoint != null && {
2463
+ prompt_cache_breakpoint: promptCacheBreakpoint
2464
+ }
2332
2465
  };
2333
2466
  } else if (part.mediaType === "application/pdf") {
2334
2467
  if (part.data instanceof URL) {
2335
2468
  return {
2336
2469
  type: "input_file",
2337
- file_url: part.data.toString()
2470
+ file_url: part.data.toString(),
2471
+ ...promptCacheBreakpoint != null && {
2472
+ prompt_cache_breakpoint: promptCacheBreakpoint
2473
+ }
2338
2474
  };
2339
2475
  }
2340
2476
  return {
@@ -2342,6 +2478,9 @@ async function convertToOpenAIResponsesInput({
2342
2478
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2343
2479
  filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2344
2480
  file_data: `data:application/pdf;base64,${(0, import_provider_utils21.convertToBase64)(part.data)}`
2481
+ },
2482
+ ...promptCacheBreakpoint != null && {
2483
+ prompt_cache_breakpoint: promptCacheBreakpoint
2345
2484
  }
2346
2485
  };
2347
2486
  } else {
@@ -2427,12 +2566,12 @@ async function convertToOpenAIResponsesInput({
2427
2566
  break;
2428
2567
  }
2429
2568
  case "reasoning": {
2430
- const providerOptions = await (0, import_provider_utils21.parseProviderOptions)({
2569
+ const providerOptions2 = await (0, import_provider_utils21.parseProviderOptions)({
2431
2570
  provider: "openai",
2432
2571
  providerOptions: part.providerOptions,
2433
2572
  schema: openaiResponsesReasoningProviderOptionsSchema
2434
2573
  });
2435
- const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2574
+ const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
2436
2575
  if (reasoningId != null) {
2437
2576
  const reasoningMessage = reasoningMessages[reasoningId];
2438
2577
  if (store) {
@@ -2461,14 +2600,14 @@ async function convertToOpenAIResponsesInput({
2461
2600
  reasoningMessages[reasoningId] = {
2462
2601
  type: "reasoning",
2463
2602
  id: reasoningId,
2464
- encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2603
+ encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
2465
2604
  summary: summaryParts
2466
2605
  };
2467
2606
  input.push(reasoningMessages[reasoningId]);
2468
2607
  } else {
2469
2608
  reasoningMessage.summary.push(...summaryParts);
2470
- if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
2471
- reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
2609
+ if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
2610
+ reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
2472
2611
  }
2473
2612
  }
2474
2613
  }
@@ -2487,6 +2626,9 @@ async function convertToOpenAIResponsesInput({
2487
2626
  case "tool": {
2488
2627
  for (const part of content) {
2489
2628
  const output = part.output;
2629
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2630
+ part.providerOptions
2631
+ );
2490
2632
  if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
2491
2633
  const parsedOutput = await (0, import_provider_utils21.validateTypes)({
2492
2634
  value: output.value,
@@ -2503,26 +2645,51 @@ async function convertToOpenAIResponsesInput({
2503
2645
  switch (output.type) {
2504
2646
  case "text":
2505
2647
  case "error-text":
2506
- contentValue = output.value;
2648
+ contentValue = promptCacheBreakpoint == null ? output.value : [
2649
+ {
2650
+ type: "input_text",
2651
+ text: output.value,
2652
+ prompt_cache_breakpoint: promptCacheBreakpoint
2653
+ }
2654
+ ];
2507
2655
  break;
2508
2656
  case "json":
2509
2657
  case "error-json":
2510
- contentValue = JSON.stringify(output.value);
2658
+ contentValue = promptCacheBreakpoint == null ? JSON.stringify(output.value) : [
2659
+ {
2660
+ type: "input_text",
2661
+ text: JSON.stringify(output.value),
2662
+ prompt_cache_breakpoint: promptCacheBreakpoint
2663
+ }
2664
+ ];
2511
2665
  break;
2512
2666
  case "content":
2513
- contentValue = output.value.map((item) => {
2667
+ contentValue = output.value.map((item, index) => {
2668
+ const isBreakpoint = promptCacheBreakpoint != null && index === output.value.length - 1;
2514
2669
  switch (item.type) {
2515
2670
  case "text": {
2516
- return { type: "input_text", text: item.text };
2671
+ return {
2672
+ type: "input_text",
2673
+ text: item.text,
2674
+ ...isBreakpoint && {
2675
+ prompt_cache_breakpoint: promptCacheBreakpoint
2676
+ }
2677
+ };
2517
2678
  }
2518
2679
  case "media": {
2519
2680
  return item.mediaType.startsWith("image/") ? {
2520
2681
  type: "input_image",
2521
- image_url: `data:${item.mediaType};base64,${item.data}`
2682
+ image_url: `data:${item.mediaType};base64,${item.data}`,
2683
+ ...isBreakpoint && {
2684
+ prompt_cache_breakpoint: promptCacheBreakpoint
2685
+ }
2522
2686
  } : {
2523
2687
  type: "input_file",
2524
2688
  filename: "data",
2525
- file_data: `data:${item.mediaType};base64,${item.data}`
2689
+ file_data: `data:${item.mediaType};base64,${item.data}`,
2690
+ ...isBreakpoint && {
2691
+ prompt_cache_breakpoint: promptCacheBreakpoint
2692
+ }
2526
2693
  };
2527
2694
  }
2528
2695
  }
@@ -2610,6 +2777,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils22.lazyValidator)(
2610
2777
  input_tokens: import_v415.z.number(),
2611
2778
  input_tokens_details: import_v415.z.object({
2612
2779
  cached_tokens: import_v415.z.number().nullish(),
2780
+ cache_write_tokens: import_v415.z.number().nullish(),
2613
2781
  orchestration_input_tokens: import_v415.z.number().nullish(),
2614
2782
  orchestration_input_cached_tokens: import_v415.z.number().nullish()
2615
2783
  }).nullish(),
@@ -2619,6 +2787,9 @@ var openaiResponsesChunkSchema = (0, import_provider_utils22.lazyValidator)(
2619
2787
  orchestration_output_tokens: import_v415.z.number().nullish()
2620
2788
  }).nullish()
2621
2789
  }),
2790
+ reasoning: import_v415.z.object({
2791
+ context: import_v415.z.string().nullish()
2792
+ }).nullish(),
2622
2793
  service_tier: import_v415.z.string().nullish()
2623
2794
  })
2624
2795
  }),
@@ -3037,11 +3208,15 @@ var openaiResponsesResponseSchema = (0, import_provider_utils22.lazyValidator)(
3037
3208
  ])
3038
3209
  ).optional(),
3039
3210
  service_tier: import_v415.z.string().nullish(),
3211
+ reasoning: import_v415.z.object({
3212
+ context: import_v415.z.string().nullish()
3213
+ }).nullish(),
3040
3214
  incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
3041
3215
  usage: import_v415.z.object({
3042
3216
  input_tokens: import_v415.z.number(),
3043
3217
  input_tokens_details: import_v415.z.object({
3044
3218
  cached_tokens: import_v415.z.number().nullish(),
3219
+ cache_write_tokens: import_v415.z.number().nullish(),
3045
3220
  orchestration_input_tokens: import_v415.z.number().nullish(),
3046
3221
  orchestration_input_cached_tokens: import_v415.z.number().nullish()
3047
3222
  }).nullish(),
@@ -3101,7 +3276,11 @@ var openaiResponsesReasoningModelIds = [
3101
3276
  "gpt-5.4-nano",
3102
3277
  "gpt-5.4-nano-2026-03-17",
3103
3278
  "gpt-5.4-pro",
3104
- "gpt-5.4-pro-2026-03-05"
3279
+ "gpt-5.4-pro-2026-03-05",
3280
+ "gpt-5.6",
3281
+ "gpt-5.6-luna",
3282
+ "gpt-5.6-sol",
3283
+ "gpt-5.6-terra"
3105
3284
  ];
3106
3285
  var openaiResponsesModelIds = [
3107
3286
  "gpt-4.1",
@@ -3175,11 +3354,22 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils23.lazyValid
3175
3354
  parallelToolCalls: import_v416.z.boolean().nullish(),
3176
3355
  previousResponseId: import_v416.z.string().nullish(),
3177
3356
  promptCacheKey: import_v416.z.string().nullish(),
3357
+ /**
3358
+ * Prompt cache behavior for GPT-5.6 and later models.
3359
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
3360
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
3361
+ */
3362
+ promptCacheOptions: import_v416.z.object({
3363
+ mode: import_v416.z.enum(["implicit", "explicit"]).optional(),
3364
+ ttl: import_v416.z.literal("30m").optional()
3365
+ }).optional(),
3178
3366
  /**
3179
3367
  * The retention policy for the prompt cache.
3180
3368
  * - 'in_memory': Default. Standard prompt caching behavior.
3181
3369
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
3182
- * Currently only available for 5.1 series models.
3370
+ * Available for models before GPT-5.6 that support extended caching.
3371
+ *
3372
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
3183
3373
  *
3184
3374
  * @default 'in_memory'
3185
3375
  */
@@ -3187,14 +3377,21 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils23.lazyValid
3187
3377
  /**
3188
3378
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
3189
3379
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
3190
- * Valid values: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
3191
- *
3192
- * The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
3193
- * models. Also, the 'xhigh' type for `reasoningEffort` is only available for
3194
- * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
3195
- * an error.
3380
+ * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
3381
+ * Supported values vary by model.
3196
3382
  */
3197
3383
  reasoningEffort: import_v416.z.string().nullish(),
3384
+ /**
3385
+ * Controls how much model work GPT-5.6 performs before returning a final answer.
3386
+ * `standard` is the default. `pro` increases quality, latency, and token usage.
3387
+ */
3388
+ reasoningMode: import_v416.z.enum(["standard", "pro"]).optional(),
3389
+ /**
3390
+ * Controls which available reasoning items GPT-5.6 can use.
3391
+ * `auto` uses the model default, `current_turn` excludes reasoning from earlier
3392
+ * turns, and `all_turns` makes compatible earlier reasoning available.
3393
+ */
3394
+ reasoningContext: import_v416.z.enum(["auto", "current_turn", "all_turns"]).optional(),
3198
3395
  reasoningSummary: import_v416.z.string().nullish(),
3199
3396
  safetyIdentifier: import_v416.z.string().nullish(),
3200
3397
  serviceTier: import_v416.z.enum(["auto", "flex", "priority", "default"]).nullish(),
@@ -3721,18 +3918,25 @@ var OpenAIResponsesLanguageModel = class {
3721
3918
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
3722
3919
  include,
3723
3920
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
3921
+ prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
3724
3922
  prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
3725
3923
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
3726
3924
  top_logprobs: topLogprobs,
3727
3925
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
3728
3926
  // model-specific settings:
3729
- ...modelCapabilities.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
3927
+ ...modelCapabilities.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
3730
3928
  reasoning: {
3731
3929
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
3732
3930
  effort: openaiOptions.reasoningEffort
3733
3931
  },
3734
3932
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
3735
3933
  summary: openaiOptions.reasoningSummary
3934
+ },
3935
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
3936
+ mode: openaiOptions.reasoningMode
3937
+ },
3938
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
3939
+ context: openaiOptions.reasoningContext
3736
3940
  }
3737
3941
  }
3738
3942
  }
@@ -3771,6 +3975,20 @@ var OpenAIResponsesLanguageModel = class {
3771
3975
  details: "reasoningSummary is not supported for non-reasoning models"
3772
3976
  });
3773
3977
  }
3978
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
3979
+ warnings.push({
3980
+ type: "unsupported-setting",
3981
+ setting: "reasoningMode",
3982
+ details: "reasoningMode is not supported for non-reasoning models"
3983
+ });
3984
+ }
3985
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
3986
+ warnings.push({
3987
+ type: "unsupported-setting",
3988
+ setting: "reasoningContext",
3989
+ details: "reasoningContext is not supported for non-reasoning models"
3990
+ });
3991
+ }
3774
3992
  }
3775
3993
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
3776
3994
  warnings.push({
@@ -3809,7 +4027,7 @@ var OpenAIResponsesLanguageModel = class {
3809
4027
  };
3810
4028
  }
3811
4029
  async doGenerate(options) {
3812
- 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, _z, _A, _B;
4030
+ 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, _z, _A, _B, _C;
3813
4031
  const {
3814
4032
  args: body,
3815
4033
  warnings,
@@ -4093,23 +4311,26 @@ var OpenAIResponsesLanguageModel = class {
4093
4311
  if (typeof response.service_tier === "string") {
4094
4312
  providerMetadata[providerKey].serviceTier = response.service_tier;
4095
4313
  }
4314
+ if (((_x = response.reasoning) == null ? void 0 : _x.context) != null) {
4315
+ providerMetadata[providerKey].reasoningContext = response.reasoning.context;
4316
+ }
4096
4317
  const usage = response.usage;
4097
- const orchestrationUsage = getOrchestrationUsageMetadata(usage);
4098
- if (orchestrationUsage != null) {
4099
- providerMetadata[providerKey].usage = orchestrationUsage;
4318
+ const responsesUsage = getResponsesUsageMetadata(usage);
4319
+ if (responsesUsage != null) {
4320
+ providerMetadata[providerKey].usage = responsesUsage;
4100
4321
  }
4101
4322
  return {
4102
4323
  content,
4103
4324
  finishReason: mapOpenAIResponseFinishReason({
4104
- finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
4325
+ finishReason: (_y = response.incomplete_details) == null ? void 0 : _y.reason,
4105
4326
  hasFunctionCall
4106
4327
  }),
4107
4328
  usage: {
4108
4329
  inputTokens: usage.input_tokens,
4109
4330
  outputTokens: usage.output_tokens,
4110
4331
  totalTokens: usage.input_tokens + usage.output_tokens,
4111
- reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
4112
- cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
4332
+ reasoningTokens: (_A = (_z = usage.output_tokens_details) == null ? void 0 : _z.reasoning_tokens) != null ? _A : void 0,
4333
+ cachedInputTokens: (_C = (_B = usage.input_tokens_details) == null ? void 0 : _B.cached_tokens) != null ? _C : void 0
4113
4334
  },
4114
4335
  request: { body },
4115
4336
  response: {
@@ -4163,7 +4384,8 @@ var OpenAIResponsesLanguageModel = class {
4163
4384
  let hasFunctionCall = false;
4164
4385
  const activeReasoning = {};
4165
4386
  let serviceTier;
4166
- let orchestrationUsage;
4387
+ let reasoningContext;
4388
+ let responsesUsage;
4167
4389
  return {
4168
4390
  stream: response.pipeThrough(
4169
4391
  new TransformStream({
@@ -4171,7 +4393,7 @@ var OpenAIResponsesLanguageModel = class {
4171
4393
  controller.enqueue({ type: "stream-start", warnings });
4172
4394
  },
4173
4395
  transform(chunk, controller) {
4174
- 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;
4396
+ 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;
4175
4397
  if (options.includeRawChunks) {
4176
4398
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
4177
4399
  }
@@ -4564,16 +4786,17 @@ var OpenAIResponsesLanguageModel = class {
4564
4786
  if (typeof value.response.service_tier === "string") {
4565
4787
  serviceTier = value.response.service_tier;
4566
4788
  }
4567
- orchestrationUsage = getOrchestrationUsageMetadata(
4568
- value.response.usage
4569
- );
4789
+ if (((_p = value.response.reasoning) == null ? void 0 : _p.context) != null) {
4790
+ reasoningContext = value.response.reasoning.context;
4791
+ }
4792
+ responsesUsage = getResponsesUsageMetadata(value.response.usage);
4570
4793
  } else if (isResponseAnnotationAddedChunk(value)) {
4571
4794
  ongoingAnnotations.push(value.annotation);
4572
4795
  if (value.annotation.type === "url_citation") {
4573
4796
  controller.enqueue({
4574
4797
  type: "source",
4575
4798
  sourceType: "url",
4576
- id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils30.generateId)(),
4799
+ id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils30.generateId)(),
4577
4800
  url: value.annotation.url,
4578
4801
  title: value.annotation.title
4579
4802
  });
@@ -4581,10 +4804,10 @@ var OpenAIResponsesLanguageModel = class {
4581
4804
  controller.enqueue({
4582
4805
  type: "source",
4583
4806
  sourceType: "document",
4584
- id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils30.generateId)(),
4807
+ id: (_v = (_u = (_t = self.config).generateId) == null ? void 0 : _u.call(_t)) != null ? _v : (0, import_provider_utils30.generateId)(),
4585
4808
  mediaType: "text/plain",
4586
- title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
4587
- filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
4809
+ title: (_x = (_w = value.annotation.quote) != null ? _w : value.annotation.filename) != null ? _x : "Document",
4810
+ filename: (_y = value.annotation.filename) != null ? _y : value.annotation.file_id,
4588
4811
  ...value.annotation.file_id ? {
4589
4812
  providerMetadata: {
4590
4813
  [providerKey]: {
@@ -4610,8 +4833,11 @@ var OpenAIResponsesLanguageModel = class {
4610
4833
  if (serviceTier !== void 0) {
4611
4834
  providerMetadata[providerKey].serviceTier = serviceTier;
4612
4835
  }
4613
- if (orchestrationUsage != null) {
4614
- providerMetadata[providerKey].usage = orchestrationUsage;
4836
+ if (reasoningContext !== void 0) {
4837
+ providerMetadata[providerKey].reasoningContext = reasoningContext;
4838
+ }
4839
+ if (responsesUsage != null) {
4840
+ providerMetadata[providerKey].usage = responsesUsage;
4615
4841
  }
4616
4842
  controller.enqueue({
4617
4843
  type: "finish",
@@ -4681,15 +4907,17 @@ function mapWebSearchOutput(action) {
4681
4907
  };
4682
4908
  }
4683
4909
  }
4684
- function getOrchestrationUsageMetadata(usage) {
4685
- var _a, _b, _c;
4686
- const orchestrationInputTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.orchestration_input_tokens;
4687
- const orchestrationInputCachedTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_cached_tokens;
4688
- const orchestrationOutputTokens = (_c = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _c.orchestration_output_tokens;
4689
- if (orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
4910
+ function getResponsesUsageMetadata(usage) {
4911
+ var _a, _b, _c, _d;
4912
+ const cacheWriteTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.cache_write_tokens;
4913
+ const orchestrationInputTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_tokens;
4914
+ const orchestrationInputCachedTokens = (_c = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _c.orchestration_input_cached_tokens;
4915
+ const orchestrationOutputTokens = (_d = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _d.orchestration_output_tokens;
4916
+ if (cacheWriteTokens == null && orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
4690
4917
  return void 0;
4691
4918
  }
4692
4919
  return {
4920
+ ...cacheWriteTokens != null && { cacheWriteTokens },
4693
4921
  ...orchestrationInputTokens != null && { orchestrationInputTokens },
4694
4922
  ...orchestrationInputCachedTokens != null && {
4695
4923
  orchestrationInputCachedTokens