@ai-sdk/openai 2.0.109 → 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.
@@ -36,7 +36,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
36
36
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
37
37
  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");
38
38
  const isReasoningModel = !(modelId.startsWith("gpt-3") || modelId.startsWith("gpt-4") || modelId.startsWith("chatgpt-4o") || modelId.startsWith("gpt-5-chat"));
39
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
39
+ 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");
40
40
  const systemMessageMode = isReasoningModel ? "developer" : "system";
41
41
  return {
42
42
  supportsFlexProcessing,
@@ -52,22 +52,46 @@ import {
52
52
  UnsupportedFunctionalityError
53
53
  } from "@ai-sdk/provider";
54
54
  import { convertToBase64 } from "@ai-sdk/provider-utils";
55
+ function getPromptCacheBreakpoint(providerOptions) {
56
+ var _a;
57
+ return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
58
+ }
55
59
  function convertToOpenAIChatMessages({
56
60
  prompt,
57
61
  systemMessageMode = "system"
58
62
  }) {
59
63
  const messages = [];
60
64
  const warnings = [];
61
- for (const { role, content } of prompt) {
65
+ for (const { role, content, providerOptions } of prompt) {
62
66
  switch (role) {
63
67
  case "system": {
64
68
  switch (systemMessageMode) {
65
69
  case "system": {
66
- messages.push({ role: "system", content });
70
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
71
+ messages.push({
72
+ role: "system",
73
+ content: promptCacheBreakpoint == null ? content : [
74
+ {
75
+ type: "text",
76
+ text: content,
77
+ prompt_cache_breakpoint: promptCacheBreakpoint
78
+ }
79
+ ]
80
+ });
67
81
  break;
68
82
  }
69
83
  case "developer": {
70
- messages.push({ role: "developer", content });
84
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
85
+ messages.push({
86
+ role: "developer",
87
+ content: promptCacheBreakpoint == null ? content : [
88
+ {
89
+ type: "text",
90
+ text: content,
91
+ prompt_cache_breakpoint: promptCacheBreakpoint
92
+ }
93
+ ]
94
+ });
71
95
  break;
72
96
  }
73
97
  case "remove": {
@@ -87,7 +111,7 @@ function convertToOpenAIChatMessages({
87
111
  break;
88
112
  }
89
113
  case "user": {
90
- if (content.length === 1 && content[0].type === "text") {
114
+ if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
91
115
  messages.push({ role: "user", content: content[0].text });
92
116
  break;
93
117
  }
@@ -97,9 +121,21 @@ function convertToOpenAIChatMessages({
97
121
  var _a, _b, _c;
98
122
  switch (part.type) {
99
123
  case "text": {
100
- return { type: "text", text: part.text };
124
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
125
+ part.providerOptions
126
+ );
127
+ return {
128
+ type: "text",
129
+ text: part.text,
130
+ ...promptCacheBreakpoint != null && {
131
+ prompt_cache_breakpoint: promptCacheBreakpoint
132
+ }
133
+ };
101
134
  }
102
135
  case "file": {
136
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
137
+ part.providerOptions
138
+ );
103
139
  if (part.mediaType.startsWith("image/")) {
104
140
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
105
141
  return {
@@ -108,6 +144,9 @@ function convertToOpenAIChatMessages({
108
144
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
109
145
  // OpenAI specific extension: image detail
110
146
  detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
147
+ },
148
+ ...promptCacheBreakpoint != null && {
149
+ prompt_cache_breakpoint: promptCacheBreakpoint
111
150
  }
112
151
  };
113
152
  } else if (part.mediaType.startsWith("audio/")) {
@@ -123,6 +162,9 @@ function convertToOpenAIChatMessages({
123
162
  input_audio: {
124
163
  data: convertToBase64(part.data),
125
164
  format: "wav"
165
+ },
166
+ ...promptCacheBreakpoint != null && {
167
+ prompt_cache_breakpoint: promptCacheBreakpoint
126
168
  }
127
169
  };
128
170
  }
@@ -133,6 +175,9 @@ function convertToOpenAIChatMessages({
133
175
  input_audio: {
134
176
  data: convertToBase64(part.data),
135
177
  format: "mp3"
178
+ },
179
+ ...promptCacheBreakpoint != null && {
180
+ prompt_cache_breakpoint: promptCacheBreakpoint
136
181
  }
137
182
  };
138
183
  }
@@ -153,6 +198,9 @@ function convertToOpenAIChatMessages({
153
198
  file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
154
199
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
155
200
  file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
201
+ },
202
+ ...promptCacheBreakpoint != null && {
203
+ prompt_cache_breakpoint: promptCacheBreakpoint
156
204
  }
157
205
  };
158
206
  } else {
@@ -168,11 +216,24 @@ function convertToOpenAIChatMessages({
168
216
  }
169
217
  case "assistant": {
170
218
  let text = "";
219
+ const textParts = [];
220
+ let hasPromptCacheBreakpoint = false;
171
221
  const toolCalls = [];
172
222
  for (const part of content) {
173
223
  switch (part.type) {
174
224
  case "text": {
225
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
226
+ part.providerOptions
227
+ );
175
228
  text += part.text;
229
+ textParts.push({
230
+ type: "text",
231
+ text: part.text,
232
+ ...promptCacheBreakpoint != null && {
233
+ prompt_cache_breakpoint: promptCacheBreakpoint
234
+ }
235
+ });
236
+ hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
176
237
  break;
177
238
  }
178
239
  case "tool-call": {
@@ -190,7 +251,7 @@ function convertToOpenAIChatMessages({
190
251
  }
191
252
  messages.push({
192
253
  role: "assistant",
193
- content: text,
254
+ content: hasPromptCacheBreakpoint ? textParts : text,
194
255
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0
195
256
  });
196
257
  break;
@@ -198,6 +259,9 @@ function convertToOpenAIChatMessages({
198
259
  case "tool": {
199
260
  for (const toolResponse of content) {
200
261
  const output = toolResponse.output;
262
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
263
+ toolResponse.providerOptions
264
+ );
201
265
  let contentValue;
202
266
  switch (output.type) {
203
267
  case "text":
@@ -213,7 +277,13 @@ function convertToOpenAIChatMessages({
213
277
  messages.push({
214
278
  role: "tool",
215
279
  tool_call_id: toolResponse.toolCallId,
216
- content: contentValue
280
+ content: promptCacheBreakpoint == null ? contentValue : [
281
+ {
282
+ type: "text",
283
+ text: contentValue,
284
+ prompt_cache_breakpoint: promptCacheBreakpoint
285
+ }
286
+ ]
217
287
  });
218
288
  }
219
289
  break;
@@ -319,7 +389,8 @@ var openaiChatResponseSchema = lazyValidator(
319
389
  completion_tokens: z2.number().nullish(),
320
390
  total_tokens: z2.number().nullish(),
321
391
  prompt_tokens_details: z2.object({
322
- cached_tokens: z2.number().nullish()
392
+ cached_tokens: z2.number().nullish(),
393
+ cache_write_tokens: z2.number().nullish()
323
394
  }).nullish(),
324
395
  completion_tokens_details: z2.object({
325
396
  reasoning_tokens: z2.number().nullish(),
@@ -388,7 +459,8 @@ var openaiChatChunkSchema = lazyValidator(
388
459
  completion_tokens: z2.number().nullish(),
389
460
  total_tokens: z2.number().nullish(),
390
461
  prompt_tokens_details: z2.object({
391
- cached_tokens: z2.number().nullish()
462
+ cached_tokens: z2.number().nullish(),
463
+ cache_write_tokens: z2.number().nullish()
392
464
  }).nullish(),
393
465
  completion_tokens_details: z2.object({
394
466
  reasoning_tokens: z2.number().nullish(),
@@ -440,7 +512,7 @@ var openaiChatLanguageModelOptions = lazyValidator2(
440
512
  /**
441
513
  * Reasoning effort for reasoning models. Defaults to `medium`.
442
514
  */
443
- reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
515
+ reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
444
516
  /**
445
517
  * Maximum number of completion tokens to generate. Useful for reasoning models.
446
518
  */
@@ -490,11 +562,22 @@ var openaiChatLanguageModelOptions = lazyValidator2(
490
562
  * Useful for improving cache hit rates and working around automatic caching issues.
491
563
  */
492
564
  promptCacheKey: z3.string().optional(),
565
+ /**
566
+ * Prompt cache behavior for GPT-5.6 and later models.
567
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
568
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
569
+ */
570
+ promptCacheOptions: z3.object({
571
+ mode: z3.enum(["implicit", "explicit"]).optional(),
572
+ ttl: z3.literal("30m").optional()
573
+ }).optional(),
493
574
  /**
494
575
  * The retention policy for the prompt cache.
495
576
  * - 'in_memory': Default. Standard prompt caching behavior.
496
577
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
497
- * Currently only available for 5.1 series models.
578
+ * Available for models before GPT-5.6 that support extended caching.
579
+ *
580
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
498
581
  *
499
582
  * @default 'in_memory'
500
583
  */
@@ -668,6 +751,7 @@ var OpenAIChatLanguageModel = class {
668
751
  reasoning_effort: openaiOptions.reasoningEffort,
669
752
  service_tier: openaiOptions.serviceTier,
670
753
  prompt_cache_key: openaiOptions.promptCacheKey,
754
+ prompt_cache_options: openaiOptions.promptCacheOptions,
671
755
  prompt_cache_retention: openaiOptions.promptCacheRetention,
672
756
  safety_identifier: openaiOptions.safetyIdentifier,
673
757
  // messages:
@@ -833,6 +917,11 @@ var OpenAIChatLanguageModel = class {
833
917
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
834
918
  providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
835
919
  }
920
+ if ((promptTokenDetails == null ? void 0 : promptTokenDetails.cache_write_tokens) != null) {
921
+ providerMetadata.openai.usage = {
922
+ cacheWriteTokens: promptTokenDetails.cache_write_tokens
923
+ };
924
+ }
836
925
  if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
837
926
  providerMetadata.openai.logprobs = choice.logprobs.content;
838
927
  }
@@ -896,7 +985,7 @@ var OpenAIChatLanguageModel = class {
896
985
  controller.enqueue({ type: "stream-start", warnings });
897
986
  },
898
987
  transform(chunk, controller) {
899
- 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;
988
+ 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;
900
989
  if (options.includeRawChunks) {
901
990
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
902
991
  }
@@ -927,18 +1016,23 @@ var OpenAIChatLanguageModel = class {
927
1016
  usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
928
1017
  usage.reasoningTokens = (_e = (_d = value.usage.completion_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
929
1018
  usage.cachedInputTokens = (_g = (_f = value.usage.prompt_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0;
930
- if (((_h = value.usage.completion_tokens_details) == null ? void 0 : _h.accepted_prediction_tokens) != null) {
931
- providerMetadata.openai.acceptedPredictionTokens = (_i = value.usage.completion_tokens_details) == null ? void 0 : _i.accepted_prediction_tokens;
1019
+ if (((_h = value.usage.prompt_tokens_details) == null ? void 0 : _h.cache_write_tokens) != null) {
1020
+ providerMetadata.openai.usage = {
1021
+ cacheWriteTokens: value.usage.prompt_tokens_details.cache_write_tokens
1022
+ };
1023
+ }
1024
+ if (((_i = value.usage.completion_tokens_details) == null ? void 0 : _i.accepted_prediction_tokens) != null) {
1025
+ providerMetadata.openai.acceptedPredictionTokens = (_j = value.usage.completion_tokens_details) == null ? void 0 : _j.accepted_prediction_tokens;
932
1026
  }
933
- if (((_j = value.usage.completion_tokens_details) == null ? void 0 : _j.rejected_prediction_tokens) != null) {
934
- providerMetadata.openai.rejectedPredictionTokens = (_k = value.usage.completion_tokens_details) == null ? void 0 : _k.rejected_prediction_tokens;
1027
+ if (((_k = value.usage.completion_tokens_details) == null ? void 0 : _k.rejected_prediction_tokens) != null) {
1028
+ providerMetadata.openai.rejectedPredictionTokens = (_l = value.usage.completion_tokens_details) == null ? void 0 : _l.rejected_prediction_tokens;
935
1029
  }
936
1030
  }
937
1031
  const choice = value.choices[0];
938
1032
  if ((choice == null ? void 0 : choice.finish_reason) != null) {
939
1033
  finishReason = mapOpenAIFinishReason(choice.finish_reason);
940
1034
  }
941
- if (((_l = choice == null ? void 0 : choice.logprobs) == null ? void 0 : _l.content) != null) {
1035
+ if (((_m = choice == null ? void 0 : choice.logprobs) == null ? void 0 : _m.content) != null) {
942
1036
  providerMetadata.openai.logprobs = choice.logprobs.content;
943
1037
  }
944
1038
  if ((choice == null ? void 0 : choice.delta) == null) {
@@ -972,7 +1066,7 @@ var OpenAIChatLanguageModel = class {
972
1066
  message: `Expected 'id' to be a string.`
973
1067
  });
974
1068
  }
975
- if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
1069
+ if (((_n = toolCallDelta.function) == null ? void 0 : _n.name) == null) {
976
1070
  throw new InvalidResponseDataError({
977
1071
  data: toolCallDelta,
978
1072
  message: `Expected 'function.name' to be a string.`
@@ -988,12 +1082,12 @@ var OpenAIChatLanguageModel = class {
988
1082
  type: "function",
989
1083
  function: {
990
1084
  name: toolCallDelta.function.name,
991
- arguments: (_n = toolCallDelta.function.arguments) != null ? _n : ""
1085
+ arguments: (_o = toolCallDelta.function.arguments) != null ? _o : ""
992
1086
  },
993
1087
  hasFinished: false
994
1088
  };
995
1089
  const toolCall2 = toolCalls[index];
996
- if (((_o = toolCall2.function) == null ? void 0 : _o.name) != null && ((_p = toolCall2.function) == null ? void 0 : _p.arguments) != null) {
1090
+ if (((_p = toolCall2.function) == null ? void 0 : _p.name) != null && ((_q = toolCall2.function) == null ? void 0 : _q.arguments) != null) {
997
1091
  if (toolCall2.function.arguments.length > 0) {
998
1092
  controller.enqueue({
999
1093
  type: "tool-input-delta",
@@ -1008,7 +1102,7 @@ var OpenAIChatLanguageModel = class {
1008
1102
  });
1009
1103
  controller.enqueue({
1010
1104
  type: "tool-call",
1011
- toolCallId: (_q = toolCall2.id) != null ? _q : generateId(),
1105
+ toolCallId: (_r = toolCall2.id) != null ? _r : generateId(),
1012
1106
  toolName: toolCall2.function.name,
1013
1107
  input: toolCall2.function.arguments
1014
1108
  });
@@ -1021,22 +1115,22 @@ var OpenAIChatLanguageModel = class {
1021
1115
  if (toolCall.hasFinished) {
1022
1116
  continue;
1023
1117
  }
1024
- if (((_r = toolCallDelta.function) == null ? void 0 : _r.arguments) != null) {
1025
- toolCall.function.arguments += (_t = (_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null ? _t : "";
1118
+ if (((_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null) {
1119
+ toolCall.function.arguments += (_u = (_t = toolCallDelta.function) == null ? void 0 : _t.arguments) != null ? _u : "";
1026
1120
  }
1027
1121
  controller.enqueue({
1028
1122
  type: "tool-input-delta",
1029
1123
  id: toolCall.id,
1030
- delta: (_u = toolCallDelta.function.arguments) != null ? _u : ""
1124
+ delta: (_v = toolCallDelta.function.arguments) != null ? _v : ""
1031
1125
  });
1032
- if (((_v = toolCall.function) == null ? void 0 : _v.name) != null && ((_w = toolCall.function) == null ? void 0 : _w.arguments) != null && isParsableJson(toolCall.function.arguments)) {
1126
+ if (((_w = toolCall.function) == null ? void 0 : _w.name) != null && ((_x = toolCall.function) == null ? void 0 : _x.arguments) != null && isParsableJson(toolCall.function.arguments)) {
1033
1127
  controller.enqueue({
1034
1128
  type: "tool-input-end",
1035
1129
  id: toolCall.id
1036
1130
  });
1037
1131
  controller.enqueue({
1038
1132
  type: "tool-call",
1039
- toolCallId: (_x = toolCall.id) != null ? _x : generateId(),
1133
+ toolCallId: (_y = toolCall.id) != null ? _y : generateId(),
1040
1134
  toolName: toolCall.function.name,
1041
1135
  input: toolCall.function.arguments
1042
1136
  });
@@ -2304,6 +2398,10 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema({
2304
2398
  });
2305
2399
 
2306
2400
  // src/responses/convert-to-openai-responses-input.ts
2401
+ function getPromptCacheBreakpoint2(providerOptions) {
2402
+ var _a;
2403
+ return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
2404
+ }
2307
2405
  function isFileId(data, prefixes) {
2308
2406
  if (!prefixes) return false;
2309
2407
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -2318,16 +2416,36 @@ async function convertToOpenAIResponsesInput({
2318
2416
  var _a, _b, _c, _d, _e, _f;
2319
2417
  let input = [];
2320
2418
  const warnings = [];
2321
- for (const { role, content } of prompt) {
2419
+ for (const { role, content, providerOptions } of prompt) {
2322
2420
  switch (role) {
2323
2421
  case "system": {
2324
2422
  switch (systemMessageMode) {
2325
2423
  case "system": {
2326
- input.push({ role: "system", content });
2424
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
2425
+ input.push({
2426
+ role: "system",
2427
+ content: promptCacheBreakpoint == null ? content : [
2428
+ {
2429
+ type: "input_text",
2430
+ text: content,
2431
+ prompt_cache_breakpoint: promptCacheBreakpoint
2432
+ }
2433
+ ]
2434
+ });
2327
2435
  break;
2328
2436
  }
2329
2437
  case "developer": {
2330
- input.push({ role: "developer", content });
2438
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
2439
+ input.push({
2440
+ role: "developer",
2441
+ content: promptCacheBreakpoint == null ? content : [
2442
+ {
2443
+ type: "input_text",
2444
+ text: content,
2445
+ prompt_cache_breakpoint: promptCacheBreakpoint
2446
+ }
2447
+ ]
2448
+ });
2331
2449
  break;
2332
2450
  }
2333
2451
  case "remove": {
@@ -2353,9 +2471,21 @@ async function convertToOpenAIResponsesInput({
2353
2471
  var _a2, _b2, _c2;
2354
2472
  switch (part.type) {
2355
2473
  case "text": {
2356
- return { type: "input_text", text: part.text };
2474
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2475
+ part.providerOptions
2476
+ );
2477
+ return {
2478
+ type: "input_text",
2479
+ text: part.text,
2480
+ ...promptCacheBreakpoint != null && {
2481
+ prompt_cache_breakpoint: promptCacheBreakpoint
2482
+ }
2483
+ };
2357
2484
  }
2358
2485
  case "file": {
2486
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2487
+ part.providerOptions
2488
+ );
2359
2489
  if (part.mediaType.startsWith("image/")) {
2360
2490
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2361
2491
  return {
@@ -2363,13 +2493,19 @@ async function convertToOpenAIResponsesInput({
2363
2493
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2364
2494
  image_url: `data:${mediaType};base64,${convertToBase642(part.data)}`
2365
2495
  },
2366
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2496
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail,
2497
+ ...promptCacheBreakpoint != null && {
2498
+ prompt_cache_breakpoint: promptCacheBreakpoint
2499
+ }
2367
2500
  };
2368
2501
  } else if (part.mediaType === "application/pdf") {
2369
2502
  if (part.data instanceof URL) {
2370
2503
  return {
2371
2504
  type: "input_file",
2372
- file_url: part.data.toString()
2505
+ file_url: part.data.toString(),
2506
+ ...promptCacheBreakpoint != null && {
2507
+ prompt_cache_breakpoint: promptCacheBreakpoint
2508
+ }
2373
2509
  };
2374
2510
  }
2375
2511
  return {
@@ -2377,6 +2513,9 @@ async function convertToOpenAIResponsesInput({
2377
2513
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2378
2514
  filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2379
2515
  file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
2516
+ },
2517
+ ...promptCacheBreakpoint != null && {
2518
+ prompt_cache_breakpoint: promptCacheBreakpoint
2380
2519
  }
2381
2520
  };
2382
2521
  } else {
@@ -2462,12 +2601,12 @@ async function convertToOpenAIResponsesInput({
2462
2601
  break;
2463
2602
  }
2464
2603
  case "reasoning": {
2465
- const providerOptions = await parseProviderOptions7({
2604
+ const providerOptions2 = await parseProviderOptions7({
2466
2605
  provider: "openai",
2467
2606
  providerOptions: part.providerOptions,
2468
2607
  schema: openaiResponsesReasoningProviderOptionsSchema
2469
2608
  });
2470
- const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2609
+ const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
2471
2610
  if (reasoningId != null) {
2472
2611
  const reasoningMessage = reasoningMessages[reasoningId];
2473
2612
  if (store) {
@@ -2496,14 +2635,14 @@ async function convertToOpenAIResponsesInput({
2496
2635
  reasoningMessages[reasoningId] = {
2497
2636
  type: "reasoning",
2498
2637
  id: reasoningId,
2499
- encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2638
+ encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
2500
2639
  summary: summaryParts
2501
2640
  };
2502
2641
  input.push(reasoningMessages[reasoningId]);
2503
2642
  } else {
2504
2643
  reasoningMessage.summary.push(...summaryParts);
2505
- if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
2506
- reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
2644
+ if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
2645
+ reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
2507
2646
  }
2508
2647
  }
2509
2648
  }
@@ -2522,6 +2661,9 @@ async function convertToOpenAIResponsesInput({
2522
2661
  case "tool": {
2523
2662
  for (const part of content) {
2524
2663
  const output = part.output;
2664
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2665
+ part.providerOptions
2666
+ );
2525
2667
  if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
2526
2668
  const parsedOutput = await validateTypes({
2527
2669
  value: output.value,
@@ -2538,26 +2680,51 @@ async function convertToOpenAIResponsesInput({
2538
2680
  switch (output.type) {
2539
2681
  case "text":
2540
2682
  case "error-text":
2541
- contentValue = output.value;
2683
+ contentValue = promptCacheBreakpoint == null ? output.value : [
2684
+ {
2685
+ type: "input_text",
2686
+ text: output.value,
2687
+ prompt_cache_breakpoint: promptCacheBreakpoint
2688
+ }
2689
+ ];
2542
2690
  break;
2543
2691
  case "json":
2544
2692
  case "error-json":
2545
- contentValue = JSON.stringify(output.value);
2693
+ contentValue = promptCacheBreakpoint == null ? JSON.stringify(output.value) : [
2694
+ {
2695
+ type: "input_text",
2696
+ text: JSON.stringify(output.value),
2697
+ prompt_cache_breakpoint: promptCacheBreakpoint
2698
+ }
2699
+ ];
2546
2700
  break;
2547
2701
  case "content":
2548
- contentValue = output.value.map((item) => {
2702
+ contentValue = output.value.map((item, index) => {
2703
+ const isBreakpoint = promptCacheBreakpoint != null && index === output.value.length - 1;
2549
2704
  switch (item.type) {
2550
2705
  case "text": {
2551
- return { type: "input_text", text: item.text };
2706
+ return {
2707
+ type: "input_text",
2708
+ text: item.text,
2709
+ ...isBreakpoint && {
2710
+ prompt_cache_breakpoint: promptCacheBreakpoint
2711
+ }
2712
+ };
2552
2713
  }
2553
2714
  case "media": {
2554
2715
  return item.mediaType.startsWith("image/") ? {
2555
2716
  type: "input_image",
2556
- image_url: `data:${item.mediaType};base64,${item.data}`
2717
+ image_url: `data:${item.mediaType};base64,${item.data}`,
2718
+ ...isBreakpoint && {
2719
+ prompt_cache_breakpoint: promptCacheBreakpoint
2720
+ }
2557
2721
  } : {
2558
2722
  type: "input_file",
2559
2723
  filename: "data",
2560
- file_data: `data:${item.mediaType};base64,${item.data}`
2724
+ file_data: `data:${item.mediaType};base64,${item.data}`,
2725
+ ...isBreakpoint && {
2726
+ prompt_cache_breakpoint: promptCacheBreakpoint
2727
+ }
2561
2728
  };
2562
2729
  }
2563
2730
  }
@@ -2648,6 +2815,7 @@ var openaiResponsesChunkSchema = lazyValidator12(
2648
2815
  input_tokens: z15.number(),
2649
2816
  input_tokens_details: z15.object({
2650
2817
  cached_tokens: z15.number().nullish(),
2818
+ cache_write_tokens: z15.number().nullish(),
2651
2819
  orchestration_input_tokens: z15.number().nullish(),
2652
2820
  orchestration_input_cached_tokens: z15.number().nullish()
2653
2821
  }).nullish(),
@@ -2657,6 +2825,9 @@ var openaiResponsesChunkSchema = lazyValidator12(
2657
2825
  orchestration_output_tokens: z15.number().nullish()
2658
2826
  }).nullish()
2659
2827
  }),
2828
+ reasoning: z15.object({
2829
+ context: z15.string().nullish()
2830
+ }).nullish(),
2660
2831
  service_tier: z15.string().nullish()
2661
2832
  })
2662
2833
  }),
@@ -3075,11 +3246,15 @@ var openaiResponsesResponseSchema = lazyValidator12(
3075
3246
  ])
3076
3247
  ).optional(),
3077
3248
  service_tier: z15.string().nullish(),
3249
+ reasoning: z15.object({
3250
+ context: z15.string().nullish()
3251
+ }).nullish(),
3078
3252
  incomplete_details: z15.object({ reason: z15.string() }).nullish(),
3079
3253
  usage: z15.object({
3080
3254
  input_tokens: z15.number(),
3081
3255
  input_tokens_details: z15.object({
3082
3256
  cached_tokens: z15.number().nullish(),
3257
+ cache_write_tokens: z15.number().nullish(),
3083
3258
  orchestration_input_tokens: z15.number().nullish(),
3084
3259
  orchestration_input_cached_tokens: z15.number().nullish()
3085
3260
  }).nullish(),
@@ -3142,7 +3317,11 @@ var openaiResponsesReasoningModelIds = [
3142
3317
  "gpt-5.4-nano",
3143
3318
  "gpt-5.4-nano-2026-03-17",
3144
3319
  "gpt-5.4-pro",
3145
- "gpt-5.4-pro-2026-03-05"
3320
+ "gpt-5.4-pro-2026-03-05",
3321
+ "gpt-5.6",
3322
+ "gpt-5.6-luna",
3323
+ "gpt-5.6-sol",
3324
+ "gpt-5.6-terra"
3146
3325
  ];
3147
3326
  var openaiResponsesModelIds = [
3148
3327
  "gpt-4.1",
@@ -3216,11 +3395,22 @@ var openaiResponsesProviderOptionsSchema = lazyValidator13(
3216
3395
  parallelToolCalls: z16.boolean().nullish(),
3217
3396
  previousResponseId: z16.string().nullish(),
3218
3397
  promptCacheKey: z16.string().nullish(),
3398
+ /**
3399
+ * Prompt cache behavior for GPT-5.6 and later models.
3400
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
3401
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
3402
+ */
3403
+ promptCacheOptions: z16.object({
3404
+ mode: z16.enum(["implicit", "explicit"]).optional(),
3405
+ ttl: z16.literal("30m").optional()
3406
+ }).optional(),
3219
3407
  /**
3220
3408
  * The retention policy for the prompt cache.
3221
3409
  * - 'in_memory': Default. Standard prompt caching behavior.
3222
3410
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
3223
- * Currently only available for 5.1 series models.
3411
+ * Available for models before GPT-5.6 that support extended caching.
3412
+ *
3413
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
3224
3414
  *
3225
3415
  * @default 'in_memory'
3226
3416
  */
@@ -3228,14 +3418,21 @@ var openaiResponsesProviderOptionsSchema = lazyValidator13(
3228
3418
  /**
3229
3419
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
3230
3420
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
3231
- * Valid values: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
3232
- *
3233
- * The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
3234
- * models. Also, the 'xhigh' type for `reasoningEffort` is only available for
3235
- * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
3236
- * an error.
3421
+ * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
3422
+ * Supported values vary by model.
3237
3423
  */
3238
3424
  reasoningEffort: z16.string().nullish(),
3425
+ /**
3426
+ * Controls how much model work GPT-5.6 performs before returning a final answer.
3427
+ * `standard` is the default. `pro` increases quality, latency, and token usage.
3428
+ */
3429
+ reasoningMode: z16.enum(["standard", "pro"]).optional(),
3430
+ /**
3431
+ * Controls which available reasoning items GPT-5.6 can use.
3432
+ * `auto` uses the model default, `current_turn` excludes reasoning from earlier
3433
+ * turns, and `all_turns` makes compatible earlier reasoning available.
3434
+ */
3435
+ reasoningContext: z16.enum(["auto", "current_turn", "all_turns"]).optional(),
3239
3436
  reasoningSummary: z16.string().nullish(),
3240
3437
  safetyIdentifier: z16.string().nullish(),
3241
3438
  serviceTier: z16.enum(["auto", "flex", "priority", "default"]).nullish(),
@@ -3784,18 +3981,25 @@ var OpenAIResponsesLanguageModel = class {
3784
3981
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
3785
3982
  include,
3786
3983
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
3984
+ prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
3787
3985
  prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
3788
3986
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
3789
3987
  top_logprobs: topLogprobs,
3790
3988
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
3791
3989
  // model-specific settings:
3792
- ...modelCapabilities.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
3990
+ ...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) && {
3793
3991
  reasoning: {
3794
3992
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
3795
3993
  effort: openaiOptions.reasoningEffort
3796
3994
  },
3797
3995
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
3798
3996
  summary: openaiOptions.reasoningSummary
3997
+ },
3998
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
3999
+ mode: openaiOptions.reasoningMode
4000
+ },
4001
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
4002
+ context: openaiOptions.reasoningContext
3799
4003
  }
3800
4004
  }
3801
4005
  }
@@ -3834,6 +4038,20 @@ var OpenAIResponsesLanguageModel = class {
3834
4038
  details: "reasoningSummary is not supported for non-reasoning models"
3835
4039
  });
3836
4040
  }
4041
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
4042
+ warnings.push({
4043
+ type: "unsupported-setting",
4044
+ setting: "reasoningMode",
4045
+ details: "reasoningMode is not supported for non-reasoning models"
4046
+ });
4047
+ }
4048
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
4049
+ warnings.push({
4050
+ type: "unsupported-setting",
4051
+ setting: "reasoningContext",
4052
+ details: "reasoningContext is not supported for non-reasoning models"
4053
+ });
4054
+ }
3837
4055
  }
3838
4056
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
3839
4057
  warnings.push({
@@ -3872,7 +4090,7 @@ var OpenAIResponsesLanguageModel = class {
3872
4090
  };
3873
4091
  }
3874
4092
  async doGenerate(options) {
3875
- 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;
4093
+ 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;
3876
4094
  const {
3877
4095
  args: body,
3878
4096
  warnings,
@@ -4156,23 +4374,26 @@ var OpenAIResponsesLanguageModel = class {
4156
4374
  if (typeof response.service_tier === "string") {
4157
4375
  providerMetadata[providerKey].serviceTier = response.service_tier;
4158
4376
  }
4377
+ if (((_x = response.reasoning) == null ? void 0 : _x.context) != null) {
4378
+ providerMetadata[providerKey].reasoningContext = response.reasoning.context;
4379
+ }
4159
4380
  const usage = response.usage;
4160
- const orchestrationUsage = getOrchestrationUsageMetadata(usage);
4161
- if (orchestrationUsage != null) {
4162
- providerMetadata[providerKey].usage = orchestrationUsage;
4381
+ const responsesUsage = getResponsesUsageMetadata(usage);
4382
+ if (responsesUsage != null) {
4383
+ providerMetadata[providerKey].usage = responsesUsage;
4163
4384
  }
4164
4385
  return {
4165
4386
  content,
4166
4387
  finishReason: mapOpenAIResponseFinishReason({
4167
- finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
4388
+ finishReason: (_y = response.incomplete_details) == null ? void 0 : _y.reason,
4168
4389
  hasFunctionCall
4169
4390
  }),
4170
4391
  usage: {
4171
4392
  inputTokens: usage.input_tokens,
4172
4393
  outputTokens: usage.output_tokens,
4173
4394
  totalTokens: usage.input_tokens + usage.output_tokens,
4174
- reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
4175
- cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
4395
+ reasoningTokens: (_A = (_z = usage.output_tokens_details) == null ? void 0 : _z.reasoning_tokens) != null ? _A : void 0,
4396
+ cachedInputTokens: (_C = (_B = usage.input_tokens_details) == null ? void 0 : _B.cached_tokens) != null ? _C : void 0
4176
4397
  },
4177
4398
  request: { body },
4178
4399
  response: {
@@ -4226,7 +4447,8 @@ var OpenAIResponsesLanguageModel = class {
4226
4447
  let hasFunctionCall = false;
4227
4448
  const activeReasoning = {};
4228
4449
  let serviceTier;
4229
- let orchestrationUsage;
4450
+ let reasoningContext;
4451
+ let responsesUsage;
4230
4452
  return {
4231
4453
  stream: response.pipeThrough(
4232
4454
  new TransformStream({
@@ -4234,7 +4456,7 @@ var OpenAIResponsesLanguageModel = class {
4234
4456
  controller.enqueue({ type: "stream-start", warnings });
4235
4457
  },
4236
4458
  transform(chunk, controller) {
4237
- 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;
4459
+ 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;
4238
4460
  if (options.includeRawChunks) {
4239
4461
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
4240
4462
  }
@@ -4627,16 +4849,17 @@ var OpenAIResponsesLanguageModel = class {
4627
4849
  if (typeof value.response.service_tier === "string") {
4628
4850
  serviceTier = value.response.service_tier;
4629
4851
  }
4630
- orchestrationUsage = getOrchestrationUsageMetadata(
4631
- value.response.usage
4632
- );
4852
+ if (((_p = value.response.reasoning) == null ? void 0 : _p.context) != null) {
4853
+ reasoningContext = value.response.reasoning.context;
4854
+ }
4855
+ responsesUsage = getResponsesUsageMetadata(value.response.usage);
4633
4856
  } else if (isResponseAnnotationAddedChunk(value)) {
4634
4857
  ongoingAnnotations.push(value.annotation);
4635
4858
  if (value.annotation.type === "url_citation") {
4636
4859
  controller.enqueue({
4637
4860
  type: "source",
4638
4861
  sourceType: "url",
4639
- id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
4862
+ id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId2(),
4640
4863
  url: value.annotation.url,
4641
4864
  title: value.annotation.title
4642
4865
  });
@@ -4644,10 +4867,10 @@ var OpenAIResponsesLanguageModel = class {
4644
4867
  controller.enqueue({
4645
4868
  type: "source",
4646
4869
  sourceType: "document",
4647
- id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
4870
+ id: (_v = (_u = (_t = self.config).generateId) == null ? void 0 : _u.call(_t)) != null ? _v : generateId2(),
4648
4871
  mediaType: "text/plain",
4649
- title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
4650
- filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
4872
+ title: (_x = (_w = value.annotation.quote) != null ? _w : value.annotation.filename) != null ? _x : "Document",
4873
+ filename: (_y = value.annotation.filename) != null ? _y : value.annotation.file_id,
4651
4874
  ...value.annotation.file_id ? {
4652
4875
  providerMetadata: {
4653
4876
  [providerKey]: {
@@ -4673,8 +4896,11 @@ var OpenAIResponsesLanguageModel = class {
4673
4896
  if (serviceTier !== void 0) {
4674
4897
  providerMetadata[providerKey].serviceTier = serviceTier;
4675
4898
  }
4676
- if (orchestrationUsage != null) {
4677
- providerMetadata[providerKey].usage = orchestrationUsage;
4899
+ if (reasoningContext !== void 0) {
4900
+ providerMetadata[providerKey].reasoningContext = reasoningContext;
4901
+ }
4902
+ if (responsesUsage != null) {
4903
+ providerMetadata[providerKey].usage = responsesUsage;
4678
4904
  }
4679
4905
  controller.enqueue({
4680
4906
  type: "finish",
@@ -4744,15 +4970,17 @@ function mapWebSearchOutput(action) {
4744
4970
  };
4745
4971
  }
4746
4972
  }
4747
- function getOrchestrationUsageMetadata(usage) {
4748
- var _a, _b, _c;
4749
- const orchestrationInputTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.orchestration_input_tokens;
4750
- const orchestrationInputCachedTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_cached_tokens;
4751
- const orchestrationOutputTokens = (_c = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _c.orchestration_output_tokens;
4752
- if (orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
4973
+ function getResponsesUsageMetadata(usage) {
4974
+ var _a, _b, _c, _d;
4975
+ const cacheWriteTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.cache_write_tokens;
4976
+ const orchestrationInputTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_tokens;
4977
+ const orchestrationInputCachedTokens = (_c = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _c.orchestration_input_cached_tokens;
4978
+ const orchestrationOutputTokens = (_d = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _d.orchestration_output_tokens;
4979
+ if (cacheWriteTokens == null && orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
4753
4980
  return void 0;
4754
4981
  }
4755
4982
  return {
4983
+ ...cacheWriteTokens != null && { cacheWriteTokens },
4756
4984
  ...orchestrationInputTokens != null && { orchestrationInputTokens },
4757
4985
  ...orchestrationInputCachedTokens != null && {
4758
4986
  orchestrationInputCachedTokens