@ai-sdk/openai 2.0.129 → 2.0.131
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 +14 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +655 -660
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +656 -660
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +666 -673
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +666 -672
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
InvalidResponseDataError
|
|
4
4
|
} from "@ai-sdk/provider";
|
|
5
5
|
import {
|
|
6
|
+
StreamingToolCallTracker,
|
|
6
7
|
combineHeaders,
|
|
7
8
|
createEventSourceResponseHandler,
|
|
8
9
|
createJsonResponseHandler,
|
|
9
10
|
generateId,
|
|
10
|
-
isParsableJson,
|
|
11
11
|
parseProviderOptions,
|
|
12
12
|
postJsonToApi
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1026,7 +1026,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1026
1026
|
abortSignal: options.abortSignal,
|
|
1027
1027
|
fetch: this.config.fetch
|
|
1028
1028
|
});
|
|
1029
|
-
|
|
1029
|
+
let toolCallTracker;
|
|
1030
1030
|
let finishReason = "unknown";
|
|
1031
1031
|
const usage = {
|
|
1032
1032
|
inputTokens: void 0,
|
|
@@ -1040,10 +1040,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1040
1040
|
stream: response.pipeThrough(
|
|
1041
1041
|
new TransformStream({
|
|
1042
1042
|
start(controller) {
|
|
1043
|
+
toolCallTracker = new StreamingToolCallTracker(controller, {
|
|
1044
|
+
generateId,
|
|
1045
|
+
typeValidation: "if-present"
|
|
1046
|
+
});
|
|
1043
1047
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1044
1048
|
},
|
|
1045
1049
|
transform(chunk, controller) {
|
|
1046
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
1050
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1047
1051
|
if (options.includeRawChunks) {
|
|
1048
1052
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1049
1053
|
}
|
|
@@ -1110,90 +1114,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1110
1114
|
}
|
|
1111
1115
|
if (delta.tool_calls != null) {
|
|
1112
1116
|
for (const toolCallDelta of delta.tool_calls) {
|
|
1113
|
-
|
|
1114
|
-
if (toolCalls[index] == null) {
|
|
1115
|
-
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
1116
|
-
throw new InvalidResponseDataError({
|
|
1117
|
-
data: toolCallDelta,
|
|
1118
|
-
message: `Expected 'function' type.`
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
if (toolCallDelta.id == null) {
|
|
1122
|
-
throw new InvalidResponseDataError({
|
|
1123
|
-
data: toolCallDelta,
|
|
1124
|
-
message: `Expected 'id' to be a string.`
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
if (((_n = toolCallDelta.function) == null ? void 0 : _n.name) == null) {
|
|
1128
|
-
throw new InvalidResponseDataError({
|
|
1129
|
-
data: toolCallDelta,
|
|
1130
|
-
message: `Expected 'function.name' to be a string.`
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
controller.enqueue({
|
|
1134
|
-
type: "tool-input-start",
|
|
1135
|
-
id: toolCallDelta.id,
|
|
1136
|
-
toolName: toolCallDelta.function.name
|
|
1137
|
-
});
|
|
1138
|
-
toolCalls[index] = {
|
|
1139
|
-
id: toolCallDelta.id,
|
|
1140
|
-
type: "function",
|
|
1141
|
-
function: {
|
|
1142
|
-
name: toolCallDelta.function.name,
|
|
1143
|
-
arguments: (_o = toolCallDelta.function.arguments) != null ? _o : ""
|
|
1144
|
-
},
|
|
1145
|
-
hasFinished: false
|
|
1146
|
-
};
|
|
1147
|
-
const toolCall2 = toolCalls[index];
|
|
1148
|
-
if (((_p = toolCall2.function) == null ? void 0 : _p.name) != null && ((_q = toolCall2.function) == null ? void 0 : _q.arguments) != null) {
|
|
1149
|
-
if (toolCall2.function.arguments.length > 0) {
|
|
1150
|
-
controller.enqueue({
|
|
1151
|
-
type: "tool-input-delta",
|
|
1152
|
-
id: toolCall2.id,
|
|
1153
|
-
delta: toolCall2.function.arguments
|
|
1154
|
-
});
|
|
1155
|
-
}
|
|
1156
|
-
if (isParsableJson(toolCall2.function.arguments)) {
|
|
1157
|
-
controller.enqueue({
|
|
1158
|
-
type: "tool-input-end",
|
|
1159
|
-
id: toolCall2.id
|
|
1160
|
-
});
|
|
1161
|
-
controller.enqueue({
|
|
1162
|
-
type: "tool-call",
|
|
1163
|
-
toolCallId: (_r = toolCall2.id) != null ? _r : generateId(),
|
|
1164
|
-
toolName: toolCall2.function.name,
|
|
1165
|
-
input: toolCall2.function.arguments
|
|
1166
|
-
});
|
|
1167
|
-
toolCall2.hasFinished = true;
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
continue;
|
|
1171
|
-
}
|
|
1172
|
-
const toolCall = toolCalls[index];
|
|
1173
|
-
if (toolCall.hasFinished) {
|
|
1174
|
-
continue;
|
|
1175
|
-
}
|
|
1176
|
-
if (((_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null) {
|
|
1177
|
-
toolCall.function.arguments += (_u = (_t = toolCallDelta.function) == null ? void 0 : _t.arguments) != null ? _u : "";
|
|
1178
|
-
}
|
|
1179
|
-
controller.enqueue({
|
|
1180
|
-
type: "tool-input-delta",
|
|
1181
|
-
id: toolCall.id,
|
|
1182
|
-
delta: (_v = toolCallDelta.function.arguments) != null ? _v : ""
|
|
1183
|
-
});
|
|
1184
|
-
if (((_w = toolCall.function) == null ? void 0 : _w.name) != null && ((_x = toolCall.function) == null ? void 0 : _x.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
1185
|
-
controller.enqueue({
|
|
1186
|
-
type: "tool-input-end",
|
|
1187
|
-
id: toolCall.id
|
|
1188
|
-
});
|
|
1189
|
-
controller.enqueue({
|
|
1190
|
-
type: "tool-call",
|
|
1191
|
-
toolCallId: (_y = toolCall.id) != null ? _y : generateId(),
|
|
1192
|
-
toolName: toolCall.function.name,
|
|
1193
|
-
input: toolCall.function.arguments
|
|
1194
|
-
});
|
|
1195
|
-
toolCall.hasFinished = true;
|
|
1196
|
-
}
|
|
1117
|
+
toolCallTracker.processDelta(toolCallDelta);
|
|
1197
1118
|
}
|
|
1198
1119
|
}
|
|
1199
1120
|
if (delta.annotations != null) {
|
|
@@ -1212,6 +1133,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1212
1133
|
if (isActiveText) {
|
|
1213
1134
|
controller.enqueue({ type: "text-end", id: "0" });
|
|
1214
1135
|
}
|
|
1136
|
+
toolCallTracker.flush();
|
|
1215
1137
|
controller.enqueue({
|
|
1216
1138
|
type: "finish",
|
|
1217
1139
|
finishReason,
|
|
@@ -2409,6 +2331,7 @@ var OpenAISpeechModel = class {
|
|
|
2409
2331
|
|
|
2410
2332
|
// src/responses/openai-responses-language-model.ts
|
|
2411
2333
|
import {
|
|
2334
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError6,
|
|
2412
2335
|
APICallError
|
|
2413
2336
|
} from "@ai-sdk/provider";
|
|
2414
2337
|
import {
|
|
@@ -2429,31 +2352,235 @@ import {
|
|
|
2429
2352
|
parseProviderOptions as parseProviderOptions7,
|
|
2430
2353
|
validateTypes
|
|
2431
2354
|
} from "@ai-sdk/provider-utils";
|
|
2432
|
-
import { z as
|
|
2355
|
+
import { z as z15 } from "zod/v4";
|
|
2433
2356
|
|
|
2434
|
-
// src/
|
|
2357
|
+
// src/responses/openai-responses-options.ts
|
|
2435
2358
|
import {
|
|
2436
|
-
|
|
2437
|
-
lazySchema,
|
|
2359
|
+
lazyValidator as lazyValidator12,
|
|
2438
2360
|
zodSchema as zodSchema12
|
|
2439
2361
|
} from "@ai-sdk/provider-utils";
|
|
2440
2362
|
import { z as z13 } from "zod/v4";
|
|
2441
|
-
var
|
|
2363
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
2364
|
+
var openaiResponsesReasoningModelIds = [
|
|
2365
|
+
"o1",
|
|
2366
|
+
"o1-2024-12-17",
|
|
2367
|
+
"o3",
|
|
2368
|
+
"o3-2025-04-16",
|
|
2369
|
+
"o3-deep-research",
|
|
2370
|
+
"o3-deep-research-2025-06-26",
|
|
2371
|
+
"o3-mini",
|
|
2372
|
+
"o3-mini-2025-01-31",
|
|
2373
|
+
"o4-mini",
|
|
2374
|
+
"o4-mini-2025-04-16",
|
|
2375
|
+
"o4-mini-deep-research",
|
|
2376
|
+
"o4-mini-deep-research-2025-06-26",
|
|
2377
|
+
"codex-mini-latest",
|
|
2378
|
+
"computer-use-preview",
|
|
2379
|
+
"gpt-5",
|
|
2380
|
+
"gpt-5-2025-08-07",
|
|
2381
|
+
"gpt-5-codex",
|
|
2382
|
+
"gpt-5-mini",
|
|
2383
|
+
"gpt-5-mini-2025-08-07",
|
|
2384
|
+
"gpt-5-nano",
|
|
2385
|
+
"gpt-5-nano-2025-08-07",
|
|
2386
|
+
"gpt-5-pro",
|
|
2387
|
+
"gpt-5-pro-2025-10-06",
|
|
2388
|
+
"gpt-5.1",
|
|
2389
|
+
"gpt-5.1-chat-latest",
|
|
2390
|
+
"gpt-5.1-codex-mini",
|
|
2391
|
+
"gpt-5.1-codex",
|
|
2392
|
+
"gpt-5.1-codex-max",
|
|
2393
|
+
"gpt-5.2",
|
|
2394
|
+
"gpt-5.2-chat-latest",
|
|
2395
|
+
"gpt-5.2-pro",
|
|
2396
|
+
"gpt-5.2-codex",
|
|
2397
|
+
"gpt-5.3-chat-latest",
|
|
2398
|
+
"gpt-5.3-codex",
|
|
2399
|
+
"gpt-5.4",
|
|
2400
|
+
"gpt-5.4-2026-03-05",
|
|
2401
|
+
"gpt-5.4-mini",
|
|
2402
|
+
"gpt-5.4-mini-2026-03-17",
|
|
2403
|
+
"gpt-5.4-nano",
|
|
2404
|
+
"gpt-5.4-nano-2026-03-17",
|
|
2405
|
+
"gpt-5.4-pro",
|
|
2406
|
+
"gpt-5.4-pro-2026-03-05",
|
|
2407
|
+
"gpt-5.6",
|
|
2408
|
+
"gpt-5.6-luna",
|
|
2409
|
+
"gpt-5.6-sol",
|
|
2410
|
+
"gpt-5.6-terra",
|
|
2411
|
+
"gpt-6-astra",
|
|
2412
|
+
"gpt-6-luna",
|
|
2413
|
+
"gpt-6-sol"
|
|
2414
|
+
];
|
|
2415
|
+
var openaiResponsesModelIds = [
|
|
2416
|
+
"gpt-4.1",
|
|
2417
|
+
"gpt-4.1-2025-04-14",
|
|
2418
|
+
"gpt-4.1-mini",
|
|
2419
|
+
"gpt-4.1-mini-2025-04-14",
|
|
2420
|
+
"gpt-4.1-nano",
|
|
2421
|
+
"gpt-4.1-nano-2025-04-14",
|
|
2422
|
+
"gpt-4o",
|
|
2423
|
+
"gpt-4o-2024-05-13",
|
|
2424
|
+
"gpt-4o-2024-08-06",
|
|
2425
|
+
"gpt-4o-2024-11-20",
|
|
2426
|
+
"gpt-4o-audio-preview",
|
|
2427
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
2428
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
2429
|
+
"gpt-4o-search-preview",
|
|
2430
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
2431
|
+
"gpt-4o-mini-search-preview",
|
|
2432
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
2433
|
+
"gpt-4o-mini",
|
|
2434
|
+
"gpt-4o-mini-2024-07-18",
|
|
2435
|
+
"gpt-4-turbo",
|
|
2436
|
+
"gpt-4-turbo-2024-04-09",
|
|
2437
|
+
"gpt-4-turbo-preview",
|
|
2438
|
+
"gpt-4-0125-preview",
|
|
2439
|
+
"gpt-4-1106-preview",
|
|
2440
|
+
"gpt-4",
|
|
2441
|
+
"gpt-4-0613",
|
|
2442
|
+
"gpt-4.5-preview",
|
|
2443
|
+
"gpt-4.5-preview-2025-02-27",
|
|
2444
|
+
"gpt-3.5-turbo-0125",
|
|
2445
|
+
"gpt-3.5-turbo",
|
|
2446
|
+
"gpt-3.5-turbo-1106",
|
|
2447
|
+
"chatgpt-4o-latest",
|
|
2448
|
+
"gpt-5-chat-latest",
|
|
2449
|
+
...openaiResponsesReasoningModelIds
|
|
2450
|
+
];
|
|
2451
|
+
var openaiResponsesProviderOptionsSchema = lazyValidator12(
|
|
2452
|
+
() => zodSchema12(
|
|
2453
|
+
z13.object({
|
|
2454
|
+
conversation: z13.string().nullish(),
|
|
2455
|
+
include: z13.array(
|
|
2456
|
+
z13.enum([
|
|
2457
|
+
"reasoning.encrypted_content",
|
|
2458
|
+
// handled internally by default, only needed for unknown reasoning models
|
|
2459
|
+
"file_search_call.results",
|
|
2460
|
+
"message.output_text.logprobs"
|
|
2461
|
+
])
|
|
2462
|
+
).nullish(),
|
|
2463
|
+
instructions: z13.string().nullish(),
|
|
2464
|
+
/**
|
|
2465
|
+
* Return the log probabilities of the tokens.
|
|
2466
|
+
*
|
|
2467
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
2468
|
+
* were generated.
|
|
2469
|
+
*
|
|
2470
|
+
* Setting to a number will return the log probabilities of the top n
|
|
2471
|
+
* tokens that were generated.
|
|
2472
|
+
*
|
|
2473
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
2474
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
2475
|
+
*/
|
|
2476
|
+
logprobs: z13.union([z13.boolean(), z13.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
2477
|
+
/**
|
|
2478
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
2479
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
2480
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
2481
|
+
*/
|
|
2482
|
+
maxToolCalls: z13.number().nullish(),
|
|
2483
|
+
metadata: z13.any().nullish(),
|
|
2484
|
+
parallelToolCalls: z13.boolean().nullish(),
|
|
2485
|
+
previousResponseId: z13.string().nullish(),
|
|
2486
|
+
promptCacheKey: z13.string().nullish(),
|
|
2487
|
+
/**
|
|
2488
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
2489
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
2490
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
2491
|
+
*/
|
|
2492
|
+
promptCacheOptions: z13.object({
|
|
2493
|
+
mode: z13.enum(["implicit", "explicit"]).optional(),
|
|
2494
|
+
ttl: z13.literal("30m").optional()
|
|
2495
|
+
}).optional(),
|
|
2496
|
+
/**
|
|
2497
|
+
* The retention policy for the prompt cache.
|
|
2498
|
+
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
2499
|
+
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
2500
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
2501
|
+
*
|
|
2502
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
2503
|
+
*
|
|
2504
|
+
* @default 'in_memory'
|
|
2505
|
+
*/
|
|
2506
|
+
promptCacheRetention: z13.enum(["in_memory", "24h"]).nullish(),
|
|
2507
|
+
/**
|
|
2508
|
+
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
2509
|
+
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
2510
|
+
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
2511
|
+
* Supported values vary by model.
|
|
2512
|
+
*/
|
|
2513
|
+
reasoningEffort: z13.string().nullish(),
|
|
2514
|
+
/**
|
|
2515
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
2516
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
2517
|
+
* request prefix for prompt caching.
|
|
2518
|
+
*
|
|
2519
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
2520
|
+
* combined with automatic truncation.
|
|
2521
|
+
*/
|
|
2522
|
+
reasoningEffortUpdate: z13.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
2523
|
+
/**
|
|
2524
|
+
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
2525
|
+
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
2526
|
+
*/
|
|
2527
|
+
reasoningMode: z13.enum(["standard", "pro"]).optional(),
|
|
2528
|
+
/**
|
|
2529
|
+
* Controls which available reasoning items GPT-5.6 can use.
|
|
2530
|
+
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
2531
|
+
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
2532
|
+
*/
|
|
2533
|
+
reasoningContext: z13.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
2534
|
+
reasoningSummary: z13.string().nullish(),
|
|
2535
|
+
safetyIdentifier: z13.string().nullish(),
|
|
2536
|
+
serviceTier: z13.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
2537
|
+
store: z13.boolean().nullish(),
|
|
2538
|
+
strictJsonSchema: z13.boolean().nullish(),
|
|
2539
|
+
textVerbosity: z13.enum(["low", "medium", "high"]).nullish(),
|
|
2540
|
+
truncation: z13.enum(["auto", "disabled"]).nullish(),
|
|
2541
|
+
user: z13.string().nullish()
|
|
2542
|
+
})
|
|
2543
|
+
)
|
|
2544
|
+
);
|
|
2545
|
+
var openaiResponsesSystemMessageOptionsSchema = lazyValidator12(
|
|
2442
2546
|
() => zodSchema12(
|
|
2443
2547
|
z13.object({
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2548
|
+
/**
|
|
2549
|
+
* Emit a configuration update at this position in Responses history.
|
|
2550
|
+
* Requires empty system message content and the same supported
|
|
2551
|
+
* configuration as the request-level reasoningEffortUpdate option.
|
|
2552
|
+
* Unsupported historical updates throw instead of being omitted.
|
|
2553
|
+
*
|
|
2554
|
+
* @see https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation
|
|
2555
|
+
*/
|
|
2556
|
+
reasoningEffortUpdate: z13.enum(["low", "medium", "high", "xhigh", "max"]).optional()
|
|
2557
|
+
})
|
|
2558
|
+
)
|
|
2559
|
+
);
|
|
2560
|
+
|
|
2561
|
+
// src/tool/local-shell.ts
|
|
2562
|
+
import {
|
|
2563
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
2564
|
+
lazySchema,
|
|
2565
|
+
zodSchema as zodSchema13
|
|
2566
|
+
} from "@ai-sdk/provider-utils";
|
|
2567
|
+
import { z as z14 } from "zod/v4";
|
|
2568
|
+
var localShellInputSchema = lazySchema(
|
|
2569
|
+
() => zodSchema13(
|
|
2570
|
+
z14.object({
|
|
2571
|
+
action: z14.object({
|
|
2572
|
+
type: z14.literal("exec"),
|
|
2573
|
+
command: z14.array(z14.string()),
|
|
2574
|
+
timeoutMs: z14.number().optional(),
|
|
2575
|
+
user: z14.string().optional(),
|
|
2576
|
+
workingDirectory: z14.string().optional(),
|
|
2577
|
+
env: z14.record(z14.string(), z14.string()).optional()
|
|
2451
2578
|
})
|
|
2452
2579
|
})
|
|
2453
2580
|
)
|
|
2454
2581
|
);
|
|
2455
2582
|
var localShellOutputSchema = lazySchema(
|
|
2456
|
-
() =>
|
|
2583
|
+
() => zodSchema13(z14.object({ output: z14.string() }))
|
|
2457
2584
|
);
|
|
2458
2585
|
var localShell = createProviderDefinedToolFactoryWithOutputSchema({
|
|
2459
2586
|
id: "openai.local_shell",
|
|
@@ -2474,9 +2601,11 @@ function isFileId(data, prefixes) {
|
|
|
2474
2601
|
async function convertToOpenAIResponsesInput({
|
|
2475
2602
|
prompt,
|
|
2476
2603
|
systemMessageMode,
|
|
2604
|
+
providerOptionsName = "openai",
|
|
2477
2605
|
explicitMessageItemType = false,
|
|
2478
2606
|
fileIdPrefixes,
|
|
2479
2607
|
store,
|
|
2608
|
+
configurationUpdateUnsupportedReason,
|
|
2480
2609
|
hasLocalShellTool = false
|
|
2481
2610
|
}) {
|
|
2482
2611
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -2485,6 +2614,33 @@ async function convertToOpenAIResponsesInput({
|
|
|
2485
2614
|
for (const { role, content, providerOptions } of prompt) {
|
|
2486
2615
|
switch (role) {
|
|
2487
2616
|
case "system": {
|
|
2617
|
+
let options = await parseProviderOptions7({
|
|
2618
|
+
provider: providerOptionsName,
|
|
2619
|
+
providerOptions,
|
|
2620
|
+
schema: openaiResponsesSystemMessageOptionsSchema
|
|
2621
|
+
});
|
|
2622
|
+
if (options == null && providerOptionsName !== "openai") {
|
|
2623
|
+
options = await parseProviderOptions7({
|
|
2624
|
+
provider: "openai",
|
|
2625
|
+
providerOptions,
|
|
2626
|
+
schema: openaiResponsesSystemMessageOptionsSchema
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
const effort = options == null ? void 0 : options.reasoningEffortUpdate;
|
|
2630
|
+
if (effort != null) {
|
|
2631
|
+
const unsupportedReason = content !== "" ? "Message-level reasoningEffortUpdate requires empty system message content." : configurationUpdateUnsupportedReason;
|
|
2632
|
+
if (unsupportedReason != null) {
|
|
2633
|
+
throw new UnsupportedFunctionalityError4({
|
|
2634
|
+
functionality: "Message-level reasoningEffortUpdate",
|
|
2635
|
+
message: unsupportedReason
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
input.push({
|
|
2639
|
+
type: "configuration_update",
|
|
2640
|
+
reasoning: { effort }
|
|
2641
|
+
});
|
|
2642
|
+
break;
|
|
2643
|
+
}
|
|
2488
2644
|
switch (systemMessageMode) {
|
|
2489
2645
|
case "system": {
|
|
2490
2646
|
const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
|
|
@@ -2830,9 +2986,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2830
2986
|
}
|
|
2831
2987
|
return { input, warnings };
|
|
2832
2988
|
}
|
|
2833
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2834
|
-
itemId:
|
|
2835
|
-
reasoningEncryptedContent:
|
|
2989
|
+
var openaiResponsesReasoningProviderOptionsSchema = z15.object({
|
|
2990
|
+
itemId: z15.string().nullish(),
|
|
2991
|
+
reasoningEncryptedContent: z15.string().nullish()
|
|
2836
2992
|
});
|
|
2837
2993
|
|
|
2838
2994
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2855,290 +3011,290 @@ function mapOpenAIResponseFinishReason({
|
|
|
2855
3011
|
|
|
2856
3012
|
// src/responses/openai-responses-api.ts
|
|
2857
3013
|
import {
|
|
2858
|
-
lazyValidator as
|
|
2859
|
-
zodSchema as
|
|
3014
|
+
lazyValidator as lazyValidator13,
|
|
3015
|
+
zodSchema as zodSchema14
|
|
2860
3016
|
} from "@ai-sdk/provider-utils";
|
|
2861
|
-
import { z as
|
|
2862
|
-
var openaiResponsesChunkSchema =
|
|
2863
|
-
() =>
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
type:
|
|
2867
|
-
item_id:
|
|
2868
|
-
delta:
|
|
2869
|
-
logprobs:
|
|
2870
|
-
|
|
2871
|
-
token:
|
|
2872
|
-
logprob:
|
|
2873
|
-
top_logprobs:
|
|
2874
|
-
|
|
2875
|
-
token:
|
|
2876
|
-
logprob:
|
|
3017
|
+
import { z as z16 } from "zod/v4";
|
|
3018
|
+
var openaiResponsesChunkSchema = lazyValidator13(
|
|
3019
|
+
() => zodSchema14(
|
|
3020
|
+
z16.union([
|
|
3021
|
+
z16.object({
|
|
3022
|
+
type: z16.literal("response.output_text.delta"),
|
|
3023
|
+
item_id: z16.string(),
|
|
3024
|
+
delta: z16.string(),
|
|
3025
|
+
logprobs: z16.array(
|
|
3026
|
+
z16.object({
|
|
3027
|
+
token: z16.string(),
|
|
3028
|
+
logprob: z16.number(),
|
|
3029
|
+
top_logprobs: z16.array(
|
|
3030
|
+
z16.object({
|
|
3031
|
+
token: z16.string(),
|
|
3032
|
+
logprob: z16.number()
|
|
2877
3033
|
})
|
|
2878
3034
|
)
|
|
2879
3035
|
})
|
|
2880
3036
|
).nullish()
|
|
2881
3037
|
}),
|
|
2882
|
-
|
|
2883
|
-
type:
|
|
2884
|
-
response:
|
|
2885
|
-
incomplete_details:
|
|
2886
|
-
usage:
|
|
2887
|
-
input_tokens:
|
|
2888
|
-
input_tokens_details:
|
|
2889
|
-
cached_tokens:
|
|
2890
|
-
cache_write_tokens:
|
|
2891
|
-
orchestration_input_tokens:
|
|
2892
|
-
orchestration_input_cached_tokens:
|
|
3038
|
+
z16.object({
|
|
3039
|
+
type: z16.enum(["response.completed", "response.incomplete"]),
|
|
3040
|
+
response: z16.object({
|
|
3041
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
3042
|
+
usage: z16.object({
|
|
3043
|
+
input_tokens: z16.number(),
|
|
3044
|
+
input_tokens_details: z16.object({
|
|
3045
|
+
cached_tokens: z16.number().nullish(),
|
|
3046
|
+
cache_write_tokens: z16.number().nullish(),
|
|
3047
|
+
orchestration_input_tokens: z16.number().nullish(),
|
|
3048
|
+
orchestration_input_cached_tokens: z16.number().nullish()
|
|
2893
3049
|
}).nullish(),
|
|
2894
|
-
output_tokens:
|
|
2895
|
-
output_tokens_details:
|
|
2896
|
-
reasoning_tokens:
|
|
2897
|
-
orchestration_output_tokens:
|
|
3050
|
+
output_tokens: z16.number(),
|
|
3051
|
+
output_tokens_details: z16.object({
|
|
3052
|
+
reasoning_tokens: z16.number().nullish(),
|
|
3053
|
+
orchestration_output_tokens: z16.number().nullish()
|
|
2898
3054
|
}).nullish()
|
|
2899
3055
|
}),
|
|
2900
|
-
reasoning:
|
|
2901
|
-
context:
|
|
3056
|
+
reasoning: z16.object({
|
|
3057
|
+
context: z16.string().nullish()
|
|
2902
3058
|
}).nullish(),
|
|
2903
|
-
service_tier:
|
|
3059
|
+
service_tier: z16.string().nullish()
|
|
2904
3060
|
})
|
|
2905
3061
|
}),
|
|
2906
|
-
|
|
2907
|
-
type:
|
|
2908
|
-
response:
|
|
2909
|
-
id:
|
|
2910
|
-
created_at:
|
|
2911
|
-
model:
|
|
2912
|
-
service_tier:
|
|
3062
|
+
z16.object({
|
|
3063
|
+
type: z16.literal("response.created"),
|
|
3064
|
+
response: z16.object({
|
|
3065
|
+
id: z16.string(),
|
|
3066
|
+
created_at: z16.number(),
|
|
3067
|
+
model: z16.string(),
|
|
3068
|
+
service_tier: z16.string().nullish()
|
|
2913
3069
|
})
|
|
2914
3070
|
}),
|
|
2915
|
-
|
|
2916
|
-
type:
|
|
2917
|
-
output_index:
|
|
2918
|
-
item:
|
|
2919
|
-
|
|
2920
|
-
type:
|
|
2921
|
-
id:
|
|
2922
|
-
phase:
|
|
3071
|
+
z16.object({
|
|
3072
|
+
type: z16.literal("response.output_item.added"),
|
|
3073
|
+
output_index: z16.number(),
|
|
3074
|
+
item: z16.discriminatedUnion("type", [
|
|
3075
|
+
z16.object({
|
|
3076
|
+
type: z16.literal("message"),
|
|
3077
|
+
id: z16.string(),
|
|
3078
|
+
phase: z16.enum(["commentary", "final_answer"]).nullish()
|
|
2923
3079
|
}),
|
|
2924
|
-
|
|
2925
|
-
type:
|
|
2926
|
-
id:
|
|
2927
|
-
encrypted_content:
|
|
3080
|
+
z16.object({
|
|
3081
|
+
type: z16.literal("reasoning"),
|
|
3082
|
+
id: z16.string(),
|
|
3083
|
+
encrypted_content: z16.string().nullish()
|
|
2928
3084
|
}),
|
|
2929
|
-
|
|
2930
|
-
type:
|
|
2931
|
-
id:
|
|
2932
|
-
call_id:
|
|
2933
|
-
name:
|
|
2934
|
-
arguments:
|
|
2935
|
-
async:
|
|
3085
|
+
z16.object({
|
|
3086
|
+
type: z16.literal("function_call"),
|
|
3087
|
+
id: z16.string(),
|
|
3088
|
+
call_id: z16.string(),
|
|
3089
|
+
name: z16.string(),
|
|
3090
|
+
arguments: z16.string(),
|
|
3091
|
+
async: z16.boolean().nullish()
|
|
2936
3092
|
}),
|
|
2937
|
-
|
|
2938
|
-
type:
|
|
2939
|
-
id:
|
|
2940
|
-
status:
|
|
3093
|
+
z16.object({
|
|
3094
|
+
type: z16.literal("web_search_call"),
|
|
3095
|
+
id: z16.string(),
|
|
3096
|
+
status: z16.string()
|
|
2941
3097
|
}),
|
|
2942
|
-
|
|
2943
|
-
type:
|
|
2944
|
-
id:
|
|
2945
|
-
status:
|
|
3098
|
+
z16.object({
|
|
3099
|
+
type: z16.literal("computer_call"),
|
|
3100
|
+
id: z16.string(),
|
|
3101
|
+
status: z16.string()
|
|
2946
3102
|
}),
|
|
2947
|
-
|
|
2948
|
-
type:
|
|
2949
|
-
id:
|
|
3103
|
+
z16.object({
|
|
3104
|
+
type: z16.literal("file_search_call"),
|
|
3105
|
+
id: z16.string()
|
|
2950
3106
|
}),
|
|
2951
|
-
|
|
2952
|
-
type:
|
|
2953
|
-
id:
|
|
3107
|
+
z16.object({
|
|
3108
|
+
type: z16.literal("image_generation_call"),
|
|
3109
|
+
id: z16.string()
|
|
2954
3110
|
}),
|
|
2955
|
-
|
|
2956
|
-
type:
|
|
2957
|
-
id:
|
|
2958
|
-
container_id:
|
|
2959
|
-
code:
|
|
2960
|
-
outputs:
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3111
|
+
z16.object({
|
|
3112
|
+
type: z16.literal("code_interpreter_call"),
|
|
3113
|
+
id: z16.string(),
|
|
3114
|
+
container_id: z16.string(),
|
|
3115
|
+
code: z16.string().nullable(),
|
|
3116
|
+
outputs: z16.array(
|
|
3117
|
+
z16.discriminatedUnion("type", [
|
|
3118
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
3119
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
2964
3120
|
])
|
|
2965
3121
|
).nullable(),
|
|
2966
|
-
status:
|
|
3122
|
+
status: z16.string()
|
|
2967
3123
|
})
|
|
2968
3124
|
])
|
|
2969
3125
|
}),
|
|
2970
|
-
|
|
2971
|
-
type:
|
|
2972
|
-
output_index:
|
|
2973
|
-
item:
|
|
2974
|
-
|
|
2975
|
-
type:
|
|
2976
|
-
id:
|
|
2977
|
-
phase:
|
|
3126
|
+
z16.object({
|
|
3127
|
+
type: z16.literal("response.output_item.done"),
|
|
3128
|
+
output_index: z16.number(),
|
|
3129
|
+
item: z16.discriminatedUnion("type", [
|
|
3130
|
+
z16.object({
|
|
3131
|
+
type: z16.literal("message"),
|
|
3132
|
+
id: z16.string(),
|
|
3133
|
+
phase: z16.enum(["commentary", "final_answer"]).nullish()
|
|
2978
3134
|
}),
|
|
2979
|
-
|
|
2980
|
-
type:
|
|
2981
|
-
id:
|
|
2982
|
-
encrypted_content:
|
|
3135
|
+
z16.object({
|
|
3136
|
+
type: z16.literal("reasoning"),
|
|
3137
|
+
id: z16.string(),
|
|
3138
|
+
encrypted_content: z16.string().nullish()
|
|
2983
3139
|
}),
|
|
2984
|
-
|
|
2985
|
-
type:
|
|
2986
|
-
id:
|
|
2987
|
-
call_id:
|
|
2988
|
-
name:
|
|
2989
|
-
arguments:
|
|
2990
|
-
async:
|
|
2991
|
-
status:
|
|
3140
|
+
z16.object({
|
|
3141
|
+
type: z16.literal("function_call"),
|
|
3142
|
+
id: z16.string(),
|
|
3143
|
+
call_id: z16.string(),
|
|
3144
|
+
name: z16.string(),
|
|
3145
|
+
arguments: z16.string(),
|
|
3146
|
+
async: z16.boolean().nullish(),
|
|
3147
|
+
status: z16.enum(["in_progress", "completed", "incomplete"])
|
|
2992
3148
|
}),
|
|
2993
|
-
|
|
2994
|
-
type:
|
|
2995
|
-
id:
|
|
2996
|
-
code:
|
|
2997
|
-
container_id:
|
|
2998
|
-
outputs:
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3149
|
+
z16.object({
|
|
3150
|
+
type: z16.literal("code_interpreter_call"),
|
|
3151
|
+
id: z16.string(),
|
|
3152
|
+
code: z16.string().nullable(),
|
|
3153
|
+
container_id: z16.string(),
|
|
3154
|
+
outputs: z16.array(
|
|
3155
|
+
z16.discriminatedUnion("type", [
|
|
3156
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
3157
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
3002
3158
|
])
|
|
3003
3159
|
).nullable()
|
|
3004
3160
|
}),
|
|
3005
|
-
|
|
3006
|
-
type:
|
|
3007
|
-
id:
|
|
3008
|
-
result:
|
|
3161
|
+
z16.object({
|
|
3162
|
+
type: z16.literal("image_generation_call"),
|
|
3163
|
+
id: z16.string(),
|
|
3164
|
+
result: z16.string()
|
|
3009
3165
|
}),
|
|
3010
|
-
|
|
3011
|
-
type:
|
|
3012
|
-
id:
|
|
3013
|
-
status:
|
|
3014
|
-
action:
|
|
3015
|
-
|
|
3016
|
-
type:
|
|
3017
|
-
query:
|
|
3018
|
-
sources:
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3166
|
+
z16.object({
|
|
3167
|
+
type: z16.literal("web_search_call"),
|
|
3168
|
+
id: z16.string(),
|
|
3169
|
+
status: z16.string(),
|
|
3170
|
+
action: z16.discriminatedUnion("type", [
|
|
3171
|
+
z16.object({
|
|
3172
|
+
type: z16.literal("search"),
|
|
3173
|
+
query: z16.string().nullish(),
|
|
3174
|
+
sources: z16.array(
|
|
3175
|
+
z16.discriminatedUnion("type", [
|
|
3176
|
+
z16.object({ type: z16.literal("url"), url: z16.string() }),
|
|
3177
|
+
z16.object({ type: z16.literal("api"), name: z16.string() })
|
|
3022
3178
|
])
|
|
3023
3179
|
).nullish()
|
|
3024
3180
|
}),
|
|
3025
|
-
|
|
3026
|
-
type:
|
|
3027
|
-
url:
|
|
3181
|
+
z16.object({
|
|
3182
|
+
type: z16.literal("open_page"),
|
|
3183
|
+
url: z16.string().nullish()
|
|
3028
3184
|
}),
|
|
3029
|
-
|
|
3030
|
-
type:
|
|
3031
|
-
url:
|
|
3032
|
-
pattern:
|
|
3185
|
+
z16.object({
|
|
3186
|
+
type: z16.literal("find_in_page"),
|
|
3187
|
+
url: z16.string().nullish(),
|
|
3188
|
+
pattern: z16.string().nullish()
|
|
3033
3189
|
})
|
|
3034
3190
|
]).nullish()
|
|
3035
3191
|
}),
|
|
3036
|
-
|
|
3037
|
-
type:
|
|
3038
|
-
id:
|
|
3039
|
-
queries:
|
|
3040
|
-
results:
|
|
3041
|
-
|
|
3042
|
-
attributes:
|
|
3043
|
-
file_id:
|
|
3044
|
-
filename:
|
|
3045
|
-
score:
|
|
3046
|
-
text:
|
|
3192
|
+
z16.object({
|
|
3193
|
+
type: z16.literal("file_search_call"),
|
|
3194
|
+
id: z16.string(),
|
|
3195
|
+
queries: z16.array(z16.string()),
|
|
3196
|
+
results: z16.array(
|
|
3197
|
+
z16.object({
|
|
3198
|
+
attributes: z16.record(z16.string(), z16.unknown()),
|
|
3199
|
+
file_id: z16.string(),
|
|
3200
|
+
filename: z16.string(),
|
|
3201
|
+
score: z16.number(),
|
|
3202
|
+
text: z16.string()
|
|
3047
3203
|
})
|
|
3048
3204
|
).nullish()
|
|
3049
3205
|
}),
|
|
3050
|
-
|
|
3051
|
-
type:
|
|
3052
|
-
id:
|
|
3053
|
-
call_id:
|
|
3054
|
-
action:
|
|
3055
|
-
type:
|
|
3056
|
-
command:
|
|
3057
|
-
timeout_ms:
|
|
3058
|
-
user:
|
|
3059
|
-
working_directory:
|
|
3060
|
-
env:
|
|
3206
|
+
z16.object({
|
|
3207
|
+
type: z16.literal("local_shell_call"),
|
|
3208
|
+
id: z16.string(),
|
|
3209
|
+
call_id: z16.string(),
|
|
3210
|
+
action: z16.object({
|
|
3211
|
+
type: z16.literal("exec"),
|
|
3212
|
+
command: z16.array(z16.string()),
|
|
3213
|
+
timeout_ms: z16.number().optional(),
|
|
3214
|
+
user: z16.string().optional(),
|
|
3215
|
+
working_directory: z16.string().optional(),
|
|
3216
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
3061
3217
|
})
|
|
3062
3218
|
}),
|
|
3063
|
-
|
|
3064
|
-
type:
|
|
3065
|
-
id:
|
|
3066
|
-
status:
|
|
3219
|
+
z16.object({
|
|
3220
|
+
type: z16.literal("computer_call"),
|
|
3221
|
+
id: z16.string(),
|
|
3222
|
+
status: z16.literal("completed")
|
|
3067
3223
|
})
|
|
3068
3224
|
])
|
|
3069
3225
|
}),
|
|
3070
|
-
|
|
3071
|
-
type:
|
|
3072
|
-
item_id:
|
|
3073
|
-
output_index:
|
|
3074
|
-
delta:
|
|
3226
|
+
z16.object({
|
|
3227
|
+
type: z16.literal("response.function_call_arguments.delta"),
|
|
3228
|
+
item_id: z16.string(),
|
|
3229
|
+
output_index: z16.number(),
|
|
3230
|
+
delta: z16.string()
|
|
3075
3231
|
}),
|
|
3076
|
-
|
|
3077
|
-
type:
|
|
3078
|
-
item_id:
|
|
3079
|
-
output_index:
|
|
3080
|
-
partial_image_b64:
|
|
3232
|
+
z16.object({
|
|
3233
|
+
type: z16.literal("response.image_generation_call.partial_image"),
|
|
3234
|
+
item_id: z16.string(),
|
|
3235
|
+
output_index: z16.number(),
|
|
3236
|
+
partial_image_b64: z16.string()
|
|
3081
3237
|
}),
|
|
3082
|
-
|
|
3083
|
-
type:
|
|
3084
|
-
item_id:
|
|
3085
|
-
output_index:
|
|
3086
|
-
delta:
|
|
3238
|
+
z16.object({
|
|
3239
|
+
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
3240
|
+
item_id: z16.string(),
|
|
3241
|
+
output_index: z16.number(),
|
|
3242
|
+
delta: z16.string()
|
|
3087
3243
|
}),
|
|
3088
|
-
|
|
3089
|
-
type:
|
|
3090
|
-
item_id:
|
|
3091
|
-
output_index:
|
|
3092
|
-
code:
|
|
3244
|
+
z16.object({
|
|
3245
|
+
type: z16.literal("response.code_interpreter_call_code.done"),
|
|
3246
|
+
item_id: z16.string(),
|
|
3247
|
+
output_index: z16.number(),
|
|
3248
|
+
code: z16.string()
|
|
3093
3249
|
}),
|
|
3094
|
-
|
|
3095
|
-
type:
|
|
3096
|
-
annotation:
|
|
3097
|
-
|
|
3098
|
-
type:
|
|
3099
|
-
start_index:
|
|
3100
|
-
end_index:
|
|
3101
|
-
url:
|
|
3102
|
-
title:
|
|
3250
|
+
z16.object({
|
|
3251
|
+
type: z16.literal("response.output_text.annotation.added"),
|
|
3252
|
+
annotation: z16.discriminatedUnion("type", [
|
|
3253
|
+
z16.object({
|
|
3254
|
+
type: z16.literal("url_citation"),
|
|
3255
|
+
start_index: z16.number(),
|
|
3256
|
+
end_index: z16.number(),
|
|
3257
|
+
url: z16.string(),
|
|
3258
|
+
title: z16.string()
|
|
3103
3259
|
}),
|
|
3104
|
-
|
|
3105
|
-
type:
|
|
3106
|
-
file_id:
|
|
3107
|
-
filename:
|
|
3108
|
-
index:
|
|
3109
|
-
start_index:
|
|
3110
|
-
end_index:
|
|
3111
|
-
quote:
|
|
3260
|
+
z16.object({
|
|
3261
|
+
type: z16.literal("file_citation"),
|
|
3262
|
+
file_id: z16.string(),
|
|
3263
|
+
filename: z16.string().nullish(),
|
|
3264
|
+
index: z16.number().nullish(),
|
|
3265
|
+
start_index: z16.number().nullish(),
|
|
3266
|
+
end_index: z16.number().nullish(),
|
|
3267
|
+
quote: z16.string().nullish()
|
|
3112
3268
|
})
|
|
3113
3269
|
])
|
|
3114
3270
|
}),
|
|
3115
|
-
|
|
3116
|
-
type:
|
|
3117
|
-
item_id:
|
|
3118
|
-
summary_index:
|
|
3271
|
+
z16.object({
|
|
3272
|
+
type: z16.literal("response.reasoning_summary_part.added"),
|
|
3273
|
+
item_id: z16.string(),
|
|
3274
|
+
summary_index: z16.number()
|
|
3119
3275
|
}),
|
|
3120
|
-
|
|
3121
|
-
type:
|
|
3122
|
-
item_id:
|
|
3123
|
-
summary_index:
|
|
3124
|
-
delta:
|
|
3276
|
+
z16.object({
|
|
3277
|
+
type: z16.literal("response.reasoning_summary_text.delta"),
|
|
3278
|
+
item_id: z16.string(),
|
|
3279
|
+
summary_index: z16.number(),
|
|
3280
|
+
delta: z16.string()
|
|
3125
3281
|
}),
|
|
3126
|
-
|
|
3127
|
-
type:
|
|
3128
|
-
item_id:
|
|
3129
|
-
summary_index:
|
|
3282
|
+
z16.object({
|
|
3283
|
+
type: z16.literal("response.reasoning_summary_part.done"),
|
|
3284
|
+
item_id: z16.string(),
|
|
3285
|
+
summary_index: z16.number()
|
|
3130
3286
|
}),
|
|
3131
|
-
|
|
3132
|
-
type:
|
|
3133
|
-
sequence_number:
|
|
3134
|
-
error:
|
|
3135
|
-
type:
|
|
3136
|
-
code:
|
|
3137
|
-
message:
|
|
3138
|
-
param:
|
|
3287
|
+
z16.object({
|
|
3288
|
+
type: z16.literal("error"),
|
|
3289
|
+
sequence_number: z16.number(),
|
|
3290
|
+
error: z16.object({
|
|
3291
|
+
type: z16.string(),
|
|
3292
|
+
code: z16.string(),
|
|
3293
|
+
message: z16.string(),
|
|
3294
|
+
param: z16.string().nullish()
|
|
3139
3295
|
})
|
|
3140
3296
|
}),
|
|
3141
|
-
|
|
3297
|
+
z16.object({ type: z16.string() }).loose().transform((value) => ({
|
|
3142
3298
|
type: "unknown_chunk",
|
|
3143
3299
|
message: value.type
|
|
3144
3300
|
}))
|
|
@@ -3146,392 +3302,203 @@ var openaiResponsesChunkSchema = lazyValidator12(
|
|
|
3146
3302
|
])
|
|
3147
3303
|
)
|
|
3148
3304
|
);
|
|
3149
|
-
var openaiResponsesResponseSchema =
|
|
3150
|
-
() =>
|
|
3151
|
-
|
|
3152
|
-
id:
|
|
3153
|
-
created_at:
|
|
3154
|
-
error:
|
|
3155
|
-
message:
|
|
3156
|
-
type:
|
|
3157
|
-
param:
|
|
3158
|
-
code:
|
|
3305
|
+
var openaiResponsesResponseSchema = lazyValidator13(
|
|
3306
|
+
() => zodSchema14(
|
|
3307
|
+
z16.object({
|
|
3308
|
+
id: z16.string().optional(),
|
|
3309
|
+
created_at: z16.number().optional(),
|
|
3310
|
+
error: z16.object({
|
|
3311
|
+
message: z16.string(),
|
|
3312
|
+
type: z16.string(),
|
|
3313
|
+
param: z16.string().nullish(),
|
|
3314
|
+
code: z16.string()
|
|
3159
3315
|
}).nullish(),
|
|
3160
|
-
model:
|
|
3161
|
-
output:
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
type:
|
|
3165
|
-
role:
|
|
3166
|
-
id:
|
|
3167
|
-
phase:
|
|
3168
|
-
content:
|
|
3169
|
-
|
|
3170
|
-
type:
|
|
3171
|
-
text:
|
|
3172
|
-
logprobs:
|
|
3173
|
-
|
|
3174
|
-
token:
|
|
3175
|
-
logprob:
|
|
3176
|
-
top_logprobs:
|
|
3177
|
-
|
|
3178
|
-
token:
|
|
3179
|
-
logprob:
|
|
3316
|
+
model: z16.string().optional(),
|
|
3317
|
+
output: z16.array(
|
|
3318
|
+
z16.discriminatedUnion("type", [
|
|
3319
|
+
z16.object({
|
|
3320
|
+
type: z16.literal("message"),
|
|
3321
|
+
role: z16.literal("assistant"),
|
|
3322
|
+
id: z16.string(),
|
|
3323
|
+
phase: z16.enum(["commentary", "final_answer"]).nullish(),
|
|
3324
|
+
content: z16.array(
|
|
3325
|
+
z16.object({
|
|
3326
|
+
type: z16.literal("output_text"),
|
|
3327
|
+
text: z16.string(),
|
|
3328
|
+
logprobs: z16.array(
|
|
3329
|
+
z16.object({
|
|
3330
|
+
token: z16.string(),
|
|
3331
|
+
logprob: z16.number(),
|
|
3332
|
+
top_logprobs: z16.array(
|
|
3333
|
+
z16.object({
|
|
3334
|
+
token: z16.string(),
|
|
3335
|
+
logprob: z16.number()
|
|
3180
3336
|
})
|
|
3181
3337
|
)
|
|
3182
3338
|
})
|
|
3183
3339
|
).nullish(),
|
|
3184
|
-
annotations:
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
type:
|
|
3188
|
-
start_index:
|
|
3189
|
-
end_index:
|
|
3190
|
-
url:
|
|
3191
|
-
title:
|
|
3340
|
+
annotations: z16.array(
|
|
3341
|
+
z16.discriminatedUnion("type", [
|
|
3342
|
+
z16.object({
|
|
3343
|
+
type: z16.literal("url_citation"),
|
|
3344
|
+
start_index: z16.number(),
|
|
3345
|
+
end_index: z16.number(),
|
|
3346
|
+
url: z16.string(),
|
|
3347
|
+
title: z16.string()
|
|
3192
3348
|
}),
|
|
3193
|
-
|
|
3194
|
-
type:
|
|
3195
|
-
file_id:
|
|
3196
|
-
filename:
|
|
3197
|
-
index:
|
|
3198
|
-
start_index:
|
|
3199
|
-
end_index:
|
|
3200
|
-
quote:
|
|
3349
|
+
z16.object({
|
|
3350
|
+
type: z16.literal("file_citation"),
|
|
3351
|
+
file_id: z16.string(),
|
|
3352
|
+
filename: z16.string().nullish(),
|
|
3353
|
+
index: z16.number().nullish(),
|
|
3354
|
+
start_index: z16.number().nullish(),
|
|
3355
|
+
end_index: z16.number().nullish(),
|
|
3356
|
+
quote: z16.string().nullish()
|
|
3201
3357
|
}),
|
|
3202
|
-
|
|
3203
|
-
type:
|
|
3204
|
-
container_id:
|
|
3205
|
-
file_id:
|
|
3206
|
-
filename:
|
|
3207
|
-
start_index:
|
|
3208
|
-
end_index:
|
|
3209
|
-
index:
|
|
3358
|
+
z16.object({
|
|
3359
|
+
type: z16.literal("container_file_citation"),
|
|
3360
|
+
container_id: z16.string(),
|
|
3361
|
+
file_id: z16.string(),
|
|
3362
|
+
filename: z16.string().nullish(),
|
|
3363
|
+
start_index: z16.number().nullish(),
|
|
3364
|
+
end_index: z16.number().nullish(),
|
|
3365
|
+
index: z16.number().nullish()
|
|
3210
3366
|
}),
|
|
3211
|
-
|
|
3212
|
-
type:
|
|
3213
|
-
file_id:
|
|
3214
|
-
index:
|
|
3367
|
+
z16.object({
|
|
3368
|
+
type: z16.literal("file_path"),
|
|
3369
|
+
file_id: z16.string(),
|
|
3370
|
+
index: z16.number().nullish()
|
|
3215
3371
|
})
|
|
3216
3372
|
])
|
|
3217
3373
|
)
|
|
3218
3374
|
})
|
|
3219
3375
|
)
|
|
3220
3376
|
}),
|
|
3221
|
-
|
|
3222
|
-
type:
|
|
3223
|
-
id:
|
|
3224
|
-
status:
|
|
3225
|
-
action:
|
|
3226
|
-
|
|
3227
|
-
type:
|
|
3228
|
-
query:
|
|
3229
|
-
sources:
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
type:
|
|
3234
|
-
name:
|
|
3377
|
+
z16.object({
|
|
3378
|
+
type: z16.literal("web_search_call"),
|
|
3379
|
+
id: z16.string(),
|
|
3380
|
+
status: z16.string(),
|
|
3381
|
+
action: z16.discriminatedUnion("type", [
|
|
3382
|
+
z16.object({
|
|
3383
|
+
type: z16.literal("search"),
|
|
3384
|
+
query: z16.string().nullish(),
|
|
3385
|
+
sources: z16.array(
|
|
3386
|
+
z16.discriminatedUnion("type", [
|
|
3387
|
+
z16.object({ type: z16.literal("url"), url: z16.string() }),
|
|
3388
|
+
z16.object({
|
|
3389
|
+
type: z16.literal("api"),
|
|
3390
|
+
name: z16.string()
|
|
3235
3391
|
})
|
|
3236
3392
|
])
|
|
3237
3393
|
).nullish()
|
|
3238
3394
|
}),
|
|
3239
|
-
|
|
3240
|
-
type:
|
|
3241
|
-
url:
|
|
3395
|
+
z16.object({
|
|
3396
|
+
type: z16.literal("open_page"),
|
|
3397
|
+
url: z16.string().nullish()
|
|
3242
3398
|
}),
|
|
3243
|
-
|
|
3244
|
-
type:
|
|
3245
|
-
url:
|
|
3246
|
-
pattern:
|
|
3399
|
+
z16.object({
|
|
3400
|
+
type: z16.literal("find_in_page"),
|
|
3401
|
+
url: z16.string().nullish(),
|
|
3402
|
+
pattern: z16.string().nullish()
|
|
3247
3403
|
})
|
|
3248
3404
|
]).nullish()
|
|
3249
3405
|
}),
|
|
3250
|
-
|
|
3251
|
-
type:
|
|
3252
|
-
id:
|
|
3253
|
-
queries:
|
|
3254
|
-
results:
|
|
3255
|
-
|
|
3256
|
-
attributes:
|
|
3257
|
-
|
|
3258
|
-
|
|
3406
|
+
z16.object({
|
|
3407
|
+
type: z16.literal("file_search_call"),
|
|
3408
|
+
id: z16.string(),
|
|
3409
|
+
queries: z16.array(z16.string()),
|
|
3410
|
+
results: z16.array(
|
|
3411
|
+
z16.object({
|
|
3412
|
+
attributes: z16.record(
|
|
3413
|
+
z16.string(),
|
|
3414
|
+
z16.union([z16.string(), z16.number(), z16.boolean()])
|
|
3259
3415
|
),
|
|
3260
|
-
file_id:
|
|
3261
|
-
filename:
|
|
3262
|
-
score:
|
|
3263
|
-
text:
|
|
3416
|
+
file_id: z16.string(),
|
|
3417
|
+
filename: z16.string(),
|
|
3418
|
+
score: z16.number(),
|
|
3419
|
+
text: z16.string()
|
|
3264
3420
|
})
|
|
3265
3421
|
).nullish()
|
|
3266
3422
|
}),
|
|
3267
|
-
|
|
3268
|
-
type:
|
|
3269
|
-
id:
|
|
3270
|
-
code:
|
|
3271
|
-
container_id:
|
|
3272
|
-
outputs:
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3423
|
+
z16.object({
|
|
3424
|
+
type: z16.literal("code_interpreter_call"),
|
|
3425
|
+
id: z16.string(),
|
|
3426
|
+
code: z16.string().nullable(),
|
|
3427
|
+
container_id: z16.string(),
|
|
3428
|
+
outputs: z16.array(
|
|
3429
|
+
z16.discriminatedUnion("type", [
|
|
3430
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
3431
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
3276
3432
|
])
|
|
3277
3433
|
).nullable()
|
|
3278
3434
|
}),
|
|
3279
|
-
|
|
3280
|
-
type:
|
|
3281
|
-
id:
|
|
3282
|
-
result:
|
|
3435
|
+
z16.object({
|
|
3436
|
+
type: z16.literal("image_generation_call"),
|
|
3437
|
+
id: z16.string(),
|
|
3438
|
+
result: z16.string()
|
|
3283
3439
|
}),
|
|
3284
|
-
|
|
3285
|
-
type:
|
|
3286
|
-
id:
|
|
3287
|
-
call_id:
|
|
3288
|
-
action:
|
|
3289
|
-
type:
|
|
3290
|
-
command:
|
|
3291
|
-
timeout_ms:
|
|
3292
|
-
user:
|
|
3293
|
-
working_directory:
|
|
3294
|
-
env:
|
|
3440
|
+
z16.object({
|
|
3441
|
+
type: z16.literal("local_shell_call"),
|
|
3442
|
+
id: z16.string(),
|
|
3443
|
+
call_id: z16.string(),
|
|
3444
|
+
action: z16.object({
|
|
3445
|
+
type: z16.literal("exec"),
|
|
3446
|
+
command: z16.array(z16.string()),
|
|
3447
|
+
timeout_ms: z16.number().optional(),
|
|
3448
|
+
user: z16.string().optional(),
|
|
3449
|
+
working_directory: z16.string().optional(),
|
|
3450
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
3295
3451
|
})
|
|
3296
3452
|
}),
|
|
3297
|
-
|
|
3298
|
-
type:
|
|
3299
|
-
call_id:
|
|
3300
|
-
name:
|
|
3301
|
-
arguments:
|
|
3302
|
-
id:
|
|
3303
|
-
async:
|
|
3453
|
+
z16.object({
|
|
3454
|
+
type: z16.literal("function_call"),
|
|
3455
|
+
call_id: z16.string(),
|
|
3456
|
+
name: z16.string(),
|
|
3457
|
+
arguments: z16.string(),
|
|
3458
|
+
id: z16.string(),
|
|
3459
|
+
async: z16.boolean().nullish()
|
|
3304
3460
|
}),
|
|
3305
|
-
|
|
3306
|
-
type:
|
|
3307
|
-
id:
|
|
3308
|
-
status:
|
|
3461
|
+
z16.object({
|
|
3462
|
+
type: z16.literal("computer_call"),
|
|
3463
|
+
id: z16.string(),
|
|
3464
|
+
status: z16.string().optional()
|
|
3309
3465
|
}),
|
|
3310
|
-
|
|
3311
|
-
type:
|
|
3312
|
-
id:
|
|
3313
|
-
encrypted_content:
|
|
3314
|
-
summary:
|
|
3315
|
-
|
|
3316
|
-
type:
|
|
3317
|
-
text:
|
|
3466
|
+
z16.object({
|
|
3467
|
+
type: z16.literal("reasoning"),
|
|
3468
|
+
id: z16.string(),
|
|
3469
|
+
encrypted_content: z16.string().nullish(),
|
|
3470
|
+
summary: z16.array(
|
|
3471
|
+
z16.object({
|
|
3472
|
+
type: z16.literal("summary_text"),
|
|
3473
|
+
text: z16.string()
|
|
3318
3474
|
})
|
|
3319
3475
|
)
|
|
3320
3476
|
})
|
|
3321
3477
|
])
|
|
3322
3478
|
).optional(),
|
|
3323
|
-
service_tier:
|
|
3324
|
-
reasoning:
|
|
3325
|
-
context:
|
|
3479
|
+
service_tier: z16.string().nullish(),
|
|
3480
|
+
reasoning: z16.object({
|
|
3481
|
+
context: z16.string().nullish()
|
|
3326
3482
|
}).nullish(),
|
|
3327
|
-
incomplete_details:
|
|
3328
|
-
usage:
|
|
3329
|
-
input_tokens:
|
|
3330
|
-
input_tokens_details:
|
|
3331
|
-
cached_tokens:
|
|
3332
|
-
cache_write_tokens:
|
|
3333
|
-
orchestration_input_tokens:
|
|
3334
|
-
orchestration_input_cached_tokens:
|
|
3483
|
+
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
3484
|
+
usage: z16.object({
|
|
3485
|
+
input_tokens: z16.number(),
|
|
3486
|
+
input_tokens_details: z16.object({
|
|
3487
|
+
cached_tokens: z16.number().nullish(),
|
|
3488
|
+
cache_write_tokens: z16.number().nullish(),
|
|
3489
|
+
orchestration_input_tokens: z16.number().nullish(),
|
|
3490
|
+
orchestration_input_cached_tokens: z16.number().nullish()
|
|
3335
3491
|
}).nullish(),
|
|
3336
|
-
output_tokens:
|
|
3337
|
-
output_tokens_details:
|
|
3338
|
-
reasoning_tokens:
|
|
3339
|
-
orchestration_output_tokens:
|
|
3492
|
+
output_tokens: z16.number(),
|
|
3493
|
+
output_tokens_details: z16.object({
|
|
3494
|
+
reasoning_tokens: z16.number().nullish(),
|
|
3495
|
+
orchestration_output_tokens: z16.number().nullish()
|
|
3340
3496
|
}).nullish()
|
|
3341
3497
|
}).optional()
|
|
3342
3498
|
})
|
|
3343
3499
|
)
|
|
3344
3500
|
);
|
|
3345
3501
|
|
|
3346
|
-
// src/responses/openai-responses-options.ts
|
|
3347
|
-
import {
|
|
3348
|
-
lazyValidator as lazyValidator13,
|
|
3349
|
-
zodSchema as zodSchema14
|
|
3350
|
-
} from "@ai-sdk/provider-utils";
|
|
3351
|
-
import { z as z16 } from "zod/v4";
|
|
3352
|
-
var TOP_LOGPROBS_MAX = 20;
|
|
3353
|
-
var openaiResponsesReasoningModelIds = [
|
|
3354
|
-
"o1",
|
|
3355
|
-
"o1-2024-12-17",
|
|
3356
|
-
"o3",
|
|
3357
|
-
"o3-2025-04-16",
|
|
3358
|
-
"o3-deep-research",
|
|
3359
|
-
"o3-deep-research-2025-06-26",
|
|
3360
|
-
"o3-mini",
|
|
3361
|
-
"o3-mini-2025-01-31",
|
|
3362
|
-
"o4-mini",
|
|
3363
|
-
"o4-mini-2025-04-16",
|
|
3364
|
-
"o4-mini-deep-research",
|
|
3365
|
-
"o4-mini-deep-research-2025-06-26",
|
|
3366
|
-
"codex-mini-latest",
|
|
3367
|
-
"computer-use-preview",
|
|
3368
|
-
"gpt-5",
|
|
3369
|
-
"gpt-5-2025-08-07",
|
|
3370
|
-
"gpt-5-codex",
|
|
3371
|
-
"gpt-5-mini",
|
|
3372
|
-
"gpt-5-mini-2025-08-07",
|
|
3373
|
-
"gpt-5-nano",
|
|
3374
|
-
"gpt-5-nano-2025-08-07",
|
|
3375
|
-
"gpt-5-pro",
|
|
3376
|
-
"gpt-5-pro-2025-10-06",
|
|
3377
|
-
"gpt-5.1",
|
|
3378
|
-
"gpt-5.1-chat-latest",
|
|
3379
|
-
"gpt-5.1-codex-mini",
|
|
3380
|
-
"gpt-5.1-codex",
|
|
3381
|
-
"gpt-5.1-codex-max",
|
|
3382
|
-
"gpt-5.2",
|
|
3383
|
-
"gpt-5.2-chat-latest",
|
|
3384
|
-
"gpt-5.2-pro",
|
|
3385
|
-
"gpt-5.2-codex",
|
|
3386
|
-
"gpt-5.3-chat-latest",
|
|
3387
|
-
"gpt-5.3-codex",
|
|
3388
|
-
"gpt-5.4",
|
|
3389
|
-
"gpt-5.4-2026-03-05",
|
|
3390
|
-
"gpt-5.4-mini",
|
|
3391
|
-
"gpt-5.4-mini-2026-03-17",
|
|
3392
|
-
"gpt-5.4-nano",
|
|
3393
|
-
"gpt-5.4-nano-2026-03-17",
|
|
3394
|
-
"gpt-5.4-pro",
|
|
3395
|
-
"gpt-5.4-pro-2026-03-05",
|
|
3396
|
-
"gpt-5.6",
|
|
3397
|
-
"gpt-5.6-luna",
|
|
3398
|
-
"gpt-5.6-sol",
|
|
3399
|
-
"gpt-5.6-terra",
|
|
3400
|
-
"gpt-6-astra",
|
|
3401
|
-
"gpt-6-luna",
|
|
3402
|
-
"gpt-6-sol"
|
|
3403
|
-
];
|
|
3404
|
-
var openaiResponsesModelIds = [
|
|
3405
|
-
"gpt-4.1",
|
|
3406
|
-
"gpt-4.1-2025-04-14",
|
|
3407
|
-
"gpt-4.1-mini",
|
|
3408
|
-
"gpt-4.1-mini-2025-04-14",
|
|
3409
|
-
"gpt-4.1-nano",
|
|
3410
|
-
"gpt-4.1-nano-2025-04-14",
|
|
3411
|
-
"gpt-4o",
|
|
3412
|
-
"gpt-4o-2024-05-13",
|
|
3413
|
-
"gpt-4o-2024-08-06",
|
|
3414
|
-
"gpt-4o-2024-11-20",
|
|
3415
|
-
"gpt-4o-audio-preview",
|
|
3416
|
-
"gpt-4o-audio-preview-2024-10-01",
|
|
3417
|
-
"gpt-4o-audio-preview-2024-12-17",
|
|
3418
|
-
"gpt-4o-search-preview",
|
|
3419
|
-
"gpt-4o-search-preview-2025-03-11",
|
|
3420
|
-
"gpt-4o-mini-search-preview",
|
|
3421
|
-
"gpt-4o-mini-search-preview-2025-03-11",
|
|
3422
|
-
"gpt-4o-mini",
|
|
3423
|
-
"gpt-4o-mini-2024-07-18",
|
|
3424
|
-
"gpt-4-turbo",
|
|
3425
|
-
"gpt-4-turbo-2024-04-09",
|
|
3426
|
-
"gpt-4-turbo-preview",
|
|
3427
|
-
"gpt-4-0125-preview",
|
|
3428
|
-
"gpt-4-1106-preview",
|
|
3429
|
-
"gpt-4",
|
|
3430
|
-
"gpt-4-0613",
|
|
3431
|
-
"gpt-4.5-preview",
|
|
3432
|
-
"gpt-4.5-preview-2025-02-27",
|
|
3433
|
-
"gpt-3.5-turbo-0125",
|
|
3434
|
-
"gpt-3.5-turbo",
|
|
3435
|
-
"gpt-3.5-turbo-1106",
|
|
3436
|
-
"chatgpt-4o-latest",
|
|
3437
|
-
"gpt-5-chat-latest",
|
|
3438
|
-
...openaiResponsesReasoningModelIds
|
|
3439
|
-
];
|
|
3440
|
-
var openaiResponsesProviderOptionsSchema = lazyValidator13(
|
|
3441
|
-
() => zodSchema14(
|
|
3442
|
-
z16.object({
|
|
3443
|
-
conversation: z16.string().nullish(),
|
|
3444
|
-
include: z16.array(
|
|
3445
|
-
z16.enum([
|
|
3446
|
-
"reasoning.encrypted_content",
|
|
3447
|
-
// handled internally by default, only needed for unknown reasoning models
|
|
3448
|
-
"file_search_call.results",
|
|
3449
|
-
"message.output_text.logprobs"
|
|
3450
|
-
])
|
|
3451
|
-
).nullish(),
|
|
3452
|
-
instructions: z16.string().nullish(),
|
|
3453
|
-
/**
|
|
3454
|
-
* Return the log probabilities of the tokens.
|
|
3455
|
-
*
|
|
3456
|
-
* Setting to true will return the log probabilities of the tokens that
|
|
3457
|
-
* were generated.
|
|
3458
|
-
*
|
|
3459
|
-
* Setting to a number will return the log probabilities of the top n
|
|
3460
|
-
* tokens that were generated.
|
|
3461
|
-
*
|
|
3462
|
-
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3463
|
-
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3464
|
-
*/
|
|
3465
|
-
logprobs: z16.union([z16.boolean(), z16.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3466
|
-
/**
|
|
3467
|
-
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3468
|
-
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3469
|
-
* Any further attempts to call a tool by the model will be ignored.
|
|
3470
|
-
*/
|
|
3471
|
-
maxToolCalls: z16.number().nullish(),
|
|
3472
|
-
metadata: z16.any().nullish(),
|
|
3473
|
-
parallelToolCalls: z16.boolean().nullish(),
|
|
3474
|
-
previousResponseId: z16.string().nullish(),
|
|
3475
|
-
promptCacheKey: z16.string().nullish(),
|
|
3476
|
-
/**
|
|
3477
|
-
* Prompt cache behavior for GPT-5.6 and later models.
|
|
3478
|
-
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
3479
|
-
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
3480
|
-
*/
|
|
3481
|
-
promptCacheOptions: z16.object({
|
|
3482
|
-
mode: z16.enum(["implicit", "explicit"]).optional(),
|
|
3483
|
-
ttl: z16.literal("30m").optional()
|
|
3484
|
-
}).optional(),
|
|
3485
|
-
/**
|
|
3486
|
-
* The retention policy for the prompt cache.
|
|
3487
|
-
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
3488
|
-
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
3489
|
-
* Available for models before GPT-5.6 that support extended caching.
|
|
3490
|
-
*
|
|
3491
|
-
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
3492
|
-
*
|
|
3493
|
-
* @default 'in_memory'
|
|
3494
|
-
*/
|
|
3495
|
-
promptCacheRetention: z16.enum(["in_memory", "24h"]).nullish(),
|
|
3496
|
-
/**
|
|
3497
|
-
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
3498
|
-
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
3499
|
-
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
3500
|
-
* Supported values vary by model.
|
|
3501
|
-
*/
|
|
3502
|
-
reasoningEffort: z16.string().nullish(),
|
|
3503
|
-
/**
|
|
3504
|
-
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
3505
|
-
* without changing the request-level reasoning effort. This preserves the
|
|
3506
|
-
* request prefix for prompt caching.
|
|
3507
|
-
*
|
|
3508
|
-
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
3509
|
-
* combined with automatic truncation.
|
|
3510
|
-
*/
|
|
3511
|
-
reasoningEffortUpdate: z16.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
3512
|
-
/**
|
|
3513
|
-
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
3514
|
-
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
3515
|
-
*/
|
|
3516
|
-
reasoningMode: z16.enum(["standard", "pro"]).optional(),
|
|
3517
|
-
/**
|
|
3518
|
-
* Controls which available reasoning items GPT-5.6 can use.
|
|
3519
|
-
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
3520
|
-
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
3521
|
-
*/
|
|
3522
|
-
reasoningContext: z16.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
3523
|
-
reasoningSummary: z16.string().nullish(),
|
|
3524
|
-
safetyIdentifier: z16.string().nullish(),
|
|
3525
|
-
serviceTier: z16.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
3526
|
-
store: z16.boolean().nullish(),
|
|
3527
|
-
strictJsonSchema: z16.boolean().nullish(),
|
|
3528
|
-
textVerbosity: z16.enum(["low", "medium", "high"]).nullish(),
|
|
3529
|
-
truncation: z16.enum(["auto", "disabled"]).nullish(),
|
|
3530
|
-
user: z16.string().nullish()
|
|
3531
|
-
})
|
|
3532
|
-
)
|
|
3533
|
-
);
|
|
3534
|
-
|
|
3535
3502
|
// src/responses/openai-responses-prepare-tools.ts
|
|
3536
3503
|
import {
|
|
3537
3504
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
@@ -3965,6 +3932,18 @@ function resolveAsyncToolOption({
|
|
|
3965
3932
|
}
|
|
3966
3933
|
|
|
3967
3934
|
// src/responses/openai-responses-language-model.ts
|
|
3935
|
+
function getConfigurationUpdateUnsupportedReason({
|
|
3936
|
+
modelCapabilities,
|
|
3937
|
+
options
|
|
3938
|
+
}) {
|
|
3939
|
+
if (!modelCapabilities.supportsConfigurationUpdate) {
|
|
3940
|
+
return "reasoningEffortUpdate is only supported by GPT-6 and later models";
|
|
3941
|
+
}
|
|
3942
|
+
if ((options == null ? void 0 : options.reasoningMode) === "pro" || (options == null ? void 0 : options.truncation) === "auto") {
|
|
3943
|
+
return "reasoningEffortUpdate requires standard reasoning mode without automatic truncation";
|
|
3944
|
+
}
|
|
3945
|
+
return void 0;
|
|
3946
|
+
}
|
|
3968
3947
|
var OpenAIResponsesLanguageModel = class {
|
|
3969
3948
|
constructor(modelId, config) {
|
|
3970
3949
|
this.specificationVersion = "v2";
|
|
@@ -4029,8 +4008,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4029
4008
|
details: "conversation and previousResponseId cannot be used together"
|
|
4030
4009
|
});
|
|
4031
4010
|
}
|
|
4011
|
+
const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
|
|
4012
|
+
modelCapabilities,
|
|
4013
|
+
options: openaiOptions
|
|
4014
|
+
});
|
|
4032
4015
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
4033
4016
|
prompt,
|
|
4017
|
+
configurationUpdateUnsupportedReason,
|
|
4018
|
+
providerOptionsName: this.config.provider.includes("azure") ? "azure" : "openai",
|
|
4034
4019
|
systemMessageMode: modelCapabilities.systemMessageMode,
|
|
4035
4020
|
explicitMessageItemType: this.config.explicitMessageItemType,
|
|
4036
4021
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
@@ -4050,18 +4035,27 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4050
4035
|
resolvedReasoningEffort = void 0;
|
|
4051
4036
|
}
|
|
4052
4037
|
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
4053
|
-
|
|
4054
|
-
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
4038
|
+
if (reasoningEffortUpdate != null && configurationUpdateUnsupportedReason != null) {
|
|
4055
4039
|
warnings.push({
|
|
4056
4040
|
type: "unsupported-setting",
|
|
4057
4041
|
setting: "reasoningEffortUpdate",
|
|
4058
|
-
details:
|
|
4042
|
+
details: configurationUpdateUnsupportedReason
|
|
4059
4043
|
});
|
|
4060
4044
|
} else if (reasoningEffortUpdate != null) {
|
|
4061
|
-
input
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4045
|
+
const firstItem = input[0];
|
|
4046
|
+
if ((firstItem == null ? void 0 : firstItem.type) !== "configuration_update" || firstItem.reasoning.effort !== reasoningEffortUpdate) {
|
|
4047
|
+
input.unshift({
|
|
4048
|
+
type: "configuration_update",
|
|
4049
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
4050
|
+
});
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
for (let i = 1; i < input.length; i++) {
|
|
4054
|
+
if (input[i - 1].type === "configuration_update" && input[i].type === "configuration_update") {
|
|
4055
|
+
throw new UnsupportedFunctionalityError6({
|
|
4056
|
+
functionality: "Adjacent reasoning effort configuration updates"
|
|
4057
|
+
});
|
|
4058
|
+
}
|
|
4065
4059
|
}
|
|
4066
4060
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
4067
4061
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|