@ai-sdk/openai 2.0.14 → 2.0.16
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 +16 -0
- package/dist/index.js +56 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -38
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +56 -38
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +56 -38
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2310,7 +2310,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2310
2310
|
});
|
|
2311
2311
|
}
|
|
2312
2312
|
}
|
|
2313
|
-
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !
|
|
2313
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelConfig.supportsFlexProcessing) {
|
|
2314
2314
|
warnings.push({
|
|
2315
2315
|
type: "unsupported-setting",
|
|
2316
2316
|
setting: "serviceTier",
|
|
@@ -2318,7 +2318,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2318
2318
|
});
|
|
2319
2319
|
delete baseArgs.service_tier;
|
|
2320
2320
|
}
|
|
2321
|
-
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !
|
|
2321
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelConfig.supportsPriorityProcessing) {
|
|
2322
2322
|
warnings.push({
|
|
2323
2323
|
type: "unsupported-setting",
|
|
2324
2324
|
setting: "serviceTier",
|
|
@@ -2345,7 +2345,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2345
2345
|
};
|
|
2346
2346
|
}
|
|
2347
2347
|
async doGenerate(options) {
|
|
2348
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2348
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2349
2349
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2350
2350
|
const url = this.config.url({
|
|
2351
2351
|
path: "/responses",
|
|
@@ -2411,7 +2411,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2411
2411
|
z13.object({
|
|
2412
2412
|
type: z13.literal("web_search_call"),
|
|
2413
2413
|
id: z13.string(),
|
|
2414
|
-
status: z13.string().optional()
|
|
2414
|
+
status: z13.string().optional(),
|
|
2415
|
+
action: z13.object({
|
|
2416
|
+
type: z13.literal("search"),
|
|
2417
|
+
query: z13.string().optional()
|
|
2418
|
+
}).nullish()
|
|
2415
2419
|
}),
|
|
2416
2420
|
z13.object({
|
|
2417
2421
|
type: z13.literal("computer_call"),
|
|
@@ -2543,14 +2547,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2543
2547
|
type: "tool-call",
|
|
2544
2548
|
toolCallId: part.id,
|
|
2545
2549
|
toolName: "web_search_preview",
|
|
2546
|
-
input: "",
|
|
2550
|
+
input: (_k = (_j = part.action) == null ? void 0 : _j.query) != null ? _k : "",
|
|
2547
2551
|
providerExecuted: true
|
|
2548
2552
|
});
|
|
2549
2553
|
content.push({
|
|
2550
2554
|
type: "tool-result",
|
|
2551
2555
|
toolCallId: part.id,
|
|
2552
2556
|
toolName: "web_search_preview",
|
|
2553
|
-
result: {
|
|
2557
|
+
result: {
|
|
2558
|
+
status: part.status || "completed",
|
|
2559
|
+
...((_l = part.action) == null ? void 0 : _l.query) && { query: part.action.query }
|
|
2560
|
+
},
|
|
2554
2561
|
providerExecuted: true
|
|
2555
2562
|
});
|
|
2556
2563
|
break;
|
|
@@ -2608,15 +2615,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2608
2615
|
return {
|
|
2609
2616
|
content,
|
|
2610
2617
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2611
|
-
finishReason: (
|
|
2618
|
+
finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
|
|
2612
2619
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2613
2620
|
}),
|
|
2614
2621
|
usage: {
|
|
2615
2622
|
inputTokens: response.usage.input_tokens,
|
|
2616
2623
|
outputTokens: response.usage.output_tokens,
|
|
2617
2624
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2618
|
-
reasoningTokens: (
|
|
2619
|
-
cachedInputTokens: (
|
|
2625
|
+
reasoningTokens: (_o = (_n = response.usage.output_tokens_details) == null ? void 0 : _n.reasoning_tokens) != null ? _o : void 0,
|
|
2626
|
+
cachedInputTokens: (_q = (_p = response.usage.input_tokens_details) == null ? void 0 : _p.cached_tokens) != null ? _q : void 0
|
|
2620
2627
|
},
|
|
2621
2628
|
request: { body },
|
|
2622
2629
|
response: {
|
|
@@ -2668,7 +2675,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2668
2675
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2669
2676
|
},
|
|
2670
2677
|
transform(chunk, controller) {
|
|
2671
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2678
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2672
2679
|
if (options.includeRawChunks) {
|
|
2673
2680
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2674
2681
|
}
|
|
@@ -2775,7 +2782,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2775
2782
|
type: "tool-call",
|
|
2776
2783
|
toolCallId: value.item.id,
|
|
2777
2784
|
toolName: "web_search_preview",
|
|
2778
|
-
input: "",
|
|
2785
|
+
input: (_c = (_b = value.item.action) == null ? void 0 : _b.query) != null ? _c : "",
|
|
2779
2786
|
providerExecuted: true
|
|
2780
2787
|
});
|
|
2781
2788
|
controller.enqueue({
|
|
@@ -2784,7 +2791,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2784
2791
|
toolName: "web_search_preview",
|
|
2785
2792
|
result: {
|
|
2786
2793
|
type: "web_search_tool_result",
|
|
2787
|
-
status: value.item.status || "completed"
|
|
2794
|
+
status: value.item.status || "completed",
|
|
2795
|
+
...((_d = value.item.action) == null ? void 0 : _d.query) && {
|
|
2796
|
+
query: value.item.action.query
|
|
2797
|
+
}
|
|
2788
2798
|
},
|
|
2789
2799
|
providerExecuted: true
|
|
2790
2800
|
});
|
|
@@ -2852,7 +2862,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2852
2862
|
providerMetadata: {
|
|
2853
2863
|
openai: {
|
|
2854
2864
|
itemId: value.item.id,
|
|
2855
|
-
reasoningEncryptedContent: (
|
|
2865
|
+
reasoningEncryptedContent: (_e = value.item.encrypted_content) != null ? _e : null
|
|
2856
2866
|
}
|
|
2857
2867
|
}
|
|
2858
2868
|
});
|
|
@@ -2887,7 +2897,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2887
2897
|
}
|
|
2888
2898
|
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
2889
2899
|
if (value.summary_index > 0) {
|
|
2890
|
-
(
|
|
2900
|
+
(_f = activeReasoning[value.item_id]) == null ? void 0 : _f.summaryParts.push(
|
|
2891
2901
|
value.summary_index
|
|
2892
2902
|
);
|
|
2893
2903
|
controller.enqueue({
|
|
@@ -2896,7 +2906,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2896
2906
|
providerMetadata: {
|
|
2897
2907
|
openai: {
|
|
2898
2908
|
itemId: value.item_id,
|
|
2899
|
-
reasoningEncryptedContent: (
|
|
2909
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
2900
2910
|
}
|
|
2901
2911
|
}
|
|
2902
2912
|
});
|
|
@@ -2914,20 +2924,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2914
2924
|
});
|
|
2915
2925
|
} else if (isResponseFinishedChunk(value)) {
|
|
2916
2926
|
finishReason = mapOpenAIResponseFinishReason({
|
|
2917
|
-
finishReason: (
|
|
2927
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
2918
2928
|
hasToolCalls
|
|
2919
2929
|
});
|
|
2920
2930
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
2921
2931
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
2922
2932
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
2923
|
-
usage.reasoningTokens = (
|
|
2924
|
-
usage.cachedInputTokens = (
|
|
2933
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
2934
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
2925
2935
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
2926
2936
|
if (value.annotation.type === "url_citation") {
|
|
2927
2937
|
controller.enqueue({
|
|
2928
2938
|
type: "source",
|
|
2929
2939
|
sourceType: "url",
|
|
2930
|
-
id: (
|
|
2940
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
2931
2941
|
url: value.annotation.url,
|
|
2932
2942
|
title: value.annotation.title
|
|
2933
2943
|
});
|
|
@@ -2935,7 +2945,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2935
2945
|
controller.enqueue({
|
|
2936
2946
|
type: "source",
|
|
2937
2947
|
sourceType: "document",
|
|
2938
|
-
id: (
|
|
2948
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId2(),
|
|
2939
2949
|
mediaType: "text/plain",
|
|
2940
2950
|
title: value.annotation.quote,
|
|
2941
2951
|
filename: value.annotation.file_id
|
|
@@ -3025,7 +3035,11 @@ var responseOutputItemAddedSchema = z13.object({
|
|
|
3025
3035
|
z13.object({
|
|
3026
3036
|
type: z13.literal("web_search_call"),
|
|
3027
3037
|
id: z13.string(),
|
|
3028
|
-
status: z13.string()
|
|
3038
|
+
status: z13.string(),
|
|
3039
|
+
action: z13.object({
|
|
3040
|
+
type: z13.literal("search"),
|
|
3041
|
+
query: z13.string().optional()
|
|
3042
|
+
}).nullish()
|
|
3029
3043
|
}),
|
|
3030
3044
|
z13.object({
|
|
3031
3045
|
type: z13.literal("computer_call"),
|
|
@@ -3074,7 +3088,11 @@ var responseOutputItemDoneSchema = z13.object({
|
|
|
3074
3088
|
z13.object({
|
|
3075
3089
|
type: z13.literal("web_search_call"),
|
|
3076
3090
|
id: z13.string(),
|
|
3077
|
-
status: z13.literal("completed")
|
|
3091
|
+
status: z13.literal("completed"),
|
|
3092
|
+
action: z13.object({
|
|
3093
|
+
type: z13.literal("search"),
|
|
3094
|
+
query: z13.string().optional()
|
|
3095
|
+
}).nullish()
|
|
3078
3096
|
}),
|
|
3079
3097
|
z13.object({
|
|
3080
3098
|
type: z13.literal("computer_call"),
|
|
@@ -3182,39 +3200,39 @@ function isErrorChunk(chunk) {
|
|
|
3182
3200
|
return chunk.type === "error";
|
|
3183
3201
|
}
|
|
3184
3202
|
function getResponsesModelConfig(modelId) {
|
|
3203
|
+
const supportsFlexProcessing2 = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
3204
|
+
const supportsPriorityProcessing2 = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
3205
|
+
const defaults = {
|
|
3206
|
+
requiredAutoTruncation: false,
|
|
3207
|
+
systemMessageMode: "system",
|
|
3208
|
+
supportsFlexProcessing: supportsFlexProcessing2,
|
|
3209
|
+
supportsPriorityProcessing: supportsPriorityProcessing2
|
|
3210
|
+
};
|
|
3185
3211
|
if (modelId.startsWith("gpt-5-chat")) {
|
|
3186
3212
|
return {
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
requiredAutoTruncation: false
|
|
3213
|
+
...defaults,
|
|
3214
|
+
isReasoningModel: false
|
|
3190
3215
|
};
|
|
3191
3216
|
}
|
|
3192
3217
|
if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
3193
3218
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
3194
3219
|
return {
|
|
3220
|
+
...defaults,
|
|
3195
3221
|
isReasoningModel: true,
|
|
3196
|
-
systemMessageMode: "remove"
|
|
3197
|
-
requiredAutoTruncation: false
|
|
3222
|
+
systemMessageMode: "remove"
|
|
3198
3223
|
};
|
|
3199
3224
|
}
|
|
3200
3225
|
return {
|
|
3226
|
+
...defaults,
|
|
3201
3227
|
isReasoningModel: true,
|
|
3202
|
-
systemMessageMode: "developer"
|
|
3203
|
-
requiredAutoTruncation: false
|
|
3228
|
+
systemMessageMode: "developer"
|
|
3204
3229
|
};
|
|
3205
3230
|
}
|
|
3206
3231
|
return {
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
requiredAutoTruncation: false
|
|
3232
|
+
...defaults,
|
|
3233
|
+
isReasoningModel: false
|
|
3210
3234
|
};
|
|
3211
3235
|
}
|
|
3212
|
-
function supportsFlexProcessing2(modelId) {
|
|
3213
|
-
return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
3214
|
-
}
|
|
3215
|
-
function supportsPriorityProcessing2(modelId) {
|
|
3216
|
-
return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
3217
|
-
}
|
|
3218
3236
|
var openaiResponsesProviderOptionsSchema = z13.object({
|
|
3219
3237
|
metadata: z13.any().nullish(),
|
|
3220
3238
|
parallelToolCalls: z13.boolean().nullish(),
|