@ai-sdk/openai 3.0.83 → 3.0.84

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.
@@ -171,7 +171,7 @@ function isHttpErrorStatusCode(value) {
171
171
 
172
172
  // src/chat/convert-openai-chat-usage.ts
173
173
  function convertOpenAIChatUsage(usage) {
174
- var _a, _b, _c, _d, _e, _f;
174
+ var _a, _b, _c, _d, _e, _f, _g, _h;
175
175
  if (usage == null) {
176
176
  return {
177
177
  inputTokens: {
@@ -191,13 +191,14 @@ function convertOpenAIChatUsage(usage) {
191
191
  const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
192
192
  const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
193
193
  const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
194
- const reasoningTokens = (_f = (_e = usage.completion_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
194
+ const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
195
+ const reasoningTokens = (_h = (_g = usage.completion_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : 0;
195
196
  return {
196
197
  inputTokens: {
197
198
  total: promptTokens,
198
- noCache: promptTokens - cachedTokens,
199
+ noCache: promptTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
199
200
  cacheRead: cachedTokens,
200
- cacheWrite: void 0
201
+ cacheWrite: cacheWriteTokens
201
202
  },
202
203
  outputTokens: {
203
204
  total: completionTokens,
@@ -216,23 +217,47 @@ import { convertToBase64 } from "@ai-sdk/provider-utils";
216
217
  function serializeToolCallArguments(input) {
217
218
  return JSON.stringify(input === void 0 ? {} : input);
218
219
  }
220
+ function getPromptCacheBreakpoint(providerOptions) {
221
+ var _a;
222
+ return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
223
+ }
219
224
  function convertToOpenAIChatMessages({
220
225
  prompt,
221
226
  systemMessageMode = "system"
222
227
  }) {
223
- var _a;
228
+ var _a, _b;
224
229
  const messages = [];
225
230
  const warnings = [];
226
- for (const { role, content } of prompt) {
231
+ for (const { role, content, providerOptions } of prompt) {
227
232
  switch (role) {
228
233
  case "system": {
229
234
  switch (systemMessageMode) {
230
235
  case "system": {
231
- messages.push({ role: "system", content });
236
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
237
+ messages.push({
238
+ role: "system",
239
+ content: promptCacheBreakpoint == null ? content : [
240
+ {
241
+ type: "text",
242
+ text: content,
243
+ prompt_cache_breakpoint: promptCacheBreakpoint
244
+ }
245
+ ]
246
+ });
232
247
  break;
233
248
  }
234
249
  case "developer": {
235
- messages.push({ role: "developer", content });
250
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
251
+ messages.push({
252
+ role: "developer",
253
+ content: promptCacheBreakpoint == null ? content : [
254
+ {
255
+ type: "text",
256
+ text: content,
257
+ prompt_cache_breakpoint: promptCacheBreakpoint
258
+ }
259
+ ]
260
+ });
236
261
  break;
237
262
  }
238
263
  case "remove": {
@@ -252,19 +277,31 @@ function convertToOpenAIChatMessages({
252
277
  break;
253
278
  }
254
279
  case "user": {
255
- if (content.length === 1 && content[0].type === "text") {
280
+ if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
256
281
  messages.push({ role: "user", content: content[0].text });
257
282
  break;
258
283
  }
259
284
  messages.push({
260
285
  role: "user",
261
286
  content: content.map((part, index) => {
262
- var _a2, _b, _c;
287
+ var _a2, _b2, _c;
263
288
  switch (part.type) {
264
289
  case "text": {
265
- return { type: "text", text: part.text };
290
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
291
+ part.providerOptions
292
+ );
293
+ return {
294
+ type: "text",
295
+ text: part.text,
296
+ ...promptCacheBreakpoint != null && {
297
+ prompt_cache_breakpoint: promptCacheBreakpoint
298
+ }
299
+ };
266
300
  }
267
301
  case "file": {
302
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
303
+ part.providerOptions
304
+ );
268
305
  if (part.mediaType.startsWith("image/")) {
269
306
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
270
307
  return {
@@ -272,7 +309,10 @@ function convertToOpenAIChatMessages({
272
309
  image_url: {
273
310
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
274
311
  // OpenAI specific extension: image detail
275
- detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
312
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
313
+ },
314
+ ...promptCacheBreakpoint != null && {
315
+ prompt_cache_breakpoint: promptCacheBreakpoint
276
316
  }
277
317
  };
278
318
  } else if (part.mediaType.startsWith("audio/")) {
@@ -288,6 +328,9 @@ function convertToOpenAIChatMessages({
288
328
  input_audio: {
289
329
  data: convertToBase64(part.data),
290
330
  format: "wav"
331
+ },
332
+ ...promptCacheBreakpoint != null && {
333
+ prompt_cache_breakpoint: promptCacheBreakpoint
291
334
  }
292
335
  };
293
336
  }
@@ -298,6 +341,9 @@ function convertToOpenAIChatMessages({
298
341
  input_audio: {
299
342
  data: convertToBase64(part.data),
300
343
  format: "mp3"
344
+ },
345
+ ...promptCacheBreakpoint != null && {
346
+ prompt_cache_breakpoint: promptCacheBreakpoint
301
347
  }
302
348
  };
303
349
  }
@@ -318,6 +364,9 @@ function convertToOpenAIChatMessages({
318
364
  file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
319
365
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
320
366
  file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
367
+ },
368
+ ...promptCacheBreakpoint != null && {
369
+ prompt_cache_breakpoint: promptCacheBreakpoint
321
370
  }
322
371
  };
323
372
  } else {
@@ -333,11 +382,24 @@ function convertToOpenAIChatMessages({
333
382
  }
334
383
  case "assistant": {
335
384
  let text = "";
385
+ const textParts = [];
386
+ let hasPromptCacheBreakpoint = false;
336
387
  const toolCalls = [];
337
388
  for (const part of content) {
338
389
  switch (part.type) {
339
390
  case "text": {
391
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
392
+ part.providerOptions
393
+ );
340
394
  text += part.text;
395
+ textParts.push({
396
+ type: "text",
397
+ text: part.text,
398
+ ...promptCacheBreakpoint != null && {
399
+ prompt_cache_breakpoint: promptCacheBreakpoint
400
+ }
401
+ });
402
+ hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
341
403
  break;
342
404
  }
343
405
  case "tool-call": {
@@ -355,7 +417,7 @@ function convertToOpenAIChatMessages({
355
417
  }
356
418
  messages.push({
357
419
  role: "assistant",
358
- content: toolCalls.length > 0 ? text || null : text,
420
+ content: hasPromptCacheBreakpoint ? textParts : toolCalls.length > 0 ? text || null : text,
359
421
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0
360
422
  });
361
423
  break;
@@ -366,6 +428,7 @@ function convertToOpenAIChatMessages({
366
428
  continue;
367
429
  }
368
430
  const output = toolResponse.output;
431
+ const promptCacheBreakpoint = (_a = output.type === "content" ? output.value.map((part) => getPromptCacheBreakpoint(part.providerOptions)).find((breakpoint) => breakpoint != null) : getPromptCacheBreakpoint(output.providerOptions)) != null ? _a : getPromptCacheBreakpoint(toolResponse.providerOptions);
369
432
  let contentValue;
370
433
  switch (output.type) {
371
434
  case "text":
@@ -373,7 +436,7 @@ function convertToOpenAIChatMessages({
373
436
  contentValue = output.value;
374
437
  break;
375
438
  case "execution-denied":
376
- contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
439
+ contentValue = (_b = output.reason) != null ? _b : "Tool call execution denied.";
377
440
  break;
378
441
  case "content":
379
442
  case "json":
@@ -384,7 +447,13 @@ function convertToOpenAIChatMessages({
384
447
  messages.push({
385
448
  role: "tool",
386
449
  tool_call_id: toolResponse.toolCallId,
387
- content: contentValue
450
+ content: promptCacheBreakpoint == null ? contentValue : [
451
+ {
452
+ type: "text",
453
+ text: contentValue,
454
+ prompt_cache_breakpoint: promptCacheBreakpoint
455
+ }
456
+ ]
388
457
  });
389
458
  }
390
459
  break;
@@ -490,7 +559,8 @@ var openaiChatResponseSchema = lazySchema(
490
559
  completion_tokens: z2.number().nullish(),
491
560
  total_tokens: z2.number().nullish(),
492
561
  prompt_tokens_details: z2.object({
493
- cached_tokens: z2.number().nullish()
562
+ cached_tokens: z2.number().nullish(),
563
+ cache_write_tokens: z2.number().nullish()
494
564
  }).nullish(),
495
565
  completion_tokens_details: z2.object({
496
566
  reasoning_tokens: z2.number().nullish(),
@@ -559,7 +629,8 @@ var openaiChatChunkSchema = lazySchema(
559
629
  completion_tokens: z2.number().nullish(),
560
630
  total_tokens: z2.number().nullish(),
561
631
  prompt_tokens_details: z2.object({
562
- cached_tokens: z2.number().nullish()
632
+ cached_tokens: z2.number().nullish(),
633
+ cache_write_tokens: z2.number().nullish()
563
634
  }).nullish(),
564
635
  completion_tokens_details: z2.object({
565
636
  reasoning_tokens: z2.number().nullish(),
@@ -611,7 +682,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
611
682
  /**
612
683
  * Reasoning effort for reasoning models. Defaults to `medium`.
613
684
  */
614
- reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
685
+ reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
615
686
  /**
616
687
  * Maximum number of completion tokens to generate. Useful for reasoning models.
617
688
  */
@@ -655,11 +726,22 @@ var openaiLanguageModelChatOptions = lazySchema2(
655
726
  * Useful for improving cache hit rates and working around automatic caching issues.
656
727
  */
657
728
  promptCacheKey: z3.string().optional(),
729
+ /**
730
+ * Prompt cache behavior for GPT-5.6 and later models.
731
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
732
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
733
+ */
734
+ promptCacheOptions: z3.object({
735
+ mode: z3.enum(["implicit", "explicit"]).optional(),
736
+ ttl: z3.literal("30m").optional()
737
+ }).optional(),
658
738
  /**
659
739
  * The retention policy for the prompt cache.
660
740
  * - 'in_memory': Default. Standard prompt caching behavior.
661
741
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
662
- * Currently only available for 5.1 series models.
742
+ * Available for models before GPT-5.6 that support extended caching.
743
+ *
744
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
663
745
  *
664
746
  * @default 'in_memory'
665
747
  */
@@ -843,6 +925,7 @@ var OpenAIChatLanguageModel = class {
843
925
  reasoning_effort: openaiOptions.reasoningEffort,
844
926
  service_tier: openaiOptions.serviceTier,
845
927
  prompt_cache_key: openaiOptions.promptCacheKey,
928
+ prompt_cache_options: openaiOptions.promptCacheOptions,
846
929
  prompt_cache_retention: openaiOptions.promptCacheRetention,
847
930
  safety_identifier: openaiOptions.safetyIdentifier,
848
931
  // messages:
@@ -2600,7 +2683,7 @@ import {
2600
2683
 
2601
2684
  // src/responses/convert-openai-responses-usage.ts
2602
2685
  function convertOpenAIResponsesUsage(usage) {
2603
- var _a, _b, _c, _d;
2686
+ var _a, _b, _c, _d, _e, _f;
2604
2687
  if (usage == null) {
2605
2688
  return {
2606
2689
  inputTokens: {
@@ -2620,13 +2703,14 @@ function convertOpenAIResponsesUsage(usage) {
2620
2703
  const inputTokens = usage.input_tokens;
2621
2704
  const outputTokens = usage.output_tokens;
2622
2705
  const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
2623
- const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0;
2706
+ const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
2707
+ const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
2624
2708
  return {
2625
2709
  inputTokens: {
2626
2710
  total: inputTokens,
2627
- noCache: inputTokens - cachedTokens,
2711
+ noCache: inputTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
2628
2712
  cacheRead: cachedTokens,
2629
- cacheWrite: void 0
2713
+ cacheWrite: cacheWriteTokens
2630
2714
  },
2631
2715
  outputTokens: {
2632
2716
  total: outputTokens,
@@ -2868,6 +2952,10 @@ var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
2868
2952
  function serializeToolCallArguments2(input) {
2869
2953
  return JSON.stringify(input === void 0 ? {} : input);
2870
2954
  }
2955
+ function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
2956
+ var _a;
2957
+ return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
2958
+ }
2871
2959
  function isFileId(data, prefixes) {
2872
2960
  if (!prefixes) return false;
2873
2961
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -2891,16 +2979,42 @@ async function convertToOpenAIResponsesInput({
2891
2979
  let input = [];
2892
2980
  const warnings = [];
2893
2981
  const processedApprovalIds = /* @__PURE__ */ new Set();
2894
- for (const { role, content } of prompt) {
2982
+ for (const { role, content, providerOptions } of prompt) {
2895
2983
  switch (role) {
2896
2984
  case "system": {
2897
2985
  switch (systemMessageMode) {
2898
2986
  case "system": {
2899
- input.push({ role: "system", content });
2987
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
2988
+ providerOptions,
2989
+ providerOptionsName
2990
+ );
2991
+ input.push({
2992
+ role: "system",
2993
+ content: promptCacheBreakpoint == null ? content : [
2994
+ {
2995
+ type: "input_text",
2996
+ text: content,
2997
+ prompt_cache_breakpoint: promptCacheBreakpoint
2998
+ }
2999
+ ]
3000
+ });
2900
3001
  break;
2901
3002
  }
2902
3003
  case "developer": {
2903
- input.push({ role: "developer", content });
3004
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3005
+ providerOptions,
3006
+ providerOptionsName
3007
+ );
3008
+ input.push({
3009
+ role: "developer",
3010
+ content: promptCacheBreakpoint == null ? content : [
3011
+ {
3012
+ type: "input_text",
3013
+ text: content,
3014
+ prompt_cache_breakpoint: promptCacheBreakpoint
3015
+ }
3016
+ ]
3017
+ });
2904
3018
  break;
2905
3019
  }
2906
3020
  case "remove": {
@@ -2926,9 +3040,23 @@ async function convertToOpenAIResponsesInput({
2926
3040
  var _a2, _b2, _c2;
2927
3041
  switch (part.type) {
2928
3042
  case "text": {
2929
- return { type: "input_text", text: part.text };
3043
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3044
+ part.providerOptions,
3045
+ providerOptionsName
3046
+ );
3047
+ return {
3048
+ type: "input_text",
3049
+ text: part.text,
3050
+ ...promptCacheBreakpoint != null && {
3051
+ prompt_cache_breakpoint: promptCacheBreakpoint
3052
+ }
3053
+ };
2930
3054
  }
2931
3055
  case "file": {
3056
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3057
+ part.providerOptions,
3058
+ providerOptionsName
3059
+ );
2932
3060
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2933
3061
  if (mediaType.startsWith("image/")) {
2934
3062
  return {
@@ -2936,13 +3064,19 @@ async function convertToOpenAIResponsesInput({
2936
3064
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2937
3065
  image_url: `data:${mediaType};base64,${convertToBase642(part.data)}`
2938
3066
  },
2939
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
3067
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3068
+ ...promptCacheBreakpoint != null && {
3069
+ prompt_cache_breakpoint: promptCacheBreakpoint
3070
+ }
2940
3071
  };
2941
3072
  }
2942
3073
  if (part.data instanceof URL) {
2943
3074
  return {
2944
3075
  type: "input_file",
2945
- file_url: part.data.toString()
3076
+ file_url: part.data.toString(),
3077
+ ...promptCacheBreakpoint != null && {
3078
+ prompt_cache_breakpoint: promptCacheBreakpoint
3079
+ }
2946
3080
  };
2947
3081
  }
2948
3082
  if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
@@ -2955,6 +3089,9 @@ async function convertToOpenAIResponsesInput({
2955
3089
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2956
3090
  filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
2957
3091
  file_data: `data:${mediaType};base64,${convertToBase642(part.data)}`
3092
+ },
3093
+ ...promptCacheBreakpoint != null && {
3094
+ prompt_cache_breakpoint: promptCacheBreakpoint
2958
3095
  }
2959
3096
  };
2960
3097
  }
@@ -3167,12 +3304,12 @@ async function convertToOpenAIResponsesInput({
3167
3304
  break;
3168
3305
  }
3169
3306
  case "reasoning": {
3170
- const providerOptions = await parseProviderOptions7({
3307
+ const providerOptions2 = await parseProviderOptions7({
3171
3308
  provider: providerOptionsName,
3172
3309
  providerOptions: part.providerOptions,
3173
3310
  schema: openaiResponsesReasoningProviderOptionsSchema
3174
3311
  });
3175
- const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
3312
+ const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
3176
3313
  if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
3177
3314
  break;
3178
3315
  }
@@ -3204,19 +3341,19 @@ async function convertToOpenAIResponsesInput({
3204
3341
  reasoningMessages[reasoningId] = {
3205
3342
  type: "reasoning",
3206
3343
  id: reasoningId,
3207
- encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
3344
+ encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
3208
3345
  summary: summaryParts
3209
3346
  };
3210
3347
  input.push(reasoningMessages[reasoningId]);
3211
3348
  } else {
3212
3349
  reasoningMessage.summary.push(...summaryParts);
3213
- if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
3214
- reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
3350
+ if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
3351
+ reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
3215
3352
  }
3216
3353
  }
3217
3354
  }
3218
3355
  } else {
3219
- const encryptedContent = providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent;
3356
+ const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent;
3220
3357
  if (encryptedContent != null) {
3221
3358
  const summaryParts = [];
3222
3359
  if (part.text.length > 0) {
@@ -3349,31 +3486,53 @@ async function convertToOpenAIResponsesInput({
3349
3486
  case "content":
3350
3487
  outputValue = output.value.map((item) => {
3351
3488
  var _a2, _b2, _c2, _d2, _e2;
3489
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3490
+ item.providerOptions,
3491
+ providerOptionsName
3492
+ );
3352
3493
  switch (item.type) {
3353
3494
  case "text":
3354
- return { type: "input_text", text: item.text };
3495
+ return {
3496
+ type: "input_text",
3497
+ text: item.text,
3498
+ ...promptCacheBreakpoint != null && {
3499
+ prompt_cache_breakpoint: promptCacheBreakpoint
3500
+ }
3501
+ };
3355
3502
  case "image-data":
3356
3503
  return {
3357
3504
  type: "input_image",
3358
3505
  image_url: `data:${item.mediaType};base64,${item.data}`,
3359
- detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
3506
+ detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3507
+ ...promptCacheBreakpoint != null && {
3508
+ prompt_cache_breakpoint: promptCacheBreakpoint
3509
+ }
3360
3510
  };
3361
3511
  case "image-url":
3362
3512
  return {
3363
3513
  type: "input_image",
3364
3514
  image_url: item.url,
3365
- detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
3515
+ detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
3516
+ ...promptCacheBreakpoint != null && {
3517
+ prompt_cache_breakpoint: promptCacheBreakpoint
3518
+ }
3366
3519
  };
3367
3520
  case "file-data":
3368
3521
  return {
3369
3522
  type: "input_file",
3370
3523
  filename: (_e2 = item.filename) != null ? _e2 : "data",
3371
- file_data: `data:${item.mediaType};base64,${item.data}`
3524
+ file_data: `data:${item.mediaType};base64,${item.data}`,
3525
+ ...promptCacheBreakpoint != null && {
3526
+ prompt_cache_breakpoint: promptCacheBreakpoint
3527
+ }
3372
3528
  };
3373
3529
  case "file-url":
3374
3530
  return {
3375
3531
  type: "input_file",
3376
- file_url: item.url
3532
+ file_url: item.url,
3533
+ ...promptCacheBreakpoint != null && {
3534
+ prompt_cache_breakpoint: promptCacheBreakpoint
3535
+ }
3377
3536
  };
3378
3537
  default:
3379
3538
  warnings.push({
@@ -3410,35 +3569,57 @@ async function convertToOpenAIResponsesInput({
3410
3569
  case "content":
3411
3570
  contentValue = output.value.map((item) => {
3412
3571
  var _a2, _b2, _c2, _d2, _e2;
3572
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3573
+ item.providerOptions,
3574
+ providerOptionsName
3575
+ );
3413
3576
  switch (item.type) {
3414
3577
  case "text": {
3415
- return { type: "input_text", text: item.text };
3578
+ return {
3579
+ type: "input_text",
3580
+ text: item.text,
3581
+ ...promptCacheBreakpoint != null && {
3582
+ prompt_cache_breakpoint: promptCacheBreakpoint
3583
+ }
3584
+ };
3416
3585
  }
3417
3586
  case "image-data": {
3418
3587
  return {
3419
3588
  type: "input_image",
3420
3589
  image_url: `data:${item.mediaType};base64,${item.data}`,
3421
- detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
3590
+ detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3591
+ ...promptCacheBreakpoint != null && {
3592
+ prompt_cache_breakpoint: promptCacheBreakpoint
3593
+ }
3422
3594
  };
3423
3595
  }
3424
3596
  case "image-url": {
3425
3597
  return {
3426
3598
  type: "input_image",
3427
3599
  image_url: item.url,
3428
- detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
3600
+ detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
3601
+ ...promptCacheBreakpoint != null && {
3602
+ prompt_cache_breakpoint: promptCacheBreakpoint
3603
+ }
3429
3604
  };
3430
3605
  }
3431
3606
  case "file-data": {
3432
3607
  return {
3433
3608
  type: "input_file",
3434
3609
  filename: (_e2 = item.filename) != null ? _e2 : "data",
3435
- file_data: `data:${item.mediaType};base64,${item.data}`
3610
+ file_data: `data:${item.mediaType};base64,${item.data}`,
3611
+ ...promptCacheBreakpoint != null && {
3612
+ prompt_cache_breakpoint: promptCacheBreakpoint
3613
+ }
3436
3614
  };
3437
3615
  }
3438
3616
  case "file-url": {
3439
3617
  return {
3440
3618
  type: "input_file",
3441
- file_url: item.url
3619
+ file_url: item.url,
3620
+ ...promptCacheBreakpoint != null && {
3621
+ prompt_cache_breakpoint: promptCacheBreakpoint
3622
+ }
3442
3623
  };
3443
3624
  }
3444
3625
  default: {
@@ -3563,6 +3744,7 @@ var openaiResponsesChunkSchema = lazySchema16(
3563
3744
  input_tokens: z18.number(),
3564
3745
  input_tokens_details: z18.object({
3565
3746
  cached_tokens: z18.number().nullish(),
3747
+ cache_write_tokens: z18.number().nullish(),
3566
3748
  orchestration_input_tokens: z18.number().nullish(),
3567
3749
  orchestration_input_cached_tokens: z18.number().nullish()
3568
3750
  }).nullish(),
@@ -3572,6 +3754,9 @@ var openaiResponsesChunkSchema = lazySchema16(
3572
3754
  orchestration_output_tokens: z18.number().nullish()
3573
3755
  }).nullish()
3574
3756
  }),
3757
+ reasoning: z18.object({
3758
+ context: z18.string().nullish()
3759
+ }).nullish(),
3575
3760
  service_tier: z18.string().nullish()
3576
3761
  })
3577
3762
  }),
@@ -3588,6 +3773,7 @@ var openaiResponsesChunkSchema = lazySchema16(
3588
3773
  input_tokens: z18.number(),
3589
3774
  input_tokens_details: z18.object({
3590
3775
  cached_tokens: z18.number().nullish(),
3776
+ cache_write_tokens: z18.number().nullish(),
3591
3777
  orchestration_input_tokens: z18.number().nullish(),
3592
3778
  orchestration_input_cached_tokens: z18.number().nullish()
3593
3779
  }).nullish(),
@@ -3597,6 +3783,9 @@ var openaiResponsesChunkSchema = lazySchema16(
3597
3783
  orchestration_output_tokens: z18.number().nullish()
3598
3784
  }).nullish()
3599
3785
  }).nullish(),
3786
+ reasoning: z18.object({
3787
+ context: z18.string().nullish()
3788
+ }).nullish(),
3600
3789
  service_tier: z18.string().nullish()
3601
3790
  })
3602
3791
  }),
@@ -4368,11 +4557,15 @@ var openaiResponsesResponseSchema = lazySchema16(
4368
4557
  ])
4369
4558
  ).optional(),
4370
4559
  service_tier: z18.string().nullish(),
4560
+ reasoning: z18.object({
4561
+ context: z18.string().nullish()
4562
+ }).nullish(),
4371
4563
  incomplete_details: z18.object({ reason: z18.string() }).nullish(),
4372
4564
  usage: z18.object({
4373
4565
  input_tokens: z18.number(),
4374
4566
  input_tokens_details: z18.object({
4375
4567
  cached_tokens: z18.number().nullish(),
4568
+ cache_write_tokens: z18.number().nullish(),
4376
4569
  orchestration_input_tokens: z18.number().nullish(),
4377
4570
  orchestration_input_cached_tokens: z18.number().nullish()
4378
4571
  }).nullish(),
@@ -4530,11 +4723,22 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
4530
4723
  * Sets a cache key to tie this prompt to cached prefixes for better caching performance.
4531
4724
  */
4532
4725
  promptCacheKey: z19.string().nullish(),
4726
+ /**
4727
+ * Prompt cache behavior for GPT-5.6 and later models.
4728
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
4729
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
4730
+ */
4731
+ promptCacheOptions: z19.object({
4732
+ mode: z19.enum(["implicit", "explicit"]).optional(),
4733
+ ttl: z19.literal("30m").optional()
4734
+ }).optional(),
4533
4735
  /**
4534
4736
  * The retention policy for the prompt cache.
4535
4737
  * - 'in_memory': Default. Standard prompt caching behavior.
4536
4738
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
4537
- * Currently only available for 5.1 series models.
4739
+ * Available for models before GPT-5.6 that support extended caching.
4740
+ *
4741
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
4538
4742
  *
4539
4743
  * @default 'in_memory'
4540
4744
  */
@@ -4542,14 +4746,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
4542
4746
  /**
4543
4747
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
4544
4748
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
4545
- * Valid values: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
4546
- *
4547
- * The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
4548
- * models. Also, the 'xhigh' type for `reasoningEffort` is only available for
4549
- * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
4550
- * an error.
4749
+ * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
4750
+ * Supported values vary by model.
4551
4751
  */
4552
4752
  reasoningEffort: z19.string().nullish(),
4753
+ /**
4754
+ * Controls how much model work GPT-5.6 performs before returning a final answer.
4755
+ * `standard` is the default. `pro` increases quality, latency, and token usage.
4756
+ */
4757
+ reasoningMode: z19.enum(["standard", "pro"]).optional(),
4758
+ /**
4759
+ * Controls which available reasoning items GPT-5.6 can use.
4760
+ * `auto` uses the model default, `current_turn` excludes reasoning from earlier
4761
+ * turns, and `all_turns` makes compatible earlier reasoning available.
4762
+ */
4763
+ reasoningContext: z19.enum(["auto", "current_turn", "all_turns"]).optional(),
4553
4764
  /**
4554
4765
  * Controls reasoning summary output from the model.
4555
4766
  * Set to "auto" to automatically receive the richest level available,
@@ -5502,18 +5713,25 @@ var OpenAIResponsesLanguageModel = class {
5502
5713
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
5503
5714
  include,
5504
5715
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
5716
+ prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
5505
5717
  prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
5506
5718
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
5507
5719
  top_logprobs: topLogprobs,
5508
5720
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
5509
5721
  // model-specific settings:
5510
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5722
+ ...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) && {
5511
5723
  reasoning: {
5512
5724
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
5513
5725
  effort: openaiOptions.reasoningEffort
5514
5726
  },
5515
5727
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
5516
5728
  summary: openaiOptions.reasoningSummary
5729
+ },
5730
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
5731
+ mode: openaiOptions.reasoningMode
5732
+ },
5733
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
5734
+ context: openaiOptions.reasoningContext
5517
5735
  }
5518
5736
  }
5519
5737
  }
@@ -5552,6 +5770,20 @@ var OpenAIResponsesLanguageModel = class {
5552
5770
  details: "reasoningSummary is not supported for non-reasoning models"
5553
5771
  });
5554
5772
  }
5773
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
5774
+ warnings.push({
5775
+ type: "unsupported",
5776
+ feature: "reasoningMode",
5777
+ details: "reasoningMode is not supported for non-reasoning models"
5778
+ });
5779
+ }
5780
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
5781
+ warnings.push({
5782
+ type: "unsupported",
5783
+ feature: "reasoningContext",
5784
+ details: "reasoningContext is not supported for non-reasoning models"
5785
+ });
5786
+ }
5555
5787
  }
5556
5788
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
5557
5789
  warnings.push({
@@ -5588,7 +5820,7 @@ var OpenAIResponsesLanguageModel = class {
5588
5820
  };
5589
5821
  }
5590
5822
  async doGenerate(options) {
5591
- 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;
5823
+ 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;
5592
5824
  const {
5593
5825
  args: body,
5594
5826
  warnings,
@@ -6037,7 +6269,8 @@ var OpenAIResponsesLanguageModel = class {
6037
6269
  [providerOptionsName]: {
6038
6270
  responseId: response.id,
6039
6271
  ...logprobs.length > 0 ? { logprobs } : {},
6040
- ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {}
6272
+ ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
6273
+ ...((_z = response.reasoning) == null ? void 0 : _z.context) != null ? { reasoningContext: response.reasoning.context } : {}
6041
6274
  }
6042
6275
  };
6043
6276
  const usage = response.usage;
@@ -6045,10 +6278,10 @@ var OpenAIResponsesLanguageModel = class {
6045
6278
  content,
6046
6279
  finishReason: {
6047
6280
  unified: mapOpenAIResponseFinishReason({
6048
- finishReason: (_z = response.incomplete_details) == null ? void 0 : _z.reason,
6281
+ finishReason: (_A = response.incomplete_details) == null ? void 0 : _A.reason,
6049
6282
  hasFunctionCall
6050
6283
  }),
6051
- raw: (_B = (_A = response.incomplete_details) == null ? void 0 : _A.reason) != null ? _B : void 0
6284
+ raw: (_C = (_B = response.incomplete_details) == null ? void 0 : _B.reason) != null ? _C : void 0
6052
6285
  },
6053
6286
  usage: convertOpenAIResponsesUsage(usage),
6054
6287
  request: { body },
@@ -6115,6 +6348,7 @@ var OpenAIResponsesLanguageModel = class {
6115
6348
  let hasFunctionCall = false;
6116
6349
  const activeReasoning = {};
6117
6350
  let serviceTier;
6351
+ let reasoningContext;
6118
6352
  const hostedToolSearchCallIds = [];
6119
6353
  let encounteredStreamError = false;
6120
6354
  const result = {
@@ -6124,7 +6358,7 @@ var OpenAIResponsesLanguageModel = class {
6124
6358
  controller.enqueue({ type: "stream-start", warnings });
6125
6359
  },
6126
6360
  transform(chunk, controller) {
6127
- 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, _D, _E, _F, _G, _H, _I, _J, _K, _L;
6361
+ 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, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
6128
6362
  if (options.includeRawChunks) {
6129
6363
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6130
6364
  }
@@ -6866,8 +7100,11 @@ var OpenAIResponsesLanguageModel = class {
6866
7100
  if (typeof value.response.service_tier === "string") {
6867
7101
  serviceTier = value.response.service_tier;
6868
7102
  }
7103
+ if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
7104
+ reasoningContext = value.response.reasoning.context;
7105
+ }
6869
7106
  } else if (isResponseFailedChunk(value)) {
6870
- const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
7107
+ const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
6871
7108
  finishReason = {
6872
7109
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
6873
7110
  finishReason: incompleteReason,
@@ -6875,7 +7112,10 @@ var OpenAIResponsesLanguageModel = class {
6875
7112
  }) : "error",
6876
7113
  raw: incompleteReason != null ? incompleteReason : "error"
6877
7114
  };
6878
- usage = (_z = value.response.usage) != null ? _z : void 0;
7115
+ usage = (_A = value.response.usage) != null ? _A : void 0;
7116
+ if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7117
+ reasoningContext = value.response.reasoning.context;
7118
+ }
6879
7119
  if (!encounteredStreamError && value.response.error != null) {
6880
7120
  encounteredStreamError = true;
6881
7121
  controller.enqueue({
@@ -6897,7 +7137,7 @@ var OpenAIResponsesLanguageModel = class {
6897
7137
  controller.enqueue({
6898
7138
  type: "source",
6899
7139
  sourceType: "url",
6900
- id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
7140
+ id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
6901
7141
  url: value.annotation.url,
6902
7142
  title: value.annotation.title
6903
7143
  });
@@ -6905,7 +7145,7 @@ var OpenAIResponsesLanguageModel = class {
6905
7145
  controller.enqueue({
6906
7146
  type: "source",
6907
7147
  sourceType: "document",
6908
- id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
7148
+ id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
6909
7149
  mediaType: "text/plain",
6910
7150
  title: value.annotation.filename,
6911
7151
  filename: value.annotation.filename,
@@ -6921,7 +7161,7 @@ var OpenAIResponsesLanguageModel = class {
6921
7161
  controller.enqueue({
6922
7162
  type: "source",
6923
7163
  sourceType: "document",
6924
- id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
7164
+ id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
6925
7165
  mediaType: "text/plain",
6926
7166
  title: value.annotation.filename,
6927
7167
  filename: value.annotation.filename,
@@ -6937,7 +7177,7 @@ var OpenAIResponsesLanguageModel = class {
6937
7177
  controller.enqueue({
6938
7178
  type: "source",
6939
7179
  sourceType: "document",
6940
- id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
7180
+ id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
6941
7181
  mediaType: "application/octet-stream",
6942
7182
  title: value.annotation.file_id,
6943
7183
  filename: value.annotation.file_id,
@@ -6961,7 +7201,8 @@ var OpenAIResponsesLanguageModel = class {
6961
7201
  [providerOptionsName]: {
6962
7202
  responseId,
6963
7203
  ...logprobs.length > 0 ? { logprobs } : {},
6964
- ...serviceTier !== void 0 ? { serviceTier } : {}
7204
+ ...serviceTier !== void 0 ? { serviceTier } : {},
7205
+ ...reasoningContext !== void 0 ? { reasoningContext } : {}
6965
7206
  }
6966
7207
  };
6967
7208
  controller.enqueue({