@ai-sdk/openai 4.0.9 → 4.0.11
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.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.ts +22 -3
- package/dist/index.js +330 -76
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +16 -3
- package/dist/internal/index.js +329 -75
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +123 -87
- package/package.json +3 -3
- package/src/chat/convert-openai-chat-usage.ts +5 -2
- package/src/chat/convert-to-openai-chat-messages.ts +114 -7
- package/src/chat/openai-chat-api.ts +2 -0
- package/src/chat/openai-chat-language-model-options.ts +20 -2
- package/src/chat/openai-chat-language-model.ts +1 -0
- package/src/chat/openai-chat-prompt.ts +8 -4
- package/src/openai-language-model-capabilities.ts +2 -1
- package/src/responses/convert-openai-responses-usage.ts +5 -2
- package/src/responses/convert-to-openai-responses-input.ts +123 -6
- package/src/responses/openai-responses-api.ts +77 -11
- package/src/responses/openai-responses-language-model-options.ts +40 -7
- package/src/responses/openai-responses-language-model.ts +37 -1
- package/src/responses/openai-responses-provider-metadata.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
45
45
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
46
46
|
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");
|
|
47
47
|
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
48
|
-
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.5");
|
|
48
|
+
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.5") || modelId.startsWith("gpt-5.6");
|
|
49
49
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
50
50
|
return {
|
|
51
51
|
supportsFlexProcessing,
|
|
@@ -181,7 +181,7 @@ function isHttpErrorStatusCode(value) {
|
|
|
181
181
|
|
|
182
182
|
// src/chat/convert-openai-chat-usage.ts
|
|
183
183
|
function convertOpenAIChatUsage(usage) {
|
|
184
|
-
var _a, _b, _c, _d, _e, _f;
|
|
184
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
185
185
|
if (usage == null) {
|
|
186
186
|
return {
|
|
187
187
|
inputTokens: {
|
|
@@ -201,13 +201,14 @@ function convertOpenAIChatUsage(usage) {
|
|
|
201
201
|
const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
|
|
202
202
|
const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
|
|
203
203
|
const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
|
|
204
|
-
const
|
|
204
|
+
const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
|
|
205
|
+
const reasoningTokens = (_h = (_g = usage.completion_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : 0;
|
|
205
206
|
return {
|
|
206
207
|
inputTokens: {
|
|
207
208
|
total: promptTokens,
|
|
208
|
-
noCache: promptTokens - cachedTokens,
|
|
209
|
+
noCache: promptTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
209
210
|
cacheRead: cachedTokens,
|
|
210
|
-
cacheWrite:
|
|
211
|
+
cacheWrite: cacheWriteTokens
|
|
211
212
|
},
|
|
212
213
|
outputTokens: {
|
|
213
214
|
total: completionTokens,
|
|
@@ -231,23 +232,47 @@ import {
|
|
|
231
232
|
function serializeToolCallArguments(input) {
|
|
232
233
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
233
234
|
}
|
|
235
|
+
function getPromptCacheBreakpoint(providerOptions) {
|
|
236
|
+
var _a;
|
|
237
|
+
return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
238
|
+
}
|
|
234
239
|
function convertToOpenAIChatMessages({
|
|
235
240
|
prompt,
|
|
236
241
|
systemMessageMode = "system"
|
|
237
242
|
}) {
|
|
238
|
-
var _a;
|
|
243
|
+
var _a, _b;
|
|
239
244
|
const messages = [];
|
|
240
245
|
const warnings = [];
|
|
241
|
-
for (const { role, content } of prompt) {
|
|
246
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
242
247
|
switch (role) {
|
|
243
248
|
case "system": {
|
|
244
249
|
switch (systemMessageMode) {
|
|
245
250
|
case "system": {
|
|
246
|
-
|
|
251
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
252
|
+
messages.push({
|
|
253
|
+
role: "system",
|
|
254
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
255
|
+
{
|
|
256
|
+
type: "text",
|
|
257
|
+
text: content,
|
|
258
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
});
|
|
247
262
|
break;
|
|
248
263
|
}
|
|
249
264
|
case "developer": {
|
|
250
|
-
|
|
265
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
266
|
+
messages.push({
|
|
267
|
+
role: "developer",
|
|
268
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
269
|
+
{
|
|
270
|
+
type: "text",
|
|
271
|
+
text: content,
|
|
272
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
});
|
|
251
276
|
break;
|
|
252
277
|
}
|
|
253
278
|
case "remove": {
|
|
@@ -267,19 +292,31 @@ function convertToOpenAIChatMessages({
|
|
|
267
292
|
break;
|
|
268
293
|
}
|
|
269
294
|
case "user": {
|
|
270
|
-
if (content.length === 1 && content[0].type === "text") {
|
|
295
|
+
if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
|
|
271
296
|
messages.push({ role: "user", content: content[0].text });
|
|
272
297
|
break;
|
|
273
298
|
}
|
|
274
299
|
messages.push({
|
|
275
300
|
role: "user",
|
|
276
301
|
content: content.map((part, index) => {
|
|
277
|
-
var _a2,
|
|
302
|
+
var _a2, _b2, _c;
|
|
278
303
|
switch (part.type) {
|
|
279
304
|
case "text": {
|
|
280
|
-
|
|
305
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
306
|
+
part.providerOptions
|
|
307
|
+
);
|
|
308
|
+
return {
|
|
309
|
+
type: "text",
|
|
310
|
+
text: part.text,
|
|
311
|
+
...promptCacheBreakpoint != null && {
|
|
312
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
313
|
+
}
|
|
314
|
+
};
|
|
281
315
|
}
|
|
282
316
|
case "file": {
|
|
317
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
318
|
+
part.providerOptions
|
|
319
|
+
);
|
|
283
320
|
switch (part.data.type) {
|
|
284
321
|
case "reference": {
|
|
285
322
|
return {
|
|
@@ -289,6 +326,9 @@ function convertToOpenAIChatMessages({
|
|
|
289
326
|
reference: part.data.reference,
|
|
290
327
|
provider: "openai"
|
|
291
328
|
})
|
|
329
|
+
},
|
|
330
|
+
...promptCacheBreakpoint != null && {
|
|
331
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
292
332
|
}
|
|
293
333
|
};
|
|
294
334
|
}
|
|
@@ -305,7 +345,10 @@ function convertToOpenAIChatMessages({
|
|
|
305
345
|
type: "image_url",
|
|
306
346
|
image_url: {
|
|
307
347
|
url: part.data.type === "url" ? part.data.url.toString() : `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`,
|
|
308
|
-
detail: (
|
|
348
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
349
|
+
},
|
|
350
|
+
...promptCacheBreakpoint != null && {
|
|
351
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
309
352
|
}
|
|
310
353
|
};
|
|
311
354
|
} else if (topLevel === "audio") {
|
|
@@ -322,6 +365,9 @@ function convertToOpenAIChatMessages({
|
|
|
322
365
|
input_audio: {
|
|
323
366
|
data: convertToBase64(part.data.data),
|
|
324
367
|
format: "wav"
|
|
368
|
+
},
|
|
369
|
+
...promptCacheBreakpoint != null && {
|
|
370
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
325
371
|
}
|
|
326
372
|
};
|
|
327
373
|
}
|
|
@@ -332,6 +378,9 @@ function convertToOpenAIChatMessages({
|
|
|
332
378
|
input_audio: {
|
|
333
379
|
data: convertToBase64(part.data.data),
|
|
334
380
|
format: "mp3"
|
|
381
|
+
},
|
|
382
|
+
...promptCacheBreakpoint != null && {
|
|
383
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
335
384
|
}
|
|
336
385
|
};
|
|
337
386
|
}
|
|
@@ -359,6 +408,9 @@ function convertToOpenAIChatMessages({
|
|
|
359
408
|
file: {
|
|
360
409
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
361
410
|
file_data: `data:application/pdf;base64,${convertToBase64(part.data.data)}`
|
|
411
|
+
},
|
|
412
|
+
...promptCacheBreakpoint != null && {
|
|
413
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
362
414
|
}
|
|
363
415
|
};
|
|
364
416
|
}
|
|
@@ -372,11 +424,24 @@ function convertToOpenAIChatMessages({
|
|
|
372
424
|
}
|
|
373
425
|
case "assistant": {
|
|
374
426
|
let text = "";
|
|
427
|
+
const textParts = [];
|
|
428
|
+
let hasPromptCacheBreakpoint = false;
|
|
375
429
|
const toolCalls = [];
|
|
376
430
|
for (const part of content) {
|
|
377
431
|
switch (part.type) {
|
|
378
432
|
case "text": {
|
|
433
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
434
|
+
part.providerOptions
|
|
435
|
+
);
|
|
379
436
|
text += part.text;
|
|
437
|
+
textParts.push({
|
|
438
|
+
type: "text",
|
|
439
|
+
text: part.text,
|
|
440
|
+
...promptCacheBreakpoint != null && {
|
|
441
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
|
|
380
445
|
break;
|
|
381
446
|
}
|
|
382
447
|
case "tool-call": {
|
|
@@ -394,7 +459,7 @@ function convertToOpenAIChatMessages({
|
|
|
394
459
|
}
|
|
395
460
|
messages.push({
|
|
396
461
|
role: "assistant",
|
|
397
|
-
content: toolCalls.length > 0 ? text || null : text,
|
|
462
|
+
content: hasPromptCacheBreakpoint ? textParts : toolCalls.length > 0 ? text || null : text,
|
|
398
463
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
399
464
|
});
|
|
400
465
|
break;
|
|
@@ -405,6 +470,7 @@ function convertToOpenAIChatMessages({
|
|
|
405
470
|
continue;
|
|
406
471
|
}
|
|
407
472
|
const output = toolResponse.output;
|
|
473
|
+
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);
|
|
408
474
|
let contentValue;
|
|
409
475
|
switch (output.type) {
|
|
410
476
|
case "text":
|
|
@@ -412,7 +478,7 @@ function convertToOpenAIChatMessages({
|
|
|
412
478
|
contentValue = output.value;
|
|
413
479
|
break;
|
|
414
480
|
case "execution-denied":
|
|
415
|
-
contentValue = (
|
|
481
|
+
contentValue = (_b = output.reason) != null ? _b : "Tool call execution denied.";
|
|
416
482
|
break;
|
|
417
483
|
case "content":
|
|
418
484
|
case "json":
|
|
@@ -423,7 +489,13 @@ function convertToOpenAIChatMessages({
|
|
|
423
489
|
messages.push({
|
|
424
490
|
role: "tool",
|
|
425
491
|
tool_call_id: toolResponse.toolCallId,
|
|
426
|
-
content: contentValue
|
|
492
|
+
content: promptCacheBreakpoint == null ? contentValue : [
|
|
493
|
+
{
|
|
494
|
+
type: "text",
|
|
495
|
+
text: contentValue,
|
|
496
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
497
|
+
}
|
|
498
|
+
]
|
|
427
499
|
});
|
|
428
500
|
}
|
|
429
501
|
break;
|
|
@@ -529,7 +601,8 @@ var openaiChatResponseSchema = lazySchema(
|
|
|
529
601
|
completion_tokens: z2.number().nullish(),
|
|
530
602
|
total_tokens: z2.number().nullish(),
|
|
531
603
|
prompt_tokens_details: z2.object({
|
|
532
|
-
cached_tokens: z2.number().nullish()
|
|
604
|
+
cached_tokens: z2.number().nullish(),
|
|
605
|
+
cache_write_tokens: z2.number().nullish()
|
|
533
606
|
}).nullish(),
|
|
534
607
|
completion_tokens_details: z2.object({
|
|
535
608
|
reasoning_tokens: z2.number().nullish(),
|
|
@@ -598,7 +671,8 @@ var openaiChatChunkSchema = lazySchema(
|
|
|
598
671
|
completion_tokens: z2.number().nullish(),
|
|
599
672
|
total_tokens: z2.number().nullish(),
|
|
600
673
|
prompt_tokens_details: z2.object({
|
|
601
|
-
cached_tokens: z2.number().nullish()
|
|
674
|
+
cached_tokens: z2.number().nullish(),
|
|
675
|
+
cache_write_tokens: z2.number().nullish()
|
|
602
676
|
}).nullish(),
|
|
603
677
|
completion_tokens_details: z2.object({
|
|
604
678
|
reasoning_tokens: z2.number().nullish(),
|
|
@@ -650,7 +724,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
650
724
|
/**
|
|
651
725
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
652
726
|
*/
|
|
653
|
-
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
|
|
727
|
+
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
654
728
|
/**
|
|
655
729
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
656
730
|
*/
|
|
@@ -694,11 +768,22 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
694
768
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
695
769
|
*/
|
|
696
770
|
promptCacheKey: z3.string().optional(),
|
|
771
|
+
/**
|
|
772
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
773
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
774
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
775
|
+
*/
|
|
776
|
+
promptCacheOptions: z3.object({
|
|
777
|
+
mode: z3.enum(["implicit", "explicit"]).optional(),
|
|
778
|
+
ttl: z3.literal("30m").optional()
|
|
779
|
+
}).optional(),
|
|
697
780
|
/**
|
|
698
781
|
* The retention policy for the prompt cache.
|
|
699
782
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
700
783
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
701
|
-
*
|
|
784
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
785
|
+
*
|
|
786
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
702
787
|
*
|
|
703
788
|
* @default 'in_memory'
|
|
704
789
|
*/
|
|
@@ -893,6 +978,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
893
978
|
reasoning_effort: resolvedReasoningEffort,
|
|
894
979
|
service_tier: openaiOptions.serviceTier,
|
|
895
980
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
981
|
+
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
896
982
|
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
897
983
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
898
984
|
// messages:
|
|
@@ -3433,7 +3519,7 @@ import {
|
|
|
3433
3519
|
|
|
3434
3520
|
// src/responses/convert-openai-responses-usage.ts
|
|
3435
3521
|
function convertOpenAIResponsesUsage(usage) {
|
|
3436
|
-
var _a, _b, _c, _d;
|
|
3522
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3437
3523
|
if (usage == null) {
|
|
3438
3524
|
return {
|
|
3439
3525
|
inputTokens: {
|
|
@@ -3453,13 +3539,14 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
3453
3539
|
const inputTokens = usage.input_tokens;
|
|
3454
3540
|
const outputTokens = usage.output_tokens;
|
|
3455
3541
|
const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
|
|
3456
|
-
const
|
|
3542
|
+
const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
|
|
3543
|
+
const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
|
|
3457
3544
|
return {
|
|
3458
3545
|
inputTokens: {
|
|
3459
3546
|
total: inputTokens,
|
|
3460
|
-
noCache: inputTokens - cachedTokens,
|
|
3547
|
+
noCache: inputTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
3461
3548
|
cacheRead: cachedTokens,
|
|
3462
|
-
cacheWrite:
|
|
3549
|
+
cacheWrite: cacheWriteTokens
|
|
3463
3550
|
},
|
|
3464
3551
|
outputTokens: {
|
|
3465
3552
|
total: outputTokens,
|
|
@@ -3488,6 +3575,10 @@ import { z as z23 } from "zod/v4";
|
|
|
3488
3575
|
function serializeToolCallArguments2(input) {
|
|
3489
3576
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
3490
3577
|
}
|
|
3578
|
+
function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
|
|
3579
|
+
var _a;
|
|
3580
|
+
return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
3581
|
+
}
|
|
3491
3582
|
function isFileId(data, prefixes) {
|
|
3492
3583
|
if (!prefixes) return false;
|
|
3493
3584
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -3511,16 +3602,42 @@ async function convertToOpenAIResponsesInput({
|
|
|
3511
3602
|
let input = [];
|
|
3512
3603
|
const warnings = [];
|
|
3513
3604
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
3514
|
-
for (const { role, content } of prompt) {
|
|
3605
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
3515
3606
|
switch (role) {
|
|
3516
3607
|
case "system": {
|
|
3517
3608
|
switch (systemMessageMode) {
|
|
3518
3609
|
case "system": {
|
|
3519
|
-
|
|
3610
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3611
|
+
providerOptions,
|
|
3612
|
+
providerOptionsName
|
|
3613
|
+
);
|
|
3614
|
+
input.push({
|
|
3615
|
+
role: "system",
|
|
3616
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
3617
|
+
{
|
|
3618
|
+
type: "input_text",
|
|
3619
|
+
text: content,
|
|
3620
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3621
|
+
}
|
|
3622
|
+
]
|
|
3623
|
+
});
|
|
3520
3624
|
break;
|
|
3521
3625
|
}
|
|
3522
3626
|
case "developer": {
|
|
3523
|
-
|
|
3627
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3628
|
+
providerOptions,
|
|
3629
|
+
providerOptionsName
|
|
3630
|
+
);
|
|
3631
|
+
input.push({
|
|
3632
|
+
role: "developer",
|
|
3633
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
3634
|
+
{
|
|
3635
|
+
type: "input_text",
|
|
3636
|
+
text: content,
|
|
3637
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3638
|
+
}
|
|
3639
|
+
]
|
|
3640
|
+
});
|
|
3524
3641
|
break;
|
|
3525
3642
|
}
|
|
3526
3643
|
case "remove": {
|
|
@@ -3546,9 +3663,23 @@ async function convertToOpenAIResponsesInput({
|
|
|
3546
3663
|
var _a2, _b2, _c2, _d2, _e2;
|
|
3547
3664
|
switch (part.type) {
|
|
3548
3665
|
case "text": {
|
|
3549
|
-
|
|
3666
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3667
|
+
part.providerOptions,
|
|
3668
|
+
providerOptionsName
|
|
3669
|
+
);
|
|
3670
|
+
return {
|
|
3671
|
+
type: "input_text",
|
|
3672
|
+
text: part.text,
|
|
3673
|
+
...promptCacheBreakpoint != null && {
|
|
3674
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3675
|
+
}
|
|
3676
|
+
};
|
|
3550
3677
|
}
|
|
3551
3678
|
case "file": {
|
|
3679
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3680
|
+
part.providerOptions,
|
|
3681
|
+
providerOptionsName
|
|
3682
|
+
);
|
|
3552
3683
|
switch (part.data.type) {
|
|
3553
3684
|
case "reference": {
|
|
3554
3685
|
const fileId = resolveProviderReference2({
|
|
@@ -3559,12 +3690,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
3559
3690
|
return {
|
|
3560
3691
|
type: "input_image",
|
|
3561
3692
|
file_id: fileId,
|
|
3562
|
-
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3693
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3694
|
+
...promptCacheBreakpoint != null && {
|
|
3695
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3696
|
+
}
|
|
3563
3697
|
};
|
|
3564
3698
|
}
|
|
3565
3699
|
return {
|
|
3566
3700
|
type: "input_file",
|
|
3567
|
-
file_id: fileId
|
|
3701
|
+
file_id: fileId,
|
|
3702
|
+
...promptCacheBreakpoint != null && {
|
|
3703
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3704
|
+
}
|
|
3568
3705
|
};
|
|
3569
3706
|
}
|
|
3570
3707
|
case "text": {
|
|
@@ -3581,13 +3718,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3581
3718
|
...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 } : {
|
|
3582
3719
|
image_url: `data:${resolveFullMediaType2({ part })};base64,${convertToBase642(part.data.data)}`
|
|
3583
3720
|
},
|
|
3584
|
-
detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3721
|
+
detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3722
|
+
...promptCacheBreakpoint != null && {
|
|
3723
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3724
|
+
}
|
|
3585
3725
|
};
|
|
3586
3726
|
} else {
|
|
3587
3727
|
if (part.data.type === "url") {
|
|
3588
3728
|
return {
|
|
3589
3729
|
type: "input_file",
|
|
3590
|
-
file_url: part.data.url.toString()
|
|
3730
|
+
file_url: part.data.url.toString(),
|
|
3731
|
+
...promptCacheBreakpoint != null && {
|
|
3732
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3733
|
+
}
|
|
3591
3734
|
};
|
|
3592
3735
|
}
|
|
3593
3736
|
const fullMediaType = resolveFullMediaType2({ part });
|
|
@@ -3601,6 +3744,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3601
3744
|
...typeof part.data.data === "string" && isFileId(part.data.data, fileIdPrefixes) ? { file_id: part.data.data } : {
|
|
3602
3745
|
filename: (_e2 = part.filename) != null ? _e2 : fullMediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
3603
3746
|
file_data: `data:${fullMediaType};base64,${convertToBase642(part.data.data)}`
|
|
3747
|
+
},
|
|
3748
|
+
...promptCacheBreakpoint != null && {
|
|
3749
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3604
3750
|
}
|
|
3605
3751
|
};
|
|
3606
3752
|
}
|
|
@@ -3617,9 +3763,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3617
3763
|
for (const part of content) {
|
|
3618
3764
|
switch (part.type) {
|
|
3619
3765
|
case "text": {
|
|
3620
|
-
const
|
|
3621
|
-
const id =
|
|
3622
|
-
const phase =
|
|
3766
|
+
const providerOptions2 = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
|
|
3767
|
+
const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3768
|
+
const phase = providerOptions2 == null ? void 0 : providerOptions2.phase;
|
|
3623
3769
|
if (hasConversation && id != null) {
|
|
3624
3770
|
break;
|
|
3625
3771
|
}
|
|
@@ -3816,12 +3962,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
3816
3962
|
break;
|
|
3817
3963
|
}
|
|
3818
3964
|
case "reasoning": {
|
|
3819
|
-
const
|
|
3965
|
+
const providerOptions2 = await parseProviderOptions6({
|
|
3820
3966
|
provider: providerOptionsName,
|
|
3821
3967
|
providerOptions: part.providerOptions,
|
|
3822
3968
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
3823
3969
|
});
|
|
3824
|
-
const reasoningId =
|
|
3970
|
+
const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3825
3971
|
if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
|
|
3826
3972
|
break;
|
|
3827
3973
|
}
|
|
@@ -3853,19 +3999,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3853
3999
|
reasoningMessages[reasoningId] = {
|
|
3854
4000
|
type: "reasoning",
|
|
3855
4001
|
id: reasoningId,
|
|
3856
|
-
encrypted_content:
|
|
4002
|
+
encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
|
|
3857
4003
|
summary: summaryParts
|
|
3858
4004
|
};
|
|
3859
4005
|
input.push(reasoningMessages[reasoningId]);
|
|
3860
4006
|
} else {
|
|
3861
4007
|
reasoningMessage.summary.push(...summaryParts);
|
|
3862
|
-
if ((
|
|
3863
|
-
reasoningMessage.encrypted_content =
|
|
4008
|
+
if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
|
|
4009
|
+
reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
|
|
3864
4010
|
}
|
|
3865
4011
|
}
|
|
3866
4012
|
}
|
|
3867
4013
|
} else {
|
|
3868
|
-
const encryptedContent =
|
|
4014
|
+
const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent;
|
|
3869
4015
|
if (encryptedContent != null) {
|
|
3870
4016
|
const summaryParts = [];
|
|
3871
4017
|
if (part.text.length > 0) {
|
|
@@ -3890,8 +4036,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
3890
4036
|
}
|
|
3891
4037
|
case "custom": {
|
|
3892
4038
|
if (part.kind === "openai.compaction") {
|
|
3893
|
-
const
|
|
3894
|
-
const id =
|
|
4039
|
+
const providerOptions2 = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName];
|
|
4040
|
+
const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3895
4041
|
if (hasConversation && id != null) {
|
|
3896
4042
|
break;
|
|
3897
4043
|
}
|
|
@@ -3899,7 +4045,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3899
4045
|
input.push({ type: "item_reference", id });
|
|
3900
4046
|
break;
|
|
3901
4047
|
}
|
|
3902
|
-
const encryptedContent =
|
|
4048
|
+
const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.encryptedContent;
|
|
3903
4049
|
if (id != null) {
|
|
3904
4050
|
input.push({
|
|
3905
4051
|
type: "compaction",
|
|
@@ -4020,9 +4166,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
4020
4166
|
case "content":
|
|
4021
4167
|
outputValue = output.value.map((item) => {
|
|
4022
4168
|
var _a2, _b2, _c2;
|
|
4169
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
4170
|
+
item.providerOptions,
|
|
4171
|
+
providerOptionsName
|
|
4172
|
+
);
|
|
4023
4173
|
switch (item.type) {
|
|
4024
4174
|
case "text":
|
|
4025
|
-
return {
|
|
4175
|
+
return {
|
|
4176
|
+
type: "input_text",
|
|
4177
|
+
text: item.text,
|
|
4178
|
+
...promptCacheBreakpoint != null && {
|
|
4179
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4180
|
+
}
|
|
4181
|
+
};
|
|
4026
4182
|
case "file": {
|
|
4027
4183
|
const topLevel = getTopLevelMediaType2(item.mediaType);
|
|
4028
4184
|
const imageDetail = (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail;
|
|
@@ -4034,13 +4190,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
4034
4190
|
return {
|
|
4035
4191
|
type: "input_image",
|
|
4036
4192
|
image_url: `data:${fullMediaType};base64,${convertToBase642(item.data.data)}`,
|
|
4037
|
-
detail: imageDetail
|
|
4193
|
+
detail: imageDetail,
|
|
4194
|
+
...promptCacheBreakpoint != null && {
|
|
4195
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4196
|
+
}
|
|
4038
4197
|
};
|
|
4039
4198
|
}
|
|
4040
4199
|
return {
|
|
4041
4200
|
type: "input_file",
|
|
4042
4201
|
filename: (_c2 = item.filename) != null ? _c2 : "data",
|
|
4043
|
-
file_data: `data:${fullMediaType};base64,${convertToBase642(item.data.data)}
|
|
4202
|
+
file_data: `data:${fullMediaType};base64,${convertToBase642(item.data.data)}`,
|
|
4203
|
+
...promptCacheBreakpoint != null && {
|
|
4204
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4205
|
+
}
|
|
4044
4206
|
};
|
|
4045
4207
|
}
|
|
4046
4208
|
if (item.data.type === "url") {
|
|
@@ -4048,12 +4210,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
4048
4210
|
return {
|
|
4049
4211
|
type: "input_image",
|
|
4050
4212
|
image_url: item.data.url.toString(),
|
|
4051
|
-
detail: imageDetail
|
|
4213
|
+
detail: imageDetail,
|
|
4214
|
+
...promptCacheBreakpoint != null && {
|
|
4215
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4216
|
+
}
|
|
4052
4217
|
};
|
|
4053
4218
|
}
|
|
4054
4219
|
return {
|
|
4055
4220
|
type: "input_file",
|
|
4056
|
-
file_url: item.data.url.toString()
|
|
4221
|
+
file_url: item.data.url.toString(),
|
|
4222
|
+
...promptCacheBreakpoint != null && {
|
|
4223
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4224
|
+
}
|
|
4057
4225
|
};
|
|
4058
4226
|
}
|
|
4059
4227
|
warnings.push({
|
|
@@ -4097,9 +4265,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
4097
4265
|
case "content":
|
|
4098
4266
|
contentValue = output.value.map((item) => {
|
|
4099
4267
|
var _a2, _b2, _c2;
|
|
4268
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
4269
|
+
item.providerOptions,
|
|
4270
|
+
providerOptionsName
|
|
4271
|
+
);
|
|
4100
4272
|
switch (item.type) {
|
|
4101
4273
|
case "text": {
|
|
4102
|
-
return {
|
|
4274
|
+
return {
|
|
4275
|
+
type: "input_text",
|
|
4276
|
+
text: item.text,
|
|
4277
|
+
...promptCacheBreakpoint != null && {
|
|
4278
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4279
|
+
}
|
|
4280
|
+
};
|
|
4103
4281
|
}
|
|
4104
4282
|
case "file": {
|
|
4105
4283
|
const topLevel = getTopLevelMediaType2(item.mediaType);
|
|
@@ -4112,13 +4290,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
4112
4290
|
return {
|
|
4113
4291
|
type: "input_image",
|
|
4114
4292
|
image_url: `data:${fullMediaType};base64,${convertToBase642(item.data.data)}`,
|
|
4115
|
-
detail: imageDetail
|
|
4293
|
+
detail: imageDetail,
|
|
4294
|
+
...promptCacheBreakpoint != null && {
|
|
4295
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4296
|
+
}
|
|
4116
4297
|
};
|
|
4117
4298
|
}
|
|
4118
4299
|
return {
|
|
4119
4300
|
type: "input_file",
|
|
4120
4301
|
filename: (_c2 = item.filename) != null ? _c2 : "data",
|
|
4121
|
-
file_data: `data:${fullMediaType};base64,${convertToBase642(item.data.data)}
|
|
4302
|
+
file_data: `data:${fullMediaType};base64,${convertToBase642(item.data.data)}`,
|
|
4303
|
+
...promptCacheBreakpoint != null && {
|
|
4304
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4305
|
+
}
|
|
4122
4306
|
};
|
|
4123
4307
|
}
|
|
4124
4308
|
if (item.data.type === "url") {
|
|
@@ -4126,12 +4310,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
4126
4310
|
return {
|
|
4127
4311
|
type: "input_image",
|
|
4128
4312
|
image_url: item.data.url.toString(),
|
|
4129
|
-
detail: imageDetail
|
|
4313
|
+
detail: imageDetail,
|
|
4314
|
+
...promptCacheBreakpoint != null && {
|
|
4315
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4316
|
+
}
|
|
4130
4317
|
};
|
|
4131
4318
|
}
|
|
4132
4319
|
return {
|
|
4133
4320
|
type: "input_file",
|
|
4134
|
-
file_url: item.data.url.toString()
|
|
4321
|
+
file_url: item.data.url.toString(),
|
|
4322
|
+
...promptCacheBreakpoint != null && {
|
|
4323
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4324
|
+
}
|
|
4135
4325
|
};
|
|
4136
4326
|
}
|
|
4137
4327
|
warnings.push({
|
|
@@ -4262,6 +4452,7 @@ var openaiResponsesChunkSchema = lazySchema22(
|
|
|
4262
4452
|
input_tokens: z24.number(),
|
|
4263
4453
|
input_tokens_details: z24.object({
|
|
4264
4454
|
cached_tokens: z24.number().nullish(),
|
|
4455
|
+
cache_write_tokens: z24.number().nullish(),
|
|
4265
4456
|
orchestration_input_tokens: z24.number().nullish(),
|
|
4266
4457
|
orchestration_input_cached_tokens: z24.number().nullish()
|
|
4267
4458
|
}).nullish(),
|
|
@@ -4271,6 +4462,9 @@ var openaiResponsesChunkSchema = lazySchema22(
|
|
|
4271
4462
|
orchestration_output_tokens: z24.number().nullish()
|
|
4272
4463
|
}).nullish()
|
|
4273
4464
|
}),
|
|
4465
|
+
reasoning: z24.object({
|
|
4466
|
+
context: z24.string().nullish()
|
|
4467
|
+
}).nullish(),
|
|
4274
4468
|
service_tier: z24.string().nullish()
|
|
4275
4469
|
})
|
|
4276
4470
|
}),
|
|
@@ -4287,6 +4481,7 @@ var openaiResponsesChunkSchema = lazySchema22(
|
|
|
4287
4481
|
input_tokens: z24.number(),
|
|
4288
4482
|
input_tokens_details: z24.object({
|
|
4289
4483
|
cached_tokens: z24.number().nullish(),
|
|
4484
|
+
cache_write_tokens: z24.number().nullish(),
|
|
4290
4485
|
orchestration_input_tokens: z24.number().nullish(),
|
|
4291
4486
|
orchestration_input_cached_tokens: z24.number().nullish()
|
|
4292
4487
|
}).nullish(),
|
|
@@ -4296,6 +4491,9 @@ var openaiResponsesChunkSchema = lazySchema22(
|
|
|
4296
4491
|
orchestration_output_tokens: z24.number().nullish()
|
|
4297
4492
|
}).nullish()
|
|
4298
4493
|
}).nullish(),
|
|
4494
|
+
reasoning: z24.object({
|
|
4495
|
+
context: z24.string().nullish()
|
|
4496
|
+
}).nullish(),
|
|
4299
4497
|
service_tier: z24.string().nullish()
|
|
4300
4498
|
})
|
|
4301
4499
|
}),
|
|
@@ -5082,11 +5280,15 @@ var openaiResponsesResponseSchema = lazySchema22(
|
|
|
5082
5280
|
])
|
|
5083
5281
|
).optional(),
|
|
5084
5282
|
service_tier: z24.string().nullish(),
|
|
5283
|
+
reasoning: z24.object({
|
|
5284
|
+
context: z24.string().nullish()
|
|
5285
|
+
}).nullish(),
|
|
5085
5286
|
incomplete_details: z24.object({ reason: z24.string() }).nullish(),
|
|
5086
5287
|
usage: z24.object({
|
|
5087
5288
|
input_tokens: z24.number(),
|
|
5088
5289
|
input_tokens_details: z24.object({
|
|
5089
5290
|
cached_tokens: z24.number().nullish(),
|
|
5291
|
+
cache_write_tokens: z24.number().nullish(),
|
|
5090
5292
|
orchestration_input_tokens: z24.number().nullish(),
|
|
5091
5293
|
orchestration_input_cached_tokens: z24.number().nullish()
|
|
5092
5294
|
}).nullish(),
|
|
@@ -5145,7 +5347,11 @@ var openaiResponsesReasoningModelIds = [
|
|
|
5145
5347
|
"gpt-5.4-pro",
|
|
5146
5348
|
"gpt-5.4-pro-2026-03-05",
|
|
5147
5349
|
"gpt-5.5",
|
|
5148
|
-
"gpt-5.5-2026-04-23"
|
|
5350
|
+
"gpt-5.5-2026-04-23",
|
|
5351
|
+
"gpt-5.6",
|
|
5352
|
+
"gpt-5.6-luna",
|
|
5353
|
+
"gpt-5.6-sol",
|
|
5354
|
+
"gpt-5.6-terra"
|
|
5149
5355
|
];
|
|
5150
5356
|
var openaiResponsesModelIds = [
|
|
5151
5357
|
"gpt-4.1",
|
|
@@ -5240,11 +5446,22 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema23(
|
|
|
5240
5446
|
* Sets a cache key to tie this prompt to cached prefixes for better caching performance.
|
|
5241
5447
|
*/
|
|
5242
5448
|
promptCacheKey: z25.string().nullish(),
|
|
5449
|
+
/**
|
|
5450
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
5451
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
5452
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
5453
|
+
*/
|
|
5454
|
+
promptCacheOptions: z25.object({
|
|
5455
|
+
mode: z25.enum(["implicit", "explicit"]).optional(),
|
|
5456
|
+
ttl: z25.literal("30m").optional()
|
|
5457
|
+
}).optional(),
|
|
5243
5458
|
/**
|
|
5244
5459
|
* The retention policy for the prompt cache.
|
|
5245
5460
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
5246
5461
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
5247
|
-
*
|
|
5462
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
5463
|
+
*
|
|
5464
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
5248
5465
|
*
|
|
5249
5466
|
* @default 'in_memory'
|
|
5250
5467
|
*/
|
|
@@ -5252,14 +5469,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema23(
|
|
|
5252
5469
|
/**
|
|
5253
5470
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5254
5471
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5255
|
-
*
|
|
5256
|
-
*
|
|
5257
|
-
* The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
|
|
5258
|
-
* models. Also, the 'xhigh' type for `reasoningEffort` is only available for
|
|
5259
|
-
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
5260
|
-
* an error.
|
|
5472
|
+
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5473
|
+
* Supported values vary by model.
|
|
5261
5474
|
*/
|
|
5262
5475
|
reasoningEffort: z25.string().nullish(),
|
|
5476
|
+
/**
|
|
5477
|
+
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5478
|
+
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
5479
|
+
*/
|
|
5480
|
+
reasoningMode: z25.enum(["standard", "pro"]).optional(),
|
|
5481
|
+
/**
|
|
5482
|
+
* Controls which available reasoning items GPT-5.6 can use.
|
|
5483
|
+
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
5484
|
+
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
5485
|
+
*/
|
|
5486
|
+
reasoningContext: z25.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
5263
5487
|
/**
|
|
5264
5488
|
* Controls reasoning summary output from the model.
|
|
5265
5489
|
* Set to "auto" to automatically receive the richest level available,
|
|
@@ -5892,6 +6116,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5892
6116
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
5893
6117
|
include,
|
|
5894
6118
|
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
6119
|
+
prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
|
|
5895
6120
|
prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
|
|
5896
6121
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
5897
6122
|
top_logprobs: topLogprobs,
|
|
@@ -5904,13 +6129,19 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5904
6129
|
}))
|
|
5905
6130
|
},
|
|
5906
6131
|
// model-specific settings:
|
|
5907
|
-
...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null) && {
|
|
6132
|
+
...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5908
6133
|
reasoning: {
|
|
5909
6134
|
...resolvedReasoningEffort != null && {
|
|
5910
6135
|
effort: resolvedReasoningEffort
|
|
5911
6136
|
},
|
|
5912
6137
|
...resolvedReasoningSummary != null && {
|
|
5913
6138
|
summary: resolvedReasoningSummary
|
|
6139
|
+
},
|
|
6140
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
|
|
6141
|
+
mode: openaiOptions.reasoningMode
|
|
6142
|
+
},
|
|
6143
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
|
|
6144
|
+
context: openaiOptions.reasoningContext
|
|
5914
6145
|
}
|
|
5915
6146
|
}
|
|
5916
6147
|
}
|
|
@@ -5949,6 +6180,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5949
6180
|
details: "reasoningSummary is not supported for non-reasoning models"
|
|
5950
6181
|
});
|
|
5951
6182
|
}
|
|
6183
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
|
|
6184
|
+
warnings.push({
|
|
6185
|
+
type: "unsupported",
|
|
6186
|
+
feature: "reasoningMode",
|
|
6187
|
+
details: "reasoningMode is not supported for non-reasoning models"
|
|
6188
|
+
});
|
|
6189
|
+
}
|
|
6190
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
|
|
6191
|
+
warnings.push({
|
|
6192
|
+
type: "unsupported",
|
|
6193
|
+
feature: "reasoningContext",
|
|
6194
|
+
details: "reasoningContext is not supported for non-reasoning models"
|
|
6195
|
+
});
|
|
6196
|
+
}
|
|
5952
6197
|
}
|
|
5953
6198
|
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
|
|
5954
6199
|
warnings.push({
|
|
@@ -5985,7 +6230,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5985
6230
|
};
|
|
5986
6231
|
}
|
|
5987
6232
|
async doGenerate(options) {
|
|
5988
|
-
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;
|
|
6233
|
+
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;
|
|
5989
6234
|
const {
|
|
5990
6235
|
args: body,
|
|
5991
6236
|
warnings,
|
|
@@ -6448,7 +6693,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6448
6693
|
[providerOptionsName]: {
|
|
6449
6694
|
responseId: response.id,
|
|
6450
6695
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
6451
|
-
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {}
|
|
6696
|
+
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
|
|
6697
|
+
...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
|
|
6452
6698
|
}
|
|
6453
6699
|
};
|
|
6454
6700
|
const usage = response.usage;
|
|
@@ -6456,10 +6702,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6456
6702
|
content,
|
|
6457
6703
|
finishReason: {
|
|
6458
6704
|
unified: mapOpenAIResponseFinishReason({
|
|
6459
|
-
finishReason: (
|
|
6705
|
+
finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
|
|
6460
6706
|
hasFunctionCall
|
|
6461
6707
|
}),
|
|
6462
|
-
raw: (
|
|
6708
|
+
raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
|
|
6463
6709
|
},
|
|
6464
6710
|
usage: convertOpenAIResponsesUsage(usage),
|
|
6465
6711
|
request: { body },
|
|
@@ -6527,6 +6773,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6527
6773
|
let hasFunctionCall = false;
|
|
6528
6774
|
const activeReasoning = {};
|
|
6529
6775
|
let serviceTier;
|
|
6776
|
+
let reasoningContext;
|
|
6530
6777
|
const hostedToolSearchCallIds = [];
|
|
6531
6778
|
let encounteredStreamError = false;
|
|
6532
6779
|
const result = {
|
|
@@ -6536,7 +6783,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6536
6783
|
controller.enqueue({ type: "stream-start", warnings });
|
|
6537
6784
|
},
|
|
6538
6785
|
transform(chunk, controller) {
|
|
6539
|
-
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;
|
|
6786
|
+
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;
|
|
6540
6787
|
if (options.includeRawChunks) {
|
|
6541
6788
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
6542
6789
|
}
|
|
@@ -7290,8 +7537,11 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7290
7537
|
if (typeof value.response.service_tier === "string") {
|
|
7291
7538
|
serviceTier = value.response.service_tier;
|
|
7292
7539
|
}
|
|
7540
|
+
if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
|
|
7541
|
+
reasoningContext = value.response.reasoning.context;
|
|
7542
|
+
}
|
|
7293
7543
|
} else if (isResponseFailedChunk(value)) {
|
|
7294
|
-
const incompleteReason = (
|
|
7544
|
+
const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
|
|
7295
7545
|
finishReason = {
|
|
7296
7546
|
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
7297
7547
|
finishReason: incompleteReason,
|
|
@@ -7299,7 +7549,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7299
7549
|
}) : "error",
|
|
7300
7550
|
raw: incompleteReason != null ? incompleteReason : "error"
|
|
7301
7551
|
};
|
|
7302
|
-
usage = (
|
|
7552
|
+
usage = (_A = value.response.usage) != null ? _A : void 0;
|
|
7553
|
+
if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
|
|
7554
|
+
reasoningContext = value.response.reasoning.context;
|
|
7555
|
+
}
|
|
7303
7556
|
if (!encounteredStreamError && value.response.error != null) {
|
|
7304
7557
|
encounteredStreamError = true;
|
|
7305
7558
|
controller.enqueue({
|
|
@@ -7321,7 +7574,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7321
7574
|
controller.enqueue({
|
|
7322
7575
|
type: "source",
|
|
7323
7576
|
sourceType: "url",
|
|
7324
|
-
id: (
|
|
7577
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
|
|
7325
7578
|
url: value.annotation.url,
|
|
7326
7579
|
title: value.annotation.title
|
|
7327
7580
|
});
|
|
@@ -7329,7 +7582,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7329
7582
|
controller.enqueue({
|
|
7330
7583
|
type: "source",
|
|
7331
7584
|
sourceType: "document",
|
|
7332
|
-
id: (
|
|
7585
|
+
id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
|
|
7333
7586
|
mediaType: "text/plain",
|
|
7334
7587
|
title: value.annotation.filename,
|
|
7335
7588
|
filename: value.annotation.filename,
|
|
@@ -7345,7 +7598,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7345
7598
|
controller.enqueue({
|
|
7346
7599
|
type: "source",
|
|
7347
7600
|
sourceType: "document",
|
|
7348
|
-
id: (
|
|
7601
|
+
id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
|
|
7349
7602
|
mediaType: "text/plain",
|
|
7350
7603
|
title: value.annotation.filename,
|
|
7351
7604
|
filename: value.annotation.filename,
|
|
@@ -7361,7 +7614,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7361
7614
|
controller.enqueue({
|
|
7362
7615
|
type: "source",
|
|
7363
7616
|
sourceType: "document",
|
|
7364
|
-
id: (
|
|
7617
|
+
id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
|
|
7365
7618
|
mediaType: "application/octet-stream",
|
|
7366
7619
|
title: value.annotation.file_id,
|
|
7367
7620
|
filename: value.annotation.file_id,
|
|
@@ -7385,7 +7638,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7385
7638
|
[providerOptionsName]: {
|
|
7386
7639
|
responseId,
|
|
7387
7640
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
7388
|
-
...serviceTier !== void 0 ? { serviceTier } : {}
|
|
7641
|
+
...serviceTier !== void 0 ? { serviceTier } : {},
|
|
7642
|
+
...reasoningContext !== void 0 ? { reasoningContext } : {}
|
|
7389
7643
|
}
|
|
7390
7644
|
};
|
|
7391
7645
|
controller.enqueue({
|
|
@@ -8250,7 +8504,7 @@ var OpenAISkills = class {
|
|
|
8250
8504
|
};
|
|
8251
8505
|
|
|
8252
8506
|
// src/version.ts
|
|
8253
|
-
var VERSION = true ? "4.0.
|
|
8507
|
+
var VERSION = true ? "4.0.11" : "0.0.0-test";
|
|
8254
8508
|
|
|
8255
8509
|
// src/openai-provider.ts
|
|
8256
8510
|
function createOpenAI(options = {}) {
|