@ai-sdk/openai 3.0.47 → 3.0.49
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 +37 -22
- package/dist/index.d.mts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +52 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +24 -2
- package/dist/internal/index.d.ts +24 -2
- package/dist/internal/index.js +51 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +51 -6
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +2 -0
- package/package.json +3 -5
- package/src/chat/openai-chat-options.ts +4 -0
- package/src/openai-language-model-capabilities.ts +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +12 -0
- package/src/responses/openai-responses-api.ts +26 -0
- package/src/responses/openai-responses-language-model.ts +19 -0
- package/src/responses/openai-responses-options.ts +8 -0
package/dist/index.mjs
CHANGED
|
@@ -42,7 +42,7 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
42
42
|
// src/openai-language-model-capabilities.ts
|
|
43
43
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
44
44
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
45
|
-
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5
|
|
45
|
+
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");
|
|
46
46
|
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
47
47
|
const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
|
|
48
48
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
@@ -3211,6 +3211,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
3211
3211
|
filename: (_a2 = item.filename) != null ? _a2 : "data",
|
|
3212
3212
|
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
3213
3213
|
};
|
|
3214
|
+
case "file-url":
|
|
3215
|
+
return {
|
|
3216
|
+
type: "input_file",
|
|
3217
|
+
file_url: item.url
|
|
3218
|
+
};
|
|
3214
3219
|
default:
|
|
3215
3220
|
warnings.push({
|
|
3216
3221
|
type: "other",
|
|
@@ -3269,6 +3274,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
3269
3274
|
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
3270
3275
|
};
|
|
3271
3276
|
}
|
|
3277
|
+
case "file-url": {
|
|
3278
|
+
return {
|
|
3279
|
+
type: "input_file",
|
|
3280
|
+
file_url: item.url
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3272
3283
|
default: {
|
|
3273
3284
|
warnings.push({
|
|
3274
3285
|
type: "other",
|
|
@@ -3376,6 +3387,23 @@ var openaiResponsesChunkSchema = lazySchema19(
|
|
|
3376
3387
|
service_tier: z21.string().nullish()
|
|
3377
3388
|
})
|
|
3378
3389
|
}),
|
|
3390
|
+
z21.object({
|
|
3391
|
+
type: z21.literal("response.failed"),
|
|
3392
|
+
response: z21.object({
|
|
3393
|
+
error: z21.object({
|
|
3394
|
+
code: z21.string().nullish(),
|
|
3395
|
+
message: z21.string()
|
|
3396
|
+
}).nullish(),
|
|
3397
|
+
incomplete_details: z21.object({ reason: z21.string() }).nullish(),
|
|
3398
|
+
usage: z21.object({
|
|
3399
|
+
input_tokens: z21.number(),
|
|
3400
|
+
input_tokens_details: z21.object({ cached_tokens: z21.number().nullish() }).nullish(),
|
|
3401
|
+
output_tokens: z21.number(),
|
|
3402
|
+
output_tokens_details: z21.object({ reasoning_tokens: z21.number().nullish() }).nullish()
|
|
3403
|
+
}).nullish(),
|
|
3404
|
+
service_tier: z21.string().nullish()
|
|
3405
|
+
})
|
|
3406
|
+
}),
|
|
3379
3407
|
z21.object({
|
|
3380
3408
|
type: z21.literal("response.created"),
|
|
3381
3409
|
response: z21.object({
|
|
@@ -4193,6 +4221,10 @@ var openaiResponsesReasoningModelIds = [
|
|
|
4193
4221
|
"gpt-5.3-codex",
|
|
4194
4222
|
"gpt-5.4",
|
|
4195
4223
|
"gpt-5.4-2026-03-05",
|
|
4224
|
+
"gpt-5.4-mini",
|
|
4225
|
+
"gpt-5.4-mini-2026-03-17",
|
|
4226
|
+
"gpt-5.4-nano",
|
|
4227
|
+
"gpt-5.4-nano-2026-03-17",
|
|
4196
4228
|
"gpt-5.4-pro",
|
|
4197
4229
|
"gpt-5.4-pro-2026-03-05"
|
|
4198
4230
|
];
|
|
@@ -5448,7 +5480,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5448
5480
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5449
5481
|
},
|
|
5450
5482
|
transform(chunk, controller) {
|
|
5451
|
-
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;
|
|
5483
|
+
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;
|
|
5452
5484
|
if (options.includeRawChunks) {
|
|
5453
5485
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5454
5486
|
}
|
|
@@ -6173,13 +6205,23 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6173
6205
|
if (typeof value.response.service_tier === "string") {
|
|
6174
6206
|
serviceTier = value.response.service_tier;
|
|
6175
6207
|
}
|
|
6208
|
+
} else if (isResponseFailedChunk(value)) {
|
|
6209
|
+
const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
|
|
6210
|
+
finishReason = {
|
|
6211
|
+
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
6212
|
+
finishReason: incompleteReason,
|
|
6213
|
+
hasFunctionCall
|
|
6214
|
+
}) : "error",
|
|
6215
|
+
raw: incompleteReason != null ? incompleteReason : "error"
|
|
6216
|
+
};
|
|
6217
|
+
usage = (_z = value.response.usage) != null ? _z : void 0;
|
|
6176
6218
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
6177
6219
|
ongoingAnnotations.push(value.annotation);
|
|
6178
6220
|
if (value.annotation.type === "url_citation") {
|
|
6179
6221
|
controller.enqueue({
|
|
6180
6222
|
type: "source",
|
|
6181
6223
|
sourceType: "url",
|
|
6182
|
-
id: (
|
|
6224
|
+
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
|
|
6183
6225
|
url: value.annotation.url,
|
|
6184
6226
|
title: value.annotation.title
|
|
6185
6227
|
});
|
|
@@ -6187,7 +6229,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6187
6229
|
controller.enqueue({
|
|
6188
6230
|
type: "source",
|
|
6189
6231
|
sourceType: "document",
|
|
6190
|
-
id: (
|
|
6232
|
+
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
|
|
6191
6233
|
mediaType: "text/plain",
|
|
6192
6234
|
title: value.annotation.filename,
|
|
6193
6235
|
filename: value.annotation.filename,
|
|
@@ -6203,7 +6245,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6203
6245
|
controller.enqueue({
|
|
6204
6246
|
type: "source",
|
|
6205
6247
|
sourceType: "document",
|
|
6206
|
-
id: (
|
|
6248
|
+
id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
|
|
6207
6249
|
mediaType: "text/plain",
|
|
6208
6250
|
title: value.annotation.filename,
|
|
6209
6251
|
filename: value.annotation.filename,
|
|
@@ -6219,7 +6261,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6219
6261
|
controller.enqueue({
|
|
6220
6262
|
type: "source",
|
|
6221
6263
|
sourceType: "document",
|
|
6222
|
-
id: (
|
|
6264
|
+
id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
|
|
6223
6265
|
mediaType: "application/octet-stream",
|
|
6224
6266
|
title: value.annotation.file_id,
|
|
6225
6267
|
filename: value.annotation.file_id,
|
|
@@ -6267,6 +6309,9 @@ function isResponseOutputItemDoneChunk(chunk) {
|
|
|
6267
6309
|
function isResponseFinishedChunk(chunk) {
|
|
6268
6310
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
6269
6311
|
}
|
|
6312
|
+
function isResponseFailedChunk(chunk) {
|
|
6313
|
+
return chunk.type === "response.failed";
|
|
6314
|
+
}
|
|
6270
6315
|
function isResponseCreatedChunk(chunk) {
|
|
6271
6316
|
return chunk.type === "response.created";
|
|
6272
6317
|
}
|
|
@@ -6693,7 +6738,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6693
6738
|
};
|
|
6694
6739
|
|
|
6695
6740
|
// src/version.ts
|
|
6696
|
-
var VERSION = true ? "3.0.
|
|
6741
|
+
var VERSION = true ? "3.0.49" : "0.0.0-test";
|
|
6697
6742
|
|
|
6698
6743
|
// src/openai-provider.ts
|
|
6699
6744
|
function createOpenAI(options = {}) {
|