@ai-sdk/openai 3.0.82 → 3.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.mts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +313 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +313 -68
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +16 -3
- package/dist/internal/index.d.ts +16 -3
- package/dist/internal/index.js +312 -67
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +312 -67
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +85 -31
- package/package.json +3 -3
- package/src/chat/convert-openai-chat-usage.ts +5 -2
- package/src/chat/convert-to-openai-chat-messages.ts +111 -7
- package/src/chat/openai-chat-api.ts +2 -0
- package/src/chat/openai-chat-language-model.ts +1 -0
- package/src/chat/openai-chat-options.ts +20 -2
- 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 +117 -6
- package/src/responses/openai-responses-api.ts +77 -11
- package/src/responses/openai-responses-language-model.ts +37 -1
- package/src/responses/openai-responses-options.ts +40 -7
- package/src/responses/openai-responses-provider-metadata.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -43,7 +43,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
43
43
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
44
44
|
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");
|
|
45
45
|
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
46
|
-
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");
|
|
46
|
+
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");
|
|
47
47
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
48
48
|
return {
|
|
49
49
|
supportsFlexProcessing,
|
|
@@ -179,7 +179,7 @@ function isHttpErrorStatusCode(value) {
|
|
|
179
179
|
|
|
180
180
|
// src/chat/convert-openai-chat-usage.ts
|
|
181
181
|
function convertOpenAIChatUsage(usage) {
|
|
182
|
-
var _a, _b, _c, _d, _e, _f;
|
|
182
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
183
183
|
if (usage == null) {
|
|
184
184
|
return {
|
|
185
185
|
inputTokens: {
|
|
@@ -199,13 +199,14 @@ function convertOpenAIChatUsage(usage) {
|
|
|
199
199
|
const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
|
|
200
200
|
const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
|
|
201
201
|
const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
|
|
202
|
-
const
|
|
202
|
+
const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
|
|
203
|
+
const reasoningTokens = (_h = (_g = usage.completion_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : 0;
|
|
203
204
|
return {
|
|
204
205
|
inputTokens: {
|
|
205
206
|
total: promptTokens,
|
|
206
|
-
noCache: promptTokens - cachedTokens,
|
|
207
|
+
noCache: promptTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
207
208
|
cacheRead: cachedTokens,
|
|
208
|
-
cacheWrite:
|
|
209
|
+
cacheWrite: cacheWriteTokens
|
|
209
210
|
},
|
|
210
211
|
outputTokens: {
|
|
211
212
|
total: completionTokens,
|
|
@@ -224,23 +225,47 @@ import { convertToBase64 } from "@ai-sdk/provider-utils";
|
|
|
224
225
|
function serializeToolCallArguments(input) {
|
|
225
226
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
226
227
|
}
|
|
228
|
+
function getPromptCacheBreakpoint(providerOptions) {
|
|
229
|
+
var _a;
|
|
230
|
+
return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
231
|
+
}
|
|
227
232
|
function convertToOpenAIChatMessages({
|
|
228
233
|
prompt,
|
|
229
234
|
systemMessageMode = "system"
|
|
230
235
|
}) {
|
|
231
|
-
var _a;
|
|
236
|
+
var _a, _b;
|
|
232
237
|
const messages = [];
|
|
233
238
|
const warnings = [];
|
|
234
|
-
for (const { role, content } of prompt) {
|
|
239
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
235
240
|
switch (role) {
|
|
236
241
|
case "system": {
|
|
237
242
|
switch (systemMessageMode) {
|
|
238
243
|
case "system": {
|
|
239
|
-
|
|
244
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
245
|
+
messages.push({
|
|
246
|
+
role: "system",
|
|
247
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
248
|
+
{
|
|
249
|
+
type: "text",
|
|
250
|
+
text: content,
|
|
251
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
});
|
|
240
255
|
break;
|
|
241
256
|
}
|
|
242
257
|
case "developer": {
|
|
243
|
-
|
|
258
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
259
|
+
messages.push({
|
|
260
|
+
role: "developer",
|
|
261
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
262
|
+
{
|
|
263
|
+
type: "text",
|
|
264
|
+
text: content,
|
|
265
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
});
|
|
244
269
|
break;
|
|
245
270
|
}
|
|
246
271
|
case "remove": {
|
|
@@ -260,19 +285,31 @@ function convertToOpenAIChatMessages({
|
|
|
260
285
|
break;
|
|
261
286
|
}
|
|
262
287
|
case "user": {
|
|
263
|
-
if (content.length === 1 && content[0].type === "text") {
|
|
288
|
+
if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
|
|
264
289
|
messages.push({ role: "user", content: content[0].text });
|
|
265
290
|
break;
|
|
266
291
|
}
|
|
267
292
|
messages.push({
|
|
268
293
|
role: "user",
|
|
269
294
|
content: content.map((part, index) => {
|
|
270
|
-
var _a2,
|
|
295
|
+
var _a2, _b2, _c;
|
|
271
296
|
switch (part.type) {
|
|
272
297
|
case "text": {
|
|
273
|
-
|
|
298
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
299
|
+
part.providerOptions
|
|
300
|
+
);
|
|
301
|
+
return {
|
|
302
|
+
type: "text",
|
|
303
|
+
text: part.text,
|
|
304
|
+
...promptCacheBreakpoint != null && {
|
|
305
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
306
|
+
}
|
|
307
|
+
};
|
|
274
308
|
}
|
|
275
309
|
case "file": {
|
|
310
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
311
|
+
part.providerOptions
|
|
312
|
+
);
|
|
276
313
|
if (part.mediaType.startsWith("image/")) {
|
|
277
314
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
278
315
|
return {
|
|
@@ -280,7 +317,10 @@ function convertToOpenAIChatMessages({
|
|
|
280
317
|
image_url: {
|
|
281
318
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
282
319
|
// OpenAI specific extension: image detail
|
|
283
|
-
detail: (
|
|
320
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
321
|
+
},
|
|
322
|
+
...promptCacheBreakpoint != null && {
|
|
323
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
284
324
|
}
|
|
285
325
|
};
|
|
286
326
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
@@ -296,6 +336,9 @@ function convertToOpenAIChatMessages({
|
|
|
296
336
|
input_audio: {
|
|
297
337
|
data: convertToBase64(part.data),
|
|
298
338
|
format: "wav"
|
|
339
|
+
},
|
|
340
|
+
...promptCacheBreakpoint != null && {
|
|
341
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
299
342
|
}
|
|
300
343
|
};
|
|
301
344
|
}
|
|
@@ -306,6 +349,9 @@ function convertToOpenAIChatMessages({
|
|
|
306
349
|
input_audio: {
|
|
307
350
|
data: convertToBase64(part.data),
|
|
308
351
|
format: "mp3"
|
|
352
|
+
},
|
|
353
|
+
...promptCacheBreakpoint != null && {
|
|
354
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
309
355
|
}
|
|
310
356
|
};
|
|
311
357
|
}
|
|
@@ -326,6 +372,9 @@ function convertToOpenAIChatMessages({
|
|
|
326
372
|
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
327
373
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
328
374
|
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
375
|
+
},
|
|
376
|
+
...promptCacheBreakpoint != null && {
|
|
377
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
329
378
|
}
|
|
330
379
|
};
|
|
331
380
|
} else {
|
|
@@ -341,11 +390,24 @@ function convertToOpenAIChatMessages({
|
|
|
341
390
|
}
|
|
342
391
|
case "assistant": {
|
|
343
392
|
let text = "";
|
|
393
|
+
const textParts = [];
|
|
394
|
+
let hasPromptCacheBreakpoint = false;
|
|
344
395
|
const toolCalls = [];
|
|
345
396
|
for (const part of content) {
|
|
346
397
|
switch (part.type) {
|
|
347
398
|
case "text": {
|
|
399
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
400
|
+
part.providerOptions
|
|
401
|
+
);
|
|
348
402
|
text += part.text;
|
|
403
|
+
textParts.push({
|
|
404
|
+
type: "text",
|
|
405
|
+
text: part.text,
|
|
406
|
+
...promptCacheBreakpoint != null && {
|
|
407
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
|
|
349
411
|
break;
|
|
350
412
|
}
|
|
351
413
|
case "tool-call": {
|
|
@@ -363,7 +425,7 @@ function convertToOpenAIChatMessages({
|
|
|
363
425
|
}
|
|
364
426
|
messages.push({
|
|
365
427
|
role: "assistant",
|
|
366
|
-
content: toolCalls.length > 0 ? text || null : text,
|
|
428
|
+
content: hasPromptCacheBreakpoint ? textParts : toolCalls.length > 0 ? text || null : text,
|
|
367
429
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
368
430
|
});
|
|
369
431
|
break;
|
|
@@ -374,6 +436,7 @@ function convertToOpenAIChatMessages({
|
|
|
374
436
|
continue;
|
|
375
437
|
}
|
|
376
438
|
const output = toolResponse.output;
|
|
439
|
+
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);
|
|
377
440
|
let contentValue;
|
|
378
441
|
switch (output.type) {
|
|
379
442
|
case "text":
|
|
@@ -381,7 +444,7 @@ function convertToOpenAIChatMessages({
|
|
|
381
444
|
contentValue = output.value;
|
|
382
445
|
break;
|
|
383
446
|
case "execution-denied":
|
|
384
|
-
contentValue = (
|
|
447
|
+
contentValue = (_b = output.reason) != null ? _b : "Tool call execution denied.";
|
|
385
448
|
break;
|
|
386
449
|
case "content":
|
|
387
450
|
case "json":
|
|
@@ -392,7 +455,13 @@ function convertToOpenAIChatMessages({
|
|
|
392
455
|
messages.push({
|
|
393
456
|
role: "tool",
|
|
394
457
|
tool_call_id: toolResponse.toolCallId,
|
|
395
|
-
content: contentValue
|
|
458
|
+
content: promptCacheBreakpoint == null ? contentValue : [
|
|
459
|
+
{
|
|
460
|
+
type: "text",
|
|
461
|
+
text: contentValue,
|
|
462
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
463
|
+
}
|
|
464
|
+
]
|
|
396
465
|
});
|
|
397
466
|
}
|
|
398
467
|
break;
|
|
@@ -498,7 +567,8 @@ var openaiChatResponseSchema = lazySchema(
|
|
|
498
567
|
completion_tokens: z2.number().nullish(),
|
|
499
568
|
total_tokens: z2.number().nullish(),
|
|
500
569
|
prompt_tokens_details: z2.object({
|
|
501
|
-
cached_tokens: z2.number().nullish()
|
|
570
|
+
cached_tokens: z2.number().nullish(),
|
|
571
|
+
cache_write_tokens: z2.number().nullish()
|
|
502
572
|
}).nullish(),
|
|
503
573
|
completion_tokens_details: z2.object({
|
|
504
574
|
reasoning_tokens: z2.number().nullish(),
|
|
@@ -567,7 +637,8 @@ var openaiChatChunkSchema = lazySchema(
|
|
|
567
637
|
completion_tokens: z2.number().nullish(),
|
|
568
638
|
total_tokens: z2.number().nullish(),
|
|
569
639
|
prompt_tokens_details: z2.object({
|
|
570
|
-
cached_tokens: z2.number().nullish()
|
|
640
|
+
cached_tokens: z2.number().nullish(),
|
|
641
|
+
cache_write_tokens: z2.number().nullish()
|
|
571
642
|
}).nullish(),
|
|
572
643
|
completion_tokens_details: z2.object({
|
|
573
644
|
reasoning_tokens: z2.number().nullish(),
|
|
@@ -619,7 +690,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
619
690
|
/**
|
|
620
691
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
621
692
|
*/
|
|
622
|
-
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
|
|
693
|
+
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
623
694
|
/**
|
|
624
695
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
625
696
|
*/
|
|
@@ -663,11 +734,22 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
663
734
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
664
735
|
*/
|
|
665
736
|
promptCacheKey: z3.string().optional(),
|
|
737
|
+
/**
|
|
738
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
739
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
740
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
741
|
+
*/
|
|
742
|
+
promptCacheOptions: z3.object({
|
|
743
|
+
mode: z3.enum(["implicit", "explicit"]).optional(),
|
|
744
|
+
ttl: z3.literal("30m").optional()
|
|
745
|
+
}).optional(),
|
|
666
746
|
/**
|
|
667
747
|
* The retention policy for the prompt cache.
|
|
668
748
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
669
749
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
670
|
-
*
|
|
750
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
751
|
+
*
|
|
752
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
671
753
|
*
|
|
672
754
|
* @default 'in_memory'
|
|
673
755
|
*/
|
|
@@ -851,6 +933,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
851
933
|
reasoning_effort: openaiOptions.reasoningEffort,
|
|
852
934
|
service_tier: openaiOptions.serviceTier,
|
|
853
935
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
936
|
+
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
854
937
|
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
855
938
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
856
939
|
// messages:
|
|
@@ -2920,7 +3003,7 @@ import {
|
|
|
2920
3003
|
|
|
2921
3004
|
// src/responses/convert-openai-responses-usage.ts
|
|
2922
3005
|
function convertOpenAIResponsesUsage(usage) {
|
|
2923
|
-
var _a, _b, _c, _d;
|
|
3006
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2924
3007
|
if (usage == null) {
|
|
2925
3008
|
return {
|
|
2926
3009
|
inputTokens: {
|
|
@@ -2940,13 +3023,14 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2940
3023
|
const inputTokens = usage.input_tokens;
|
|
2941
3024
|
const outputTokens = usage.output_tokens;
|
|
2942
3025
|
const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
|
|
2943
|
-
const
|
|
3026
|
+
const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
|
|
3027
|
+
const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
|
|
2944
3028
|
return {
|
|
2945
3029
|
inputTokens: {
|
|
2946
3030
|
total: inputTokens,
|
|
2947
|
-
noCache: inputTokens - cachedTokens,
|
|
3031
|
+
noCache: inputTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
2948
3032
|
cacheRead: cachedTokens,
|
|
2949
|
-
cacheWrite:
|
|
3033
|
+
cacheWrite: cacheWriteTokens
|
|
2950
3034
|
},
|
|
2951
3035
|
outputTokens: {
|
|
2952
3036
|
total: outputTokens,
|
|
@@ -2972,6 +3056,10 @@ import { z as z21 } from "zod/v4";
|
|
|
2972
3056
|
function serializeToolCallArguments2(input) {
|
|
2973
3057
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
2974
3058
|
}
|
|
3059
|
+
function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
|
|
3060
|
+
var _a;
|
|
3061
|
+
return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
3062
|
+
}
|
|
2975
3063
|
function isFileId(data, prefixes) {
|
|
2976
3064
|
if (!prefixes) return false;
|
|
2977
3065
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2995,16 +3083,42 @@ async function convertToOpenAIResponsesInput({
|
|
|
2995
3083
|
let input = [];
|
|
2996
3084
|
const warnings = [];
|
|
2997
3085
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2998
|
-
for (const { role, content } of prompt) {
|
|
3086
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
2999
3087
|
switch (role) {
|
|
3000
3088
|
case "system": {
|
|
3001
3089
|
switch (systemMessageMode) {
|
|
3002
3090
|
case "system": {
|
|
3003
|
-
|
|
3091
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3092
|
+
providerOptions,
|
|
3093
|
+
providerOptionsName
|
|
3094
|
+
);
|
|
3095
|
+
input.push({
|
|
3096
|
+
role: "system",
|
|
3097
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
3098
|
+
{
|
|
3099
|
+
type: "input_text",
|
|
3100
|
+
text: content,
|
|
3101
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3102
|
+
}
|
|
3103
|
+
]
|
|
3104
|
+
});
|
|
3004
3105
|
break;
|
|
3005
3106
|
}
|
|
3006
3107
|
case "developer": {
|
|
3007
|
-
|
|
3108
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3109
|
+
providerOptions,
|
|
3110
|
+
providerOptionsName
|
|
3111
|
+
);
|
|
3112
|
+
input.push({
|
|
3113
|
+
role: "developer",
|
|
3114
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
3115
|
+
{
|
|
3116
|
+
type: "input_text",
|
|
3117
|
+
text: content,
|
|
3118
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3119
|
+
}
|
|
3120
|
+
]
|
|
3121
|
+
});
|
|
3008
3122
|
break;
|
|
3009
3123
|
}
|
|
3010
3124
|
case "remove": {
|
|
@@ -3030,9 +3144,23 @@ async function convertToOpenAIResponsesInput({
|
|
|
3030
3144
|
var _a2, _b2, _c2;
|
|
3031
3145
|
switch (part.type) {
|
|
3032
3146
|
case "text": {
|
|
3033
|
-
|
|
3147
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3148
|
+
part.providerOptions,
|
|
3149
|
+
providerOptionsName
|
|
3150
|
+
);
|
|
3151
|
+
return {
|
|
3152
|
+
type: "input_text",
|
|
3153
|
+
text: part.text,
|
|
3154
|
+
...promptCacheBreakpoint != null && {
|
|
3155
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3156
|
+
}
|
|
3157
|
+
};
|
|
3034
3158
|
}
|
|
3035
3159
|
case "file": {
|
|
3160
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3161
|
+
part.providerOptions,
|
|
3162
|
+
providerOptionsName
|
|
3163
|
+
);
|
|
3036
3164
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
3037
3165
|
if (mediaType.startsWith("image/")) {
|
|
3038
3166
|
return {
|
|
@@ -3040,13 +3168,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3040
3168
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
3041
3169
|
image_url: `data:${mediaType};base64,${convertToBase642(part.data)}`
|
|
3042
3170
|
},
|
|
3043
|
-
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3171
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3172
|
+
...promptCacheBreakpoint != null && {
|
|
3173
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3174
|
+
}
|
|
3044
3175
|
};
|
|
3045
3176
|
}
|
|
3046
3177
|
if (part.data instanceof URL) {
|
|
3047
3178
|
return {
|
|
3048
3179
|
type: "input_file",
|
|
3049
|
-
file_url: part.data.toString()
|
|
3180
|
+
file_url: part.data.toString(),
|
|
3181
|
+
...promptCacheBreakpoint != null && {
|
|
3182
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3183
|
+
}
|
|
3050
3184
|
};
|
|
3051
3185
|
}
|
|
3052
3186
|
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
@@ -3059,6 +3193,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3059
3193
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
3060
3194
|
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
3061
3195
|
file_data: `data:${mediaType};base64,${convertToBase642(part.data)}`
|
|
3196
|
+
},
|
|
3197
|
+
...promptCacheBreakpoint != null && {
|
|
3198
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3062
3199
|
}
|
|
3063
3200
|
};
|
|
3064
3201
|
}
|
|
@@ -3271,12 +3408,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
3271
3408
|
break;
|
|
3272
3409
|
}
|
|
3273
3410
|
case "reasoning": {
|
|
3274
|
-
const
|
|
3411
|
+
const providerOptions2 = await parseProviderOptions5({
|
|
3275
3412
|
provider: providerOptionsName,
|
|
3276
3413
|
providerOptions: part.providerOptions,
|
|
3277
3414
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
3278
3415
|
});
|
|
3279
|
-
const reasoningId =
|
|
3416
|
+
const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3280
3417
|
if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
|
|
3281
3418
|
break;
|
|
3282
3419
|
}
|
|
@@ -3308,19 +3445,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3308
3445
|
reasoningMessages[reasoningId] = {
|
|
3309
3446
|
type: "reasoning",
|
|
3310
3447
|
id: reasoningId,
|
|
3311
|
-
encrypted_content:
|
|
3448
|
+
encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
|
|
3312
3449
|
summary: summaryParts
|
|
3313
3450
|
};
|
|
3314
3451
|
input.push(reasoningMessages[reasoningId]);
|
|
3315
3452
|
} else {
|
|
3316
3453
|
reasoningMessage.summary.push(...summaryParts);
|
|
3317
|
-
if ((
|
|
3318
|
-
reasoningMessage.encrypted_content =
|
|
3454
|
+
if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
|
|
3455
|
+
reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
|
|
3319
3456
|
}
|
|
3320
3457
|
}
|
|
3321
3458
|
}
|
|
3322
3459
|
} else {
|
|
3323
|
-
const encryptedContent =
|
|
3460
|
+
const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent;
|
|
3324
3461
|
if (encryptedContent != null) {
|
|
3325
3462
|
const summaryParts = [];
|
|
3326
3463
|
if (part.text.length > 0) {
|
|
@@ -3453,31 +3590,53 @@ async function convertToOpenAIResponsesInput({
|
|
|
3453
3590
|
case "content":
|
|
3454
3591
|
outputValue = output.value.map((item) => {
|
|
3455
3592
|
var _a2, _b2, _c2, _d2, _e2;
|
|
3593
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3594
|
+
item.providerOptions,
|
|
3595
|
+
providerOptionsName
|
|
3596
|
+
);
|
|
3456
3597
|
switch (item.type) {
|
|
3457
3598
|
case "text":
|
|
3458
|
-
return {
|
|
3599
|
+
return {
|
|
3600
|
+
type: "input_text",
|
|
3601
|
+
text: item.text,
|
|
3602
|
+
...promptCacheBreakpoint != null && {
|
|
3603
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3604
|
+
}
|
|
3605
|
+
};
|
|
3459
3606
|
case "image-data":
|
|
3460
3607
|
return {
|
|
3461
3608
|
type: "input_image",
|
|
3462
3609
|
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3463
|
-
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3610
|
+
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3611
|
+
...promptCacheBreakpoint != null && {
|
|
3612
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3613
|
+
}
|
|
3464
3614
|
};
|
|
3465
3615
|
case "image-url":
|
|
3466
3616
|
return {
|
|
3467
3617
|
type: "input_image",
|
|
3468
3618
|
image_url: item.url,
|
|
3469
|
-
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3619
|
+
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3620
|
+
...promptCacheBreakpoint != null && {
|
|
3621
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3622
|
+
}
|
|
3470
3623
|
};
|
|
3471
3624
|
case "file-data":
|
|
3472
3625
|
return {
|
|
3473
3626
|
type: "input_file",
|
|
3474
3627
|
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3475
|
-
file_data: `data:${item.mediaType};base64,${item.data}
|
|
3628
|
+
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
3629
|
+
...promptCacheBreakpoint != null && {
|
|
3630
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3631
|
+
}
|
|
3476
3632
|
};
|
|
3477
3633
|
case "file-url":
|
|
3478
3634
|
return {
|
|
3479
3635
|
type: "input_file",
|
|
3480
|
-
file_url: item.url
|
|
3636
|
+
file_url: item.url,
|
|
3637
|
+
...promptCacheBreakpoint != null && {
|
|
3638
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3639
|
+
}
|
|
3481
3640
|
};
|
|
3482
3641
|
default:
|
|
3483
3642
|
warnings.push({
|
|
@@ -3514,35 +3673,57 @@ async function convertToOpenAIResponsesInput({
|
|
|
3514
3673
|
case "content":
|
|
3515
3674
|
contentValue = output.value.map((item) => {
|
|
3516
3675
|
var _a2, _b2, _c2, _d2, _e2;
|
|
3676
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3677
|
+
item.providerOptions,
|
|
3678
|
+
providerOptionsName
|
|
3679
|
+
);
|
|
3517
3680
|
switch (item.type) {
|
|
3518
3681
|
case "text": {
|
|
3519
|
-
return {
|
|
3682
|
+
return {
|
|
3683
|
+
type: "input_text",
|
|
3684
|
+
text: item.text,
|
|
3685
|
+
...promptCacheBreakpoint != null && {
|
|
3686
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3687
|
+
}
|
|
3688
|
+
};
|
|
3520
3689
|
}
|
|
3521
3690
|
case "image-data": {
|
|
3522
3691
|
return {
|
|
3523
3692
|
type: "input_image",
|
|
3524
3693
|
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3525
|
-
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3694
|
+
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3695
|
+
...promptCacheBreakpoint != null && {
|
|
3696
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3697
|
+
}
|
|
3526
3698
|
};
|
|
3527
3699
|
}
|
|
3528
3700
|
case "image-url": {
|
|
3529
3701
|
return {
|
|
3530
3702
|
type: "input_image",
|
|
3531
3703
|
image_url: item.url,
|
|
3532
|
-
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3704
|
+
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3705
|
+
...promptCacheBreakpoint != null && {
|
|
3706
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3707
|
+
}
|
|
3533
3708
|
};
|
|
3534
3709
|
}
|
|
3535
3710
|
case "file-data": {
|
|
3536
3711
|
return {
|
|
3537
3712
|
type: "input_file",
|
|
3538
3713
|
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3539
|
-
file_data: `data:${item.mediaType};base64,${item.data}
|
|
3714
|
+
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
3715
|
+
...promptCacheBreakpoint != null && {
|
|
3716
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3717
|
+
}
|
|
3540
3718
|
};
|
|
3541
3719
|
}
|
|
3542
3720
|
case "file-url": {
|
|
3543
3721
|
return {
|
|
3544
3722
|
type: "input_file",
|
|
3545
|
-
file_url: item.url
|
|
3723
|
+
file_url: item.url,
|
|
3724
|
+
...promptCacheBreakpoint != null && {
|
|
3725
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3726
|
+
}
|
|
3546
3727
|
};
|
|
3547
3728
|
}
|
|
3548
3729
|
default: {
|
|
@@ -3667,6 +3848,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
3667
3848
|
input_tokens: z22.number(),
|
|
3668
3849
|
input_tokens_details: z22.object({
|
|
3669
3850
|
cached_tokens: z22.number().nullish(),
|
|
3851
|
+
cache_write_tokens: z22.number().nullish(),
|
|
3670
3852
|
orchestration_input_tokens: z22.number().nullish(),
|
|
3671
3853
|
orchestration_input_cached_tokens: z22.number().nullish()
|
|
3672
3854
|
}).nullish(),
|
|
@@ -3676,6 +3858,9 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
3676
3858
|
orchestration_output_tokens: z22.number().nullish()
|
|
3677
3859
|
}).nullish()
|
|
3678
3860
|
}),
|
|
3861
|
+
reasoning: z22.object({
|
|
3862
|
+
context: z22.string().nullish()
|
|
3863
|
+
}).nullish(),
|
|
3679
3864
|
service_tier: z22.string().nullish()
|
|
3680
3865
|
})
|
|
3681
3866
|
}),
|
|
@@ -3692,6 +3877,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
3692
3877
|
input_tokens: z22.number(),
|
|
3693
3878
|
input_tokens_details: z22.object({
|
|
3694
3879
|
cached_tokens: z22.number().nullish(),
|
|
3880
|
+
cache_write_tokens: z22.number().nullish(),
|
|
3695
3881
|
orchestration_input_tokens: z22.number().nullish(),
|
|
3696
3882
|
orchestration_input_cached_tokens: z22.number().nullish()
|
|
3697
3883
|
}).nullish(),
|
|
@@ -3701,6 +3887,9 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
3701
3887
|
orchestration_output_tokens: z22.number().nullish()
|
|
3702
3888
|
}).nullish()
|
|
3703
3889
|
}).nullish(),
|
|
3890
|
+
reasoning: z22.object({
|
|
3891
|
+
context: z22.string().nullish()
|
|
3892
|
+
}).nullish(),
|
|
3704
3893
|
service_tier: z22.string().nullish()
|
|
3705
3894
|
})
|
|
3706
3895
|
}),
|
|
@@ -4472,11 +4661,15 @@ var openaiResponsesResponseSchema = lazySchema20(
|
|
|
4472
4661
|
])
|
|
4473
4662
|
).optional(),
|
|
4474
4663
|
service_tier: z22.string().nullish(),
|
|
4664
|
+
reasoning: z22.object({
|
|
4665
|
+
context: z22.string().nullish()
|
|
4666
|
+
}).nullish(),
|
|
4475
4667
|
incomplete_details: z22.object({ reason: z22.string() }).nullish(),
|
|
4476
4668
|
usage: z22.object({
|
|
4477
4669
|
input_tokens: z22.number(),
|
|
4478
4670
|
input_tokens_details: z22.object({
|
|
4479
4671
|
cached_tokens: z22.number().nullish(),
|
|
4672
|
+
cache_write_tokens: z22.number().nullish(),
|
|
4480
4673
|
orchestration_input_tokens: z22.number().nullish(),
|
|
4481
4674
|
orchestration_input_cached_tokens: z22.number().nullish()
|
|
4482
4675
|
}).nullish(),
|
|
@@ -4535,7 +4728,11 @@ var openaiResponsesReasoningModelIds = [
|
|
|
4535
4728
|
"gpt-5.4-pro",
|
|
4536
4729
|
"gpt-5.4-pro-2026-03-05",
|
|
4537
4730
|
"gpt-5.5",
|
|
4538
|
-
"gpt-5.5-2026-04-23"
|
|
4731
|
+
"gpt-5.5-2026-04-23",
|
|
4732
|
+
"gpt-5.6",
|
|
4733
|
+
"gpt-5.6-luna",
|
|
4734
|
+
"gpt-5.6-sol",
|
|
4735
|
+
"gpt-5.6-terra"
|
|
4539
4736
|
];
|
|
4540
4737
|
var openaiResponsesModelIds = [
|
|
4541
4738
|
"gpt-4.1",
|
|
@@ -4630,11 +4827,22 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
|
|
|
4630
4827
|
* Sets a cache key to tie this prompt to cached prefixes for better caching performance.
|
|
4631
4828
|
*/
|
|
4632
4829
|
promptCacheKey: z23.string().nullish(),
|
|
4830
|
+
/**
|
|
4831
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
4832
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
4833
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
4834
|
+
*/
|
|
4835
|
+
promptCacheOptions: z23.object({
|
|
4836
|
+
mode: z23.enum(["implicit", "explicit"]).optional(),
|
|
4837
|
+
ttl: z23.literal("30m").optional()
|
|
4838
|
+
}).optional(),
|
|
4633
4839
|
/**
|
|
4634
4840
|
* The retention policy for the prompt cache.
|
|
4635
4841
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
4636
4842
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
4637
|
-
*
|
|
4843
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
4844
|
+
*
|
|
4845
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
4638
4846
|
*
|
|
4639
4847
|
* @default 'in_memory'
|
|
4640
4848
|
*/
|
|
@@ -4642,14 +4850,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
|
|
|
4642
4850
|
/**
|
|
4643
4851
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
4644
4852
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
4645
|
-
*
|
|
4646
|
-
*
|
|
4647
|
-
* The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
|
|
4648
|
-
* models. Also, the 'xhigh' type for `reasoningEffort` is only available for
|
|
4649
|
-
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
4650
|
-
* an error.
|
|
4853
|
+
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
4854
|
+
* Supported values vary by model.
|
|
4651
4855
|
*/
|
|
4652
4856
|
reasoningEffort: z23.string().nullish(),
|
|
4857
|
+
/**
|
|
4858
|
+
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
4859
|
+
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
4860
|
+
*/
|
|
4861
|
+
reasoningMode: z23.enum(["standard", "pro"]).optional(),
|
|
4862
|
+
/**
|
|
4863
|
+
* Controls which available reasoning items GPT-5.6 can use.
|
|
4864
|
+
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
4865
|
+
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
4866
|
+
*/
|
|
4867
|
+
reasoningContext: z23.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
4653
4868
|
/**
|
|
4654
4869
|
* Controls reasoning summary output from the model.
|
|
4655
4870
|
* Set to "auto" to automatically receive the richest level available,
|
|
@@ -5253,18 +5468,25 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5253
5468
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
5254
5469
|
include,
|
|
5255
5470
|
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
5471
|
+
prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
|
|
5256
5472
|
prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
|
|
5257
5473
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
5258
5474
|
top_logprobs: topLogprobs,
|
|
5259
5475
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5260
5476
|
// model-specific settings:
|
|
5261
|
-
...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
5477
|
+
...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5262
5478
|
reasoning: {
|
|
5263
5479
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
|
|
5264
5480
|
effort: openaiOptions.reasoningEffort
|
|
5265
5481
|
},
|
|
5266
5482
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
5267
5483
|
summary: openaiOptions.reasoningSummary
|
|
5484
|
+
},
|
|
5485
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
|
|
5486
|
+
mode: openaiOptions.reasoningMode
|
|
5487
|
+
},
|
|
5488
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
|
|
5489
|
+
context: openaiOptions.reasoningContext
|
|
5268
5490
|
}
|
|
5269
5491
|
}
|
|
5270
5492
|
}
|
|
@@ -5303,6 +5525,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5303
5525
|
details: "reasoningSummary is not supported for non-reasoning models"
|
|
5304
5526
|
});
|
|
5305
5527
|
}
|
|
5528
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
|
|
5529
|
+
warnings.push({
|
|
5530
|
+
type: "unsupported",
|
|
5531
|
+
feature: "reasoningMode",
|
|
5532
|
+
details: "reasoningMode is not supported for non-reasoning models"
|
|
5533
|
+
});
|
|
5534
|
+
}
|
|
5535
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
|
|
5536
|
+
warnings.push({
|
|
5537
|
+
type: "unsupported",
|
|
5538
|
+
feature: "reasoningContext",
|
|
5539
|
+
details: "reasoningContext is not supported for non-reasoning models"
|
|
5540
|
+
});
|
|
5541
|
+
}
|
|
5306
5542
|
}
|
|
5307
5543
|
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
|
|
5308
5544
|
warnings.push({
|
|
@@ -5339,7 +5575,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5339
5575
|
};
|
|
5340
5576
|
}
|
|
5341
5577
|
async doGenerate(options) {
|
|
5342
|
-
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;
|
|
5578
|
+
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;
|
|
5343
5579
|
const {
|
|
5344
5580
|
args: body,
|
|
5345
5581
|
warnings,
|
|
@@ -5788,7 +6024,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5788
6024
|
[providerOptionsName]: {
|
|
5789
6025
|
responseId: response.id,
|
|
5790
6026
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
5791
|
-
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {}
|
|
6027
|
+
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
|
|
6028
|
+
...((_z = response.reasoning) == null ? void 0 : _z.context) != null ? { reasoningContext: response.reasoning.context } : {}
|
|
5792
6029
|
}
|
|
5793
6030
|
};
|
|
5794
6031
|
const usage = response.usage;
|
|
@@ -5796,10 +6033,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5796
6033
|
content,
|
|
5797
6034
|
finishReason: {
|
|
5798
6035
|
unified: mapOpenAIResponseFinishReason({
|
|
5799
|
-
finishReason: (
|
|
6036
|
+
finishReason: (_A = response.incomplete_details) == null ? void 0 : _A.reason,
|
|
5800
6037
|
hasFunctionCall
|
|
5801
6038
|
}),
|
|
5802
|
-
raw: (
|
|
6039
|
+
raw: (_C = (_B = response.incomplete_details) == null ? void 0 : _B.reason) != null ? _C : void 0
|
|
5803
6040
|
},
|
|
5804
6041
|
usage: convertOpenAIResponsesUsage(usage),
|
|
5805
6042
|
request: { body },
|
|
@@ -5866,6 +6103,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5866
6103
|
let hasFunctionCall = false;
|
|
5867
6104
|
const activeReasoning = {};
|
|
5868
6105
|
let serviceTier;
|
|
6106
|
+
let reasoningContext;
|
|
5869
6107
|
const hostedToolSearchCallIds = [];
|
|
5870
6108
|
let encounteredStreamError = false;
|
|
5871
6109
|
const result = {
|
|
@@ -5875,7 +6113,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5875
6113
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5876
6114
|
},
|
|
5877
6115
|
transform(chunk, controller) {
|
|
5878
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
|
|
6116
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
|
|
5879
6117
|
if (options.includeRawChunks) {
|
|
5880
6118
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5881
6119
|
}
|
|
@@ -6617,8 +6855,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6617
6855
|
if (typeof value.response.service_tier === "string") {
|
|
6618
6856
|
serviceTier = value.response.service_tier;
|
|
6619
6857
|
}
|
|
6858
|
+
if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
|
|
6859
|
+
reasoningContext = value.response.reasoning.context;
|
|
6860
|
+
}
|
|
6620
6861
|
} else if (isResponseFailedChunk(value)) {
|
|
6621
|
-
const incompleteReason = (
|
|
6862
|
+
const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
|
|
6622
6863
|
finishReason = {
|
|
6623
6864
|
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
6624
6865
|
finishReason: incompleteReason,
|
|
@@ -6626,7 +6867,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6626
6867
|
}) : "error",
|
|
6627
6868
|
raw: incompleteReason != null ? incompleteReason : "error"
|
|
6628
6869
|
};
|
|
6629
|
-
usage = (
|
|
6870
|
+
usage = (_A = value.response.usage) != null ? _A : void 0;
|
|
6871
|
+
if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
|
|
6872
|
+
reasoningContext = value.response.reasoning.context;
|
|
6873
|
+
}
|
|
6630
6874
|
if (!encounteredStreamError && value.response.error != null) {
|
|
6631
6875
|
encounteredStreamError = true;
|
|
6632
6876
|
controller.enqueue({
|
|
@@ -6648,7 +6892,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6648
6892
|
controller.enqueue({
|
|
6649
6893
|
type: "source",
|
|
6650
6894
|
sourceType: "url",
|
|
6651
|
-
id: (
|
|
6895
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
|
|
6652
6896
|
url: value.annotation.url,
|
|
6653
6897
|
title: value.annotation.title
|
|
6654
6898
|
});
|
|
@@ -6656,7 +6900,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6656
6900
|
controller.enqueue({
|
|
6657
6901
|
type: "source",
|
|
6658
6902
|
sourceType: "document",
|
|
6659
|
-
id: (
|
|
6903
|
+
id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
|
|
6660
6904
|
mediaType: "text/plain",
|
|
6661
6905
|
title: value.annotation.filename,
|
|
6662
6906
|
filename: value.annotation.filename,
|
|
@@ -6672,7 +6916,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6672
6916
|
controller.enqueue({
|
|
6673
6917
|
type: "source",
|
|
6674
6918
|
sourceType: "document",
|
|
6675
|
-
id: (
|
|
6919
|
+
id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
|
|
6676
6920
|
mediaType: "text/plain",
|
|
6677
6921
|
title: value.annotation.filename,
|
|
6678
6922
|
filename: value.annotation.filename,
|
|
@@ -6688,7 +6932,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6688
6932
|
controller.enqueue({
|
|
6689
6933
|
type: "source",
|
|
6690
6934
|
sourceType: "document",
|
|
6691
|
-
id: (
|
|
6935
|
+
id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
|
|
6692
6936
|
mediaType: "application/octet-stream",
|
|
6693
6937
|
title: value.annotation.file_id,
|
|
6694
6938
|
filename: value.annotation.file_id,
|
|
@@ -6712,7 +6956,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6712
6956
|
[providerOptionsName]: {
|
|
6713
6957
|
responseId,
|
|
6714
6958
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
6715
|
-
...serviceTier !== void 0 ? { serviceTier } : {}
|
|
6959
|
+
...serviceTier !== void 0 ? { serviceTier } : {},
|
|
6960
|
+
...reasoningContext !== void 0 ? { reasoningContext } : {}
|
|
6716
6961
|
}
|
|
6717
6962
|
};
|
|
6718
6963
|
controller.enqueue({
|
|
@@ -7206,7 +7451,7 @@ var OpenAITranscriptionModel = class {
|
|
|
7206
7451
|
};
|
|
7207
7452
|
|
|
7208
7453
|
// src/version.ts
|
|
7209
|
-
var VERSION = true ? "3.0.
|
|
7454
|
+
var VERSION = true ? "3.0.84" : "0.0.0-test";
|
|
7210
7455
|
|
|
7211
7456
|
// src/openai-provider.ts
|
|
7212
7457
|
function createOpenAI(options = {}) {
|