@ai-sdk/openai 4.0.10 → 4.0.13

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.
@@ -173,7 +173,7 @@ function isHttpErrorStatusCode(value) {
173
173
 
174
174
  // src/chat/convert-openai-chat-usage.ts
175
175
  function convertOpenAIChatUsage(usage) {
176
- var _a, _b, _c, _d, _e, _f;
176
+ var _a, _b, _c, _d, _e, _f, _g, _h;
177
177
  if (usage == null) {
178
178
  return {
179
179
  inputTokens: {
@@ -193,13 +193,14 @@ function convertOpenAIChatUsage(usage) {
193
193
  const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
194
194
  const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
195
195
  const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
196
- const reasoningTokens = (_f = (_e = usage.completion_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
196
+ const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
197
+ const reasoningTokens = (_h = (_g = usage.completion_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : 0;
197
198
  return {
198
199
  inputTokens: {
199
200
  total: promptTokens,
200
- noCache: promptTokens - cachedTokens,
201
+ noCache: promptTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
201
202
  cacheRead: cachedTokens,
202
- cacheWrite: void 0
203
+ cacheWrite: cacheWriteTokens
203
204
  },
204
205
  outputTokens: {
205
206
  total: completionTokens,
@@ -223,23 +224,47 @@ import {
223
224
  function serializeToolCallArguments(input) {
224
225
  return JSON.stringify(input === void 0 ? {} : input);
225
226
  }
227
+ function getPromptCacheBreakpoint(providerOptions) {
228
+ var _a;
229
+ return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
230
+ }
226
231
  function convertToOpenAIChatMessages({
227
232
  prompt,
228
233
  systemMessageMode = "system"
229
234
  }) {
230
- var _a;
235
+ var _a, _b;
231
236
  const messages = [];
232
237
  const warnings = [];
233
- for (const { role, content } of prompt) {
238
+ for (const { role, content, providerOptions } of prompt) {
234
239
  switch (role) {
235
240
  case "system": {
236
241
  switch (systemMessageMode) {
237
242
  case "system": {
238
- messages.push({ role: "system", content });
243
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
244
+ messages.push({
245
+ role: "system",
246
+ content: promptCacheBreakpoint == null ? content : [
247
+ {
248
+ type: "text",
249
+ text: content,
250
+ prompt_cache_breakpoint: promptCacheBreakpoint
251
+ }
252
+ ]
253
+ });
239
254
  break;
240
255
  }
241
256
  case "developer": {
242
- messages.push({ role: "developer", content });
257
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
258
+ messages.push({
259
+ role: "developer",
260
+ content: promptCacheBreakpoint == null ? content : [
261
+ {
262
+ type: "text",
263
+ text: content,
264
+ prompt_cache_breakpoint: promptCacheBreakpoint
265
+ }
266
+ ]
267
+ });
243
268
  break;
244
269
  }
245
270
  case "remove": {
@@ -259,19 +284,31 @@ function convertToOpenAIChatMessages({
259
284
  break;
260
285
  }
261
286
  case "user": {
262
- if (content.length === 1 && content[0].type === "text") {
287
+ if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
263
288
  messages.push({ role: "user", content: content[0].text });
264
289
  break;
265
290
  }
266
291
  messages.push({
267
292
  role: "user",
268
293
  content: content.map((part, index) => {
269
- var _a2, _b, _c;
294
+ var _a2, _b2, _c;
270
295
  switch (part.type) {
271
296
  case "text": {
272
- return { type: "text", text: part.text };
297
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
298
+ part.providerOptions
299
+ );
300
+ return {
301
+ type: "text",
302
+ text: part.text,
303
+ ...promptCacheBreakpoint != null && {
304
+ prompt_cache_breakpoint: promptCacheBreakpoint
305
+ }
306
+ };
273
307
  }
274
308
  case "file": {
309
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
310
+ part.providerOptions
311
+ );
275
312
  switch (part.data.type) {
276
313
  case "reference": {
277
314
  return {
@@ -281,6 +318,9 @@ function convertToOpenAIChatMessages({
281
318
  reference: part.data.reference,
282
319
  provider: "openai"
283
320
  })
321
+ },
322
+ ...promptCacheBreakpoint != null && {
323
+ prompt_cache_breakpoint: promptCacheBreakpoint
284
324
  }
285
325
  };
286
326
  }
@@ -297,7 +337,10 @@ function convertToOpenAIChatMessages({
297
337
  type: "image_url",
298
338
  image_url: {
299
339
  url: part.data.type === "url" ? part.data.url.toString() : `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`,
300
- detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
340
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
341
+ },
342
+ ...promptCacheBreakpoint != null && {
343
+ prompt_cache_breakpoint: promptCacheBreakpoint
301
344
  }
302
345
  };
303
346
  } else if (topLevel === "audio") {
@@ -314,6 +357,9 @@ function convertToOpenAIChatMessages({
314
357
  input_audio: {
315
358
  data: convertToBase64(part.data.data),
316
359
  format: "wav"
360
+ },
361
+ ...promptCacheBreakpoint != null && {
362
+ prompt_cache_breakpoint: promptCacheBreakpoint
317
363
  }
318
364
  };
319
365
  }
@@ -324,6 +370,9 @@ function convertToOpenAIChatMessages({
324
370
  input_audio: {
325
371
  data: convertToBase64(part.data.data),
326
372
  format: "mp3"
373
+ },
374
+ ...promptCacheBreakpoint != null && {
375
+ prompt_cache_breakpoint: promptCacheBreakpoint
327
376
  }
328
377
  };
329
378
  }
@@ -351,6 +400,9 @@ function convertToOpenAIChatMessages({
351
400
  file: {
352
401
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
353
402
  file_data: `data:application/pdf;base64,${convertToBase64(part.data.data)}`
403
+ },
404
+ ...promptCacheBreakpoint != null && {
405
+ prompt_cache_breakpoint: promptCacheBreakpoint
354
406
  }
355
407
  };
356
408
  }
@@ -364,11 +416,24 @@ function convertToOpenAIChatMessages({
364
416
  }
365
417
  case "assistant": {
366
418
  let text = "";
419
+ const textParts = [];
420
+ let hasPromptCacheBreakpoint = false;
367
421
  const toolCalls = [];
368
422
  for (const part of content) {
369
423
  switch (part.type) {
370
424
  case "text": {
425
+ const promptCacheBreakpoint = getPromptCacheBreakpoint(
426
+ part.providerOptions
427
+ );
371
428
  text += part.text;
429
+ textParts.push({
430
+ type: "text",
431
+ text: part.text,
432
+ ...promptCacheBreakpoint != null && {
433
+ prompt_cache_breakpoint: promptCacheBreakpoint
434
+ }
435
+ });
436
+ hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
372
437
  break;
373
438
  }
374
439
  case "tool-call": {
@@ -386,7 +451,7 @@ function convertToOpenAIChatMessages({
386
451
  }
387
452
  messages.push({
388
453
  role: "assistant",
389
- content: toolCalls.length > 0 ? text || null : text,
454
+ content: hasPromptCacheBreakpoint ? textParts : toolCalls.length > 0 ? text || null : text,
390
455
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0
391
456
  });
392
457
  break;
@@ -397,6 +462,7 @@ function convertToOpenAIChatMessages({
397
462
  continue;
398
463
  }
399
464
  const output = toolResponse.output;
465
+ 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);
400
466
  let contentValue;
401
467
  switch (output.type) {
402
468
  case "text":
@@ -404,7 +470,7 @@ function convertToOpenAIChatMessages({
404
470
  contentValue = output.value;
405
471
  break;
406
472
  case "execution-denied":
407
- contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
473
+ contentValue = (_b = output.reason) != null ? _b : "Tool call execution denied.";
408
474
  break;
409
475
  case "content":
410
476
  case "json":
@@ -415,7 +481,13 @@ function convertToOpenAIChatMessages({
415
481
  messages.push({
416
482
  role: "tool",
417
483
  tool_call_id: toolResponse.toolCallId,
418
- content: contentValue
484
+ content: promptCacheBreakpoint == null ? contentValue : [
485
+ {
486
+ type: "text",
487
+ text: contentValue,
488
+ prompt_cache_breakpoint: promptCacheBreakpoint
489
+ }
490
+ ]
419
491
  });
420
492
  }
421
493
  break;
@@ -521,7 +593,8 @@ var openaiChatResponseSchema = lazySchema(
521
593
  completion_tokens: z2.number().nullish(),
522
594
  total_tokens: z2.number().nullish(),
523
595
  prompt_tokens_details: z2.object({
524
- cached_tokens: z2.number().nullish()
596
+ cached_tokens: z2.number().nullish(),
597
+ cache_write_tokens: z2.number().nullish()
525
598
  }).nullish(),
526
599
  completion_tokens_details: z2.object({
527
600
  reasoning_tokens: z2.number().nullish(),
@@ -590,7 +663,8 @@ var openaiChatChunkSchema = lazySchema(
590
663
  completion_tokens: z2.number().nullish(),
591
664
  total_tokens: z2.number().nullish(),
592
665
  prompt_tokens_details: z2.object({
593
- cached_tokens: z2.number().nullish()
666
+ cached_tokens: z2.number().nullish(),
667
+ cache_write_tokens: z2.number().nullish()
594
668
  }).nullish(),
595
669
  completion_tokens_details: z2.object({
596
670
  reasoning_tokens: z2.number().nullish(),
@@ -642,7 +716,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
642
716
  /**
643
717
  * Reasoning effort for reasoning models. Defaults to `medium`.
644
718
  */
645
- reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
719
+ reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
646
720
  /**
647
721
  * Maximum number of completion tokens to generate. Useful for reasoning models.
648
722
  */
@@ -686,11 +760,22 @@ var openaiLanguageModelChatOptions = lazySchema2(
686
760
  * Useful for improving cache hit rates and working around automatic caching issues.
687
761
  */
688
762
  promptCacheKey: z3.string().optional(),
763
+ /**
764
+ * Prompt cache behavior for GPT-5.6 and later models.
765
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
766
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
767
+ */
768
+ promptCacheOptions: z3.object({
769
+ mode: z3.enum(["implicit", "explicit"]).optional(),
770
+ ttl: z3.literal("30m").optional()
771
+ }).optional(),
689
772
  /**
690
773
  * The retention policy for the prompt cache.
691
774
  * - 'in_memory': Default. Standard prompt caching behavior.
692
775
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
693
- * Currently only available for 5.1 series models.
776
+ * Available for models before GPT-5.6 that support extended caching.
777
+ *
778
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
694
779
  *
695
780
  * @default 'in_memory'
696
781
  */
@@ -885,6 +970,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
885
970
  reasoning_effort: resolvedReasoningEffort,
886
971
  service_tier: openaiOptions.serviceTier,
887
972
  prompt_cache_key: openaiOptions.promptCacheKey,
973
+ prompt_cache_options: openaiOptions.promptCacheOptions,
888
974
  prompt_cache_retention: openaiOptions.promptCacheRetention,
889
975
  safety_identifier: openaiOptions.safetyIdentifier,
890
976
  // messages:
@@ -2234,16 +2320,16 @@ import {
2234
2320
  convertBase64ToUint8Array as convertBase64ToUint8Array2,
2235
2321
  convertToBase64 as convertToBase642,
2236
2322
  createJsonResponseHandler as createJsonResponseHandler5,
2237
- getWebSocketConstructor,
2323
+ connectToWebSocket,
2238
2324
  mediaTypeToExtension,
2239
2325
  parseProviderOptions as parseProviderOptions5,
2240
2326
  postFormDataToApi as postFormDataToApi2,
2241
- readWebSocketMessageText,
2242
2327
  safeParseJSON,
2243
2328
  serializeModelOptions as serializeModelOptions5,
2244
2329
  toWebSocketUrl,
2245
2330
  WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
2246
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
2331
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5,
2332
+ waitForWebSocketBufferDrain
2247
2333
  } from "@ai-sdk/provider-utils";
2248
2334
 
2249
2335
  // src/transcription/openai-transcription-api.ts
@@ -2592,21 +2678,18 @@ function createOpenAIRealtimeTranscriptionStream({
2592
2678
  };
2593
2679
  return new ReadableStream({
2594
2680
  start: (controller) => {
2595
- const WebSocketConstructor = getWebSocketConstructor(webSocket);
2596
- const ws = new WebSocketConstructor(
2597
- url,
2598
- getOpenAIRealtimeProtocols(headers),
2599
- { headers }
2600
- );
2681
+ const realtimeConnection = getOpenAIRealtimeConnection(headers);
2601
2682
  let audioReader;
2683
+ let connection;
2602
2684
  cleanup = (closeCode) => {
2603
- abortSignal == null ? void 0 : abortSignal.removeEventListener("abort", abort);
2604
- void (audioReader == null ? void 0 : audioReader.cancel().catch(() => {
2605
- }));
2606
- try {
2607
- ws.close(closeCode);
2608
- } catch (e) {
2685
+ if (audioReader != null) {
2686
+ void audioReader.cancel().catch(() => {
2687
+ });
2688
+ } else {
2689
+ void audio.cancel().catch(() => {
2690
+ });
2609
2691
  }
2692
+ connection == null ? void 0 : connection.close(closeCode);
2610
2693
  };
2611
2694
  const finishWithError = (error) => {
2612
2695
  if (finished) return;
@@ -2629,42 +2712,42 @@ function createOpenAIRealtimeTranscriptionStream({
2629
2712
  controller.close();
2630
2713
  cleanup(1e3);
2631
2714
  };
2632
- const abort = () => {
2633
- var _a;
2634
- finishWithError((_a = abortSignal == null ? void 0 : abortSignal.reason) != null ? _a : new Error("Aborted"));
2635
- };
2636
- if (abortSignal == null ? void 0 : abortSignal.aborted) {
2637
- abort();
2638
- return;
2639
- }
2640
- abortSignal == null ? void 0 : abortSignal.addEventListener("abort", abort, { once: true });
2641
- const sendAudio = async () => {
2715
+ const sendAudio = async (socket) => {
2642
2716
  audioReader = audio.getReader();
2643
2717
  try {
2644
2718
  while (true) {
2645
2719
  const { done, value } = await audioReader.read();
2646
2720
  if (done || finished) break;
2647
- ws.send(
2721
+ socket.send(
2648
2722
  JSON.stringify({
2649
2723
  type: "input_audio_buffer.append",
2650
2724
  audio: convertToBase642(value)
2651
2725
  })
2652
2726
  );
2727
+ await waitForWebSocketBufferDrain(socket);
2653
2728
  }
2654
2729
  } finally {
2655
2730
  audioReader.releaseLock();
2731
+ audioReader = void 0;
2656
2732
  }
2657
2733
  if (!finished) {
2658
- ws.send(JSON.stringify({ type: "input_audio_buffer.commit" }));
2734
+ socket.send(JSON.stringify({ type: "input_audio_buffer.commit" }));
2659
2735
  }
2660
2736
  };
2661
- ws.onopen = () => {
2662
- controller.enqueue({ type: "stream-start", warnings });
2663
- ws.send(JSON.stringify(sessionUpdate));
2664
- void sendAudio().catch(finishWithError);
2665
- };
2666
- ws.onmessage = (event) => {
2667
- void readWebSocketMessageText(event.data).then(async (text) => {
2737
+ connection = connectToWebSocket({
2738
+ url,
2739
+ protocols: realtimeConnection.protocols,
2740
+ headers: realtimeConnection.headers,
2741
+ webSocket,
2742
+ abortSignal,
2743
+ onAbort: finishWithError,
2744
+ onProcessingError: finishWithError,
2745
+ onOpen: (socket) => {
2746
+ controller.enqueue({ type: "stream-start", warnings });
2747
+ socket.send(JSON.stringify(sessionUpdate));
2748
+ void sendAudio(socket).catch(finishWithError);
2749
+ },
2750
+ onMessageText: async (text) => {
2668
2751
  var _a, _b, _c, _d;
2669
2752
  const parsed = await safeParseJSON({ text });
2670
2753
  if (!parsed.success) return;
@@ -2692,17 +2775,17 @@ function createOpenAIRealtimeTranscriptionStream({
2692
2775
  break;
2693
2776
  }
2694
2777
  }
2695
- }).catch(finishWithError);
2696
- };
2697
- ws.onerror = () => {
2698
- finishWithError(new Error("OpenAI realtime transcription error"));
2699
- };
2700
- ws.onclose = () => {
2701
- if (finished) return;
2702
- finished = true;
2703
- cleanup();
2704
- controller.close();
2705
- };
2778
+ },
2779
+ onSocketError: () => {
2780
+ finishWithError(new Error("OpenAI realtime transcription error"));
2781
+ },
2782
+ onClose: () => {
2783
+ if (finished) return;
2784
+ finished = true;
2785
+ cleanup();
2786
+ controller.close();
2787
+ }
2788
+ });
2706
2789
  },
2707
2790
  cancel: () => {
2708
2791
  if (finished) return;
@@ -2739,11 +2822,26 @@ function buildOpenAIRealtimeTranscriptionSession({
2739
2822
  }
2740
2823
  };
2741
2824
  }
2742
- function getOpenAIRealtimeProtocols(headers) {
2825
+ function getOpenAIRealtimeConnection(headers) {
2743
2826
  var _a;
2744
- const authorization = (_a = headers.Authorization) != null ? _a : headers.authorization;
2745
- const token = (authorization == null ? void 0 : authorization.startsWith("Bearer ")) ? authorization.slice("Bearer ".length) : void 0;
2746
- return token == null ? ["realtime"] : ["realtime", `openai-insecure-api-key.${token}`];
2827
+ let authorization;
2828
+ for (const [key, value] of Object.entries(headers)) {
2829
+ if (key.toLowerCase() === "authorization" && value != null) {
2830
+ authorization = value;
2831
+ }
2832
+ }
2833
+ const token = (_a = authorization == null ? void 0 : authorization.match(/^bearer\s+(.+)$/i)) == null ? void 0 : _a[1];
2834
+ if (token == null) {
2835
+ return { protocols: ["realtime"], headers };
2836
+ }
2837
+ return {
2838
+ protocols: ["realtime", `openai-insecure-api-key.${token}`],
2839
+ headers: Object.fromEntries(
2840
+ Object.entries(headers).filter(
2841
+ ([key]) => key.toLowerCase() !== "authorization"
2842
+ )
2843
+ )
2844
+ };
2747
2845
  }
2748
2846
 
2749
2847
  // src/speech/openai-speech-model.ts
@@ -2902,7 +3000,7 @@ import {
2902
3000
 
2903
3001
  // src/responses/convert-openai-responses-usage.ts
2904
3002
  function convertOpenAIResponsesUsage(usage) {
2905
- var _a, _b, _c, _d;
3003
+ var _a, _b, _c, _d, _e, _f;
2906
3004
  if (usage == null) {
2907
3005
  return {
2908
3006
  inputTokens: {
@@ -2922,13 +3020,14 @@ function convertOpenAIResponsesUsage(usage) {
2922
3020
  const inputTokens = usage.input_tokens;
2923
3021
  const outputTokens = usage.output_tokens;
2924
3022
  const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
2925
- const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0;
3023
+ const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
3024
+ const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
2926
3025
  return {
2927
3026
  inputTokens: {
2928
3027
  total: inputTokens,
2929
- noCache: inputTokens - cachedTokens,
3028
+ noCache: inputTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
2930
3029
  cacheRead: cachedTokens,
2931
- cacheWrite: void 0
3030
+ cacheWrite: cacheWriteTokens
2932
3031
  },
2933
3032
  outputTokens: {
2934
3033
  total: outputTokens,
@@ -3173,6 +3272,10 @@ var toolSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3173
3272
  function serializeToolCallArguments2(input) {
3174
3273
  return JSON.stringify(input === void 0 ? {} : input);
3175
3274
  }
3275
+ function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
3276
+ var _a;
3277
+ return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
3278
+ }
3176
3279
  function isFileId(data, prefixes) {
3177
3280
  if (!prefixes) return false;
3178
3281
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -3196,16 +3299,42 @@ async function convertToOpenAIResponsesInput({
3196
3299
  let input = [];
3197
3300
  const warnings = [];
3198
3301
  const processedApprovalIds = /* @__PURE__ */ new Set();
3199
- for (const { role, content } of prompt) {
3302
+ for (const { role, content, providerOptions } of prompt) {
3200
3303
  switch (role) {
3201
3304
  case "system": {
3202
3305
  switch (systemMessageMode) {
3203
3306
  case "system": {
3204
- input.push({ role: "system", content });
3307
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3308
+ providerOptions,
3309
+ providerOptionsName
3310
+ );
3311
+ input.push({
3312
+ role: "system",
3313
+ content: promptCacheBreakpoint == null ? content : [
3314
+ {
3315
+ type: "input_text",
3316
+ text: content,
3317
+ prompt_cache_breakpoint: promptCacheBreakpoint
3318
+ }
3319
+ ]
3320
+ });
3205
3321
  break;
3206
3322
  }
3207
3323
  case "developer": {
3208
- input.push({ role: "developer", content });
3324
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3325
+ providerOptions,
3326
+ providerOptionsName
3327
+ );
3328
+ input.push({
3329
+ role: "developer",
3330
+ content: promptCacheBreakpoint == null ? content : [
3331
+ {
3332
+ type: "input_text",
3333
+ text: content,
3334
+ prompt_cache_breakpoint: promptCacheBreakpoint
3335
+ }
3336
+ ]
3337
+ });
3209
3338
  break;
3210
3339
  }
3211
3340
  case "remove": {
@@ -3231,9 +3360,23 @@ async function convertToOpenAIResponsesInput({
3231
3360
  var _a2, _b2, _c2, _d2, _e2;
3232
3361
  switch (part.type) {
3233
3362
  case "text": {
3234
- return { type: "input_text", text: part.text };
3363
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3364
+ part.providerOptions,
3365
+ providerOptionsName
3366
+ );
3367
+ return {
3368
+ type: "input_text",
3369
+ text: part.text,
3370
+ ...promptCacheBreakpoint != null && {
3371
+ prompt_cache_breakpoint: promptCacheBreakpoint
3372
+ }
3373
+ };
3235
3374
  }
3236
3375
  case "file": {
3376
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3377
+ part.providerOptions,
3378
+ providerOptionsName
3379
+ );
3237
3380
  switch (part.data.type) {
3238
3381
  case "reference": {
3239
3382
  const fileId = resolveProviderReference2({
@@ -3244,12 +3387,18 @@ async function convertToOpenAIResponsesInput({
3244
3387
  return {
3245
3388
  type: "input_image",
3246
3389
  file_id: fileId,
3247
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
3390
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3391
+ ...promptCacheBreakpoint != null && {
3392
+ prompt_cache_breakpoint: promptCacheBreakpoint
3393
+ }
3248
3394
  };
3249
3395
  }
3250
3396
  return {
3251
3397
  type: "input_file",
3252
- file_id: fileId
3398
+ file_id: fileId,
3399
+ ...promptCacheBreakpoint != null && {
3400
+ prompt_cache_breakpoint: promptCacheBreakpoint
3401
+ }
3253
3402
  };
3254
3403
  }
3255
3404
  case "text": {
@@ -3266,13 +3415,19 @@ async function convertToOpenAIResponsesInput({
3266
3415
  ...part.data.type === "url" ? { image_url: part.data.url.toString() } : typeof part.data.data === "string" && isFileId(part.data.data, fileIdPrefixes) ? { file_id: part.data.data } : {
3267
3416
  image_url: `data:${resolveFullMediaType2({ part })};base64,${convertToBase643(part.data.data)}`
3268
3417
  },
3269
- detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
3418
+ detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
3419
+ ...promptCacheBreakpoint != null && {
3420
+ prompt_cache_breakpoint: promptCacheBreakpoint
3421
+ }
3270
3422
  };
3271
3423
  } else {
3272
3424
  if (part.data.type === "url") {
3273
3425
  return {
3274
3426
  type: "input_file",
3275
- file_url: part.data.url.toString()
3427
+ file_url: part.data.url.toString(),
3428
+ ...promptCacheBreakpoint != null && {
3429
+ prompt_cache_breakpoint: promptCacheBreakpoint
3430
+ }
3276
3431
  };
3277
3432
  }
3278
3433
  const fullMediaType = resolveFullMediaType2({ part });
@@ -3286,6 +3441,9 @@ async function convertToOpenAIResponsesInput({
3286
3441
  ...typeof part.data.data === "string" && isFileId(part.data.data, fileIdPrefixes) ? { file_id: part.data.data } : {
3287
3442
  filename: (_e2 = part.filename) != null ? _e2 : fullMediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
3288
3443
  file_data: `data:${fullMediaType};base64,${convertToBase643(part.data.data)}`
3444
+ },
3445
+ ...promptCacheBreakpoint != null && {
3446
+ prompt_cache_breakpoint: promptCacheBreakpoint
3289
3447
  }
3290
3448
  };
3291
3449
  }
@@ -3302,9 +3460,9 @@ async function convertToOpenAIResponsesInput({
3302
3460
  for (const part of content) {
3303
3461
  switch (part.type) {
3304
3462
  case "text": {
3305
- const providerOptions = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
3306
- const id = providerOptions == null ? void 0 : providerOptions.itemId;
3307
- const phase = providerOptions == null ? void 0 : providerOptions.phase;
3463
+ const providerOptions2 = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
3464
+ const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
3465
+ const phase = providerOptions2 == null ? void 0 : providerOptions2.phase;
3308
3466
  if (hasConversation && id != null) {
3309
3467
  break;
3310
3468
  }
@@ -3501,12 +3659,12 @@ async function convertToOpenAIResponsesInput({
3501
3659
  break;
3502
3660
  }
3503
3661
  case "reasoning": {
3504
- const providerOptions = await parseProviderOptions7({
3662
+ const providerOptions2 = await parseProviderOptions7({
3505
3663
  provider: providerOptionsName,
3506
3664
  providerOptions: part.providerOptions,
3507
3665
  schema: openaiResponsesReasoningProviderOptionsSchema
3508
3666
  });
3509
- const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
3667
+ const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
3510
3668
  if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
3511
3669
  break;
3512
3670
  }
@@ -3538,19 +3696,19 @@ async function convertToOpenAIResponsesInput({
3538
3696
  reasoningMessages[reasoningId] = {
3539
3697
  type: "reasoning",
3540
3698
  id: reasoningId,
3541
- encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
3699
+ encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
3542
3700
  summary: summaryParts
3543
3701
  };
3544
3702
  input.push(reasoningMessages[reasoningId]);
3545
3703
  } else {
3546
3704
  reasoningMessage.summary.push(...summaryParts);
3547
- if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
3548
- reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
3705
+ if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
3706
+ reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
3549
3707
  }
3550
3708
  }
3551
3709
  }
3552
3710
  } else {
3553
- const encryptedContent = providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent;
3711
+ const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent;
3554
3712
  if (encryptedContent != null) {
3555
3713
  const summaryParts = [];
3556
3714
  if (part.text.length > 0) {
@@ -3575,8 +3733,8 @@ async function convertToOpenAIResponsesInput({
3575
3733
  }
3576
3734
  case "custom": {
3577
3735
  if (part.kind === "openai.compaction") {
3578
- const providerOptions = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName];
3579
- const id = providerOptions == null ? void 0 : providerOptions.itemId;
3736
+ const providerOptions2 = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName];
3737
+ const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
3580
3738
  if (hasConversation && id != null) {
3581
3739
  break;
3582
3740
  }
@@ -3584,7 +3742,7 @@ async function convertToOpenAIResponsesInput({
3584
3742
  input.push({ type: "item_reference", id });
3585
3743
  break;
3586
3744
  }
3587
- const encryptedContent = providerOptions == null ? void 0 : providerOptions.encryptedContent;
3745
+ const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.encryptedContent;
3588
3746
  if (id != null) {
3589
3747
  input.push({
3590
3748
  type: "compaction",
@@ -3705,9 +3863,19 @@ async function convertToOpenAIResponsesInput({
3705
3863
  case "content":
3706
3864
  outputValue = output.value.map((item) => {
3707
3865
  var _a2, _b2, _c2;
3866
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3867
+ item.providerOptions,
3868
+ providerOptionsName
3869
+ );
3708
3870
  switch (item.type) {
3709
3871
  case "text":
3710
- return { type: "input_text", text: item.text };
3872
+ return {
3873
+ type: "input_text",
3874
+ text: item.text,
3875
+ ...promptCacheBreakpoint != null && {
3876
+ prompt_cache_breakpoint: promptCacheBreakpoint
3877
+ }
3878
+ };
3711
3879
  case "file": {
3712
3880
  const topLevel = getTopLevelMediaType2(item.mediaType);
3713
3881
  const imageDetail = (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail;
@@ -3719,13 +3887,19 @@ async function convertToOpenAIResponsesInput({
3719
3887
  return {
3720
3888
  type: "input_image",
3721
3889
  image_url: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
3722
- detail: imageDetail
3890
+ detail: imageDetail,
3891
+ ...promptCacheBreakpoint != null && {
3892
+ prompt_cache_breakpoint: promptCacheBreakpoint
3893
+ }
3723
3894
  };
3724
3895
  }
3725
3896
  return {
3726
3897
  type: "input_file",
3727
3898
  filename: (_c2 = item.filename) != null ? _c2 : "data",
3728
- file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`
3899
+ file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
3900
+ ...promptCacheBreakpoint != null && {
3901
+ prompt_cache_breakpoint: promptCacheBreakpoint
3902
+ }
3729
3903
  };
3730
3904
  }
3731
3905
  if (item.data.type === "url") {
@@ -3733,12 +3907,18 @@ async function convertToOpenAIResponsesInput({
3733
3907
  return {
3734
3908
  type: "input_image",
3735
3909
  image_url: item.data.url.toString(),
3736
- detail: imageDetail
3910
+ detail: imageDetail,
3911
+ ...promptCacheBreakpoint != null && {
3912
+ prompt_cache_breakpoint: promptCacheBreakpoint
3913
+ }
3737
3914
  };
3738
3915
  }
3739
3916
  return {
3740
3917
  type: "input_file",
3741
- file_url: item.data.url.toString()
3918
+ file_url: item.data.url.toString(),
3919
+ ...promptCacheBreakpoint != null && {
3920
+ prompt_cache_breakpoint: promptCacheBreakpoint
3921
+ }
3742
3922
  };
3743
3923
  }
3744
3924
  warnings.push({
@@ -3782,9 +3962,19 @@ async function convertToOpenAIResponsesInput({
3782
3962
  case "content":
3783
3963
  contentValue = output.value.map((item) => {
3784
3964
  var _a2, _b2, _c2;
3965
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3966
+ item.providerOptions,
3967
+ providerOptionsName
3968
+ );
3785
3969
  switch (item.type) {
3786
3970
  case "text": {
3787
- return { type: "input_text", text: item.text };
3971
+ return {
3972
+ type: "input_text",
3973
+ text: item.text,
3974
+ ...promptCacheBreakpoint != null && {
3975
+ prompt_cache_breakpoint: promptCacheBreakpoint
3976
+ }
3977
+ };
3788
3978
  }
3789
3979
  case "file": {
3790
3980
  const topLevel = getTopLevelMediaType2(item.mediaType);
@@ -3797,13 +3987,19 @@ async function convertToOpenAIResponsesInput({
3797
3987
  return {
3798
3988
  type: "input_image",
3799
3989
  image_url: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
3800
- detail: imageDetail
3990
+ detail: imageDetail,
3991
+ ...promptCacheBreakpoint != null && {
3992
+ prompt_cache_breakpoint: promptCacheBreakpoint
3993
+ }
3801
3994
  };
3802
3995
  }
3803
3996
  return {
3804
3997
  type: "input_file",
3805
3998
  filename: (_c2 = item.filename) != null ? _c2 : "data",
3806
- file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`
3999
+ file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
4000
+ ...promptCacheBreakpoint != null && {
4001
+ prompt_cache_breakpoint: promptCacheBreakpoint
4002
+ }
3807
4003
  };
3808
4004
  }
3809
4005
  if (item.data.type === "url") {
@@ -3811,12 +4007,18 @@ async function convertToOpenAIResponsesInput({
3811
4007
  return {
3812
4008
  type: "input_image",
3813
4009
  image_url: item.data.url.toString(),
3814
- detail: imageDetail
4010
+ detail: imageDetail,
4011
+ ...promptCacheBreakpoint != null && {
4012
+ prompt_cache_breakpoint: promptCacheBreakpoint
4013
+ }
3815
4014
  };
3816
4015
  }
3817
4016
  return {
3818
4017
  type: "input_file",
3819
- file_url: item.data.url.toString()
4018
+ file_url: item.data.url.toString(),
4019
+ ...promptCacheBreakpoint != null && {
4020
+ prompt_cache_breakpoint: promptCacheBreakpoint
4021
+ }
3820
4022
  };
3821
4023
  }
3822
4024
  warnings.push({
@@ -3947,6 +4149,7 @@ var openaiResponsesChunkSchema = lazySchema16(
3947
4149
  input_tokens: z18.number(),
3948
4150
  input_tokens_details: z18.object({
3949
4151
  cached_tokens: z18.number().nullish(),
4152
+ cache_write_tokens: z18.number().nullish(),
3950
4153
  orchestration_input_tokens: z18.number().nullish(),
3951
4154
  orchestration_input_cached_tokens: z18.number().nullish()
3952
4155
  }).nullish(),
@@ -3956,6 +4159,9 @@ var openaiResponsesChunkSchema = lazySchema16(
3956
4159
  orchestration_output_tokens: z18.number().nullish()
3957
4160
  }).nullish()
3958
4161
  }),
4162
+ reasoning: z18.object({
4163
+ context: z18.string().nullish()
4164
+ }).nullish(),
3959
4165
  service_tier: z18.string().nullish()
3960
4166
  })
3961
4167
  }),
@@ -3972,6 +4178,7 @@ var openaiResponsesChunkSchema = lazySchema16(
3972
4178
  input_tokens: z18.number(),
3973
4179
  input_tokens_details: z18.object({
3974
4180
  cached_tokens: z18.number().nullish(),
4181
+ cache_write_tokens: z18.number().nullish(),
3975
4182
  orchestration_input_tokens: z18.number().nullish(),
3976
4183
  orchestration_input_cached_tokens: z18.number().nullish()
3977
4184
  }).nullish(),
@@ -3981,6 +4188,9 @@ var openaiResponsesChunkSchema = lazySchema16(
3981
4188
  orchestration_output_tokens: z18.number().nullish()
3982
4189
  }).nullish()
3983
4190
  }).nullish(),
4191
+ reasoning: z18.object({
4192
+ context: z18.string().nullish()
4193
+ }).nullish(),
3984
4194
  service_tier: z18.string().nullish()
3985
4195
  })
3986
4196
  }),
@@ -4767,11 +4977,15 @@ var openaiResponsesResponseSchema = lazySchema16(
4767
4977
  ])
4768
4978
  ).optional(),
4769
4979
  service_tier: z18.string().nullish(),
4980
+ reasoning: z18.object({
4981
+ context: z18.string().nullish()
4982
+ }).nullish(),
4770
4983
  incomplete_details: z18.object({ reason: z18.string() }).nullish(),
4771
4984
  usage: z18.object({
4772
4985
  input_tokens: z18.number(),
4773
4986
  input_tokens_details: z18.object({
4774
4987
  cached_tokens: z18.number().nullish(),
4988
+ cache_write_tokens: z18.number().nullish(),
4775
4989
  orchestration_input_tokens: z18.number().nullish(),
4776
4990
  orchestration_input_cached_tokens: z18.number().nullish()
4777
4991
  }).nullish(),
@@ -4929,11 +5143,22 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
4929
5143
  * Sets a cache key to tie this prompt to cached prefixes for better caching performance.
4930
5144
  */
4931
5145
  promptCacheKey: z19.string().nullish(),
5146
+ /**
5147
+ * Prompt cache behavior for GPT-5.6 and later models.
5148
+ * `mode` controls whether OpenAI also places an implicit breakpoint.
5149
+ * `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
5150
+ */
5151
+ promptCacheOptions: z19.object({
5152
+ mode: z19.enum(["implicit", "explicit"]).optional(),
5153
+ ttl: z19.literal("30m").optional()
5154
+ }).optional(),
4932
5155
  /**
4933
5156
  * The retention policy for the prompt cache.
4934
5157
  * - 'in_memory': Default. Standard prompt caching behavior.
4935
5158
  * - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
4936
- * Currently only available for 5.1 series models.
5159
+ * Available for models before GPT-5.6 that support extended caching.
5160
+ *
5161
+ * @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
4937
5162
  *
4938
5163
  * @default 'in_memory'
4939
5164
  */
@@ -4941,14 +5166,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
4941
5166
  /**
4942
5167
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
4943
5168
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
4944
- * Valid values: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
4945
- *
4946
- * The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
4947
- * models. Also, the 'xhigh' type for `reasoningEffort` is only available for
4948
- * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
4949
- * an error.
5169
+ * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
5170
+ * Supported values vary by model.
4950
5171
  */
4951
5172
  reasoningEffort: z19.string().nullish(),
5173
+ /**
5174
+ * Controls how much model work GPT-5.6 performs before returning a final answer.
5175
+ * `standard` is the default. `pro` increases quality, latency, and token usage.
5176
+ */
5177
+ reasoningMode: z19.enum(["standard", "pro"]).optional(),
5178
+ /**
5179
+ * Controls which available reasoning items GPT-5.6 can use.
5180
+ * `auto` uses the model default, `current_turn` excludes reasoning from earlier
5181
+ * turns, and `all_turns` makes compatible earlier reasoning available.
5182
+ */
5183
+ reasoningContext: z19.enum(["auto", "current_turn", "all_turns"]).optional(),
4952
5184
  /**
4953
5185
  * Controls reasoning summary output from the model.
4954
5186
  * Set to "auto" to automatically receive the richest level available,
@@ -5929,6 +6161,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5929
6161
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
5930
6162
  include,
5931
6163
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
6164
+ prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
5932
6165
  prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
5933
6166
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
5934
6167
  top_logprobs: topLogprobs,
@@ -5941,13 +6174,19 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5941
6174
  }))
5942
6175
  },
5943
6176
  // model-specific settings:
5944
- ...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null) && {
6177
+ ...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
5945
6178
  reasoning: {
5946
6179
  ...resolvedReasoningEffort != null && {
5947
6180
  effort: resolvedReasoningEffort
5948
6181
  },
5949
6182
  ...resolvedReasoningSummary != null && {
5950
6183
  summary: resolvedReasoningSummary
6184
+ },
6185
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
6186
+ mode: openaiOptions.reasoningMode
6187
+ },
6188
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
6189
+ context: openaiOptions.reasoningContext
5951
6190
  }
5952
6191
  }
5953
6192
  }
@@ -5986,6 +6225,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5986
6225
  details: "reasoningSummary is not supported for non-reasoning models"
5987
6226
  });
5988
6227
  }
6228
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
6229
+ warnings.push({
6230
+ type: "unsupported",
6231
+ feature: "reasoningMode",
6232
+ details: "reasoningMode is not supported for non-reasoning models"
6233
+ });
6234
+ }
6235
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
6236
+ warnings.push({
6237
+ type: "unsupported",
6238
+ feature: "reasoningContext",
6239
+ details: "reasoningContext is not supported for non-reasoning models"
6240
+ });
6241
+ }
5989
6242
  }
5990
6243
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
5991
6244
  warnings.push({
@@ -6022,7 +6275,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6022
6275
  };
6023
6276
  }
6024
6277
  async doGenerate(options) {
6025
- 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;
6278
+ 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;
6026
6279
  const {
6027
6280
  args: body,
6028
6281
  warnings,
@@ -6485,7 +6738,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6485
6738
  [providerOptionsName]: {
6486
6739
  responseId: response.id,
6487
6740
  ...logprobs.length > 0 ? { logprobs } : {},
6488
- ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {}
6741
+ ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
6742
+ ...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
6489
6743
  }
6490
6744
  };
6491
6745
  const usage = response.usage;
@@ -6493,10 +6747,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6493
6747
  content,
6494
6748
  finishReason: {
6495
6749
  unified: mapOpenAIResponseFinishReason({
6496
- finishReason: (_B = response.incomplete_details) == null ? void 0 : _B.reason,
6750
+ finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
6497
6751
  hasFunctionCall
6498
6752
  }),
6499
- raw: (_D = (_C = response.incomplete_details) == null ? void 0 : _C.reason) != null ? _D : void 0
6753
+ raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
6500
6754
  },
6501
6755
  usage: convertOpenAIResponsesUsage(usage),
6502
6756
  request: { body },
@@ -6564,6 +6818,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6564
6818
  let hasFunctionCall = false;
6565
6819
  const activeReasoning = {};
6566
6820
  let serviceTier;
6821
+ let reasoningContext;
6567
6822
  const hostedToolSearchCallIds = [];
6568
6823
  let encounteredStreamError = false;
6569
6824
  const result = {
@@ -6573,7 +6828,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6573
6828
  controller.enqueue({ type: "stream-start", warnings });
6574
6829
  },
6575
6830
  transform(chunk, controller) {
6576
- var _a2, _b2, _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;
6831
+ var _a2, _b2, _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;
6577
6832
  if (options.includeRawChunks) {
6578
6833
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6579
6834
  }
@@ -7327,8 +7582,11 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7327
7582
  if (typeof value.response.service_tier === "string") {
7328
7583
  serviceTier = value.response.service_tier;
7329
7584
  }
7585
+ if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
7586
+ reasoningContext = value.response.reasoning.context;
7587
+ }
7330
7588
  } else if (isResponseFailedChunk(value)) {
7331
- const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
7589
+ const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
7332
7590
  finishReason = {
7333
7591
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
7334
7592
  finishReason: incompleteReason,
@@ -7336,7 +7594,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7336
7594
  }) : "error",
7337
7595
  raw: incompleteReason != null ? incompleteReason : "error"
7338
7596
  };
7339
- usage = (_z = value.response.usage) != null ? _z : void 0;
7597
+ usage = (_A = value.response.usage) != null ? _A : void 0;
7598
+ if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7599
+ reasoningContext = value.response.reasoning.context;
7600
+ }
7340
7601
  if (!encounteredStreamError && value.response.error != null) {
7341
7602
  encounteredStreamError = true;
7342
7603
  controller.enqueue({
@@ -7358,7 +7619,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7358
7619
  controller.enqueue({
7359
7620
  type: "source",
7360
7621
  sourceType: "url",
7361
- id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
7622
+ id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
7362
7623
  url: value.annotation.url,
7363
7624
  title: value.annotation.title
7364
7625
  });
@@ -7366,7 +7627,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7366
7627
  controller.enqueue({
7367
7628
  type: "source",
7368
7629
  sourceType: "document",
7369
- id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
7630
+ id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
7370
7631
  mediaType: "text/plain",
7371
7632
  title: value.annotation.filename,
7372
7633
  filename: value.annotation.filename,
@@ -7382,7 +7643,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7382
7643
  controller.enqueue({
7383
7644
  type: "source",
7384
7645
  sourceType: "document",
7385
- id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
7646
+ id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
7386
7647
  mediaType: "text/plain",
7387
7648
  title: value.annotation.filename,
7388
7649
  filename: value.annotation.filename,
@@ -7398,7 +7659,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7398
7659
  controller.enqueue({
7399
7660
  type: "source",
7400
7661
  sourceType: "document",
7401
- id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
7662
+ id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
7402
7663
  mediaType: "application/octet-stream",
7403
7664
  title: value.annotation.file_id,
7404
7665
  filename: value.annotation.file_id,
@@ -7422,7 +7683,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7422
7683
  [providerOptionsName]: {
7423
7684
  responseId,
7424
7685
  ...logprobs.length > 0 ? { logprobs } : {},
7425
- ...serviceTier !== void 0 ? { serviceTier } : {}
7686
+ ...serviceTier !== void 0 ? { serviceTier } : {},
7687
+ ...reasoningContext !== void 0 ? { reasoningContext } : {}
7426
7688
  }
7427
7689
  };
7428
7690
  controller.enqueue({