@ai-sdk/openai 4.0.0-beta.13 → 4.0.0-beta.15
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 +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +41 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -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 +40 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +40 -6
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +2 -0
- package/package.json +1 -1
- package/src/chat/openai-chat-options.ts +4 -0
- package/src/openai-language-model-capabilities.ts +2 -2
- package/src/responses/openai-responses-api.ts +25 -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
|
@@ -43,7 +43,7 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
43
43
|
// src/openai-language-model-capabilities.ts
|
|
44
44
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
45
45
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
46
|
-
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5
|
|
46
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
47
47
|
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
48
48
|
const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
|
|
49
49
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
@@ -3400,6 +3400,23 @@ var openaiResponsesChunkSchema = lazySchema19(
|
|
|
3400
3400
|
service_tier: z21.string().nullish()
|
|
3401
3401
|
})
|
|
3402
3402
|
}),
|
|
3403
|
+
z21.object({
|
|
3404
|
+
type: z21.literal("response.failed"),
|
|
3405
|
+
response: z21.object({
|
|
3406
|
+
error: z21.object({
|
|
3407
|
+
code: z21.string().nullish(),
|
|
3408
|
+
message: z21.string()
|
|
3409
|
+
}).nullish(),
|
|
3410
|
+
incomplete_details: z21.object({ reason: z21.string() }).nullish(),
|
|
3411
|
+
usage: z21.object({
|
|
3412
|
+
input_tokens: z21.number(),
|
|
3413
|
+
input_tokens_details: z21.object({ cached_tokens: z21.number().nullish() }).nullish(),
|
|
3414
|
+
output_tokens: z21.number(),
|
|
3415
|
+
output_tokens_details: z21.object({ reasoning_tokens: z21.number().nullish() }).nullish()
|
|
3416
|
+
}).nullish(),
|
|
3417
|
+
service_tier: z21.string().nullish()
|
|
3418
|
+
})
|
|
3419
|
+
}),
|
|
3403
3420
|
z21.object({
|
|
3404
3421
|
type: z21.literal("response.created"),
|
|
3405
3422
|
response: z21.object({
|
|
@@ -4232,6 +4249,10 @@ var openaiResponsesReasoningModelIds = [
|
|
|
4232
4249
|
"gpt-5.3-codex",
|
|
4233
4250
|
"gpt-5.4",
|
|
4234
4251
|
"gpt-5.4-2026-03-05",
|
|
4252
|
+
"gpt-5.4-mini",
|
|
4253
|
+
"gpt-5.4-mini-2026-03-17",
|
|
4254
|
+
"gpt-5.4-nano",
|
|
4255
|
+
"gpt-5.4-nano-2026-03-17",
|
|
4235
4256
|
"gpt-5.4-pro",
|
|
4236
4257
|
"gpt-5.4-pro-2026-03-05"
|
|
4237
4258
|
];
|
|
@@ -5518,7 +5539,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5518
5539
|
controller.enqueue({ type: "stream-start", warnings });
|
|
5519
5540
|
},
|
|
5520
5541
|
transform(chunk, controller) {
|
|
5521
|
-
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;
|
|
5542
|
+
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;
|
|
5522
5543
|
if (options.includeRawChunks) {
|
|
5523
5544
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5524
5545
|
}
|
|
@@ -6255,13 +6276,23 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6255
6276
|
if (typeof value.response.service_tier === "string") {
|
|
6256
6277
|
serviceTier = value.response.service_tier;
|
|
6257
6278
|
}
|
|
6279
|
+
} else if (isResponseFailedChunk(value)) {
|
|
6280
|
+
const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
|
|
6281
|
+
finishReason = {
|
|
6282
|
+
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
6283
|
+
finishReason: incompleteReason,
|
|
6284
|
+
hasFunctionCall
|
|
6285
|
+
}) : "error",
|
|
6286
|
+
raw: incompleteReason != null ? incompleteReason : "error"
|
|
6287
|
+
};
|
|
6288
|
+
usage = (_z = value.response.usage) != null ? _z : void 0;
|
|
6258
6289
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
6259
6290
|
ongoingAnnotations.push(value.annotation);
|
|
6260
6291
|
if (value.annotation.type === "url_citation") {
|
|
6261
6292
|
controller.enqueue({
|
|
6262
6293
|
type: "source",
|
|
6263
6294
|
sourceType: "url",
|
|
6264
|
-
id: (
|
|
6295
|
+
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
|
|
6265
6296
|
url: value.annotation.url,
|
|
6266
6297
|
title: value.annotation.title
|
|
6267
6298
|
});
|
|
@@ -6269,7 +6300,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6269
6300
|
controller.enqueue({
|
|
6270
6301
|
type: "source",
|
|
6271
6302
|
sourceType: "document",
|
|
6272
|
-
id: (
|
|
6303
|
+
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
|
|
6273
6304
|
mediaType: "text/plain",
|
|
6274
6305
|
title: value.annotation.filename,
|
|
6275
6306
|
filename: value.annotation.filename,
|
|
@@ -6285,7 +6316,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6285
6316
|
controller.enqueue({
|
|
6286
6317
|
type: "source",
|
|
6287
6318
|
sourceType: "document",
|
|
6288
|
-
id: (
|
|
6319
|
+
id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
|
|
6289
6320
|
mediaType: "text/plain",
|
|
6290
6321
|
title: value.annotation.filename,
|
|
6291
6322
|
filename: value.annotation.filename,
|
|
@@ -6301,7 +6332,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6301
6332
|
controller.enqueue({
|
|
6302
6333
|
type: "source",
|
|
6303
6334
|
sourceType: "document",
|
|
6304
|
-
id: (
|
|
6335
|
+
id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
|
|
6305
6336
|
mediaType: "application/octet-stream",
|
|
6306
6337
|
title: value.annotation.file_id,
|
|
6307
6338
|
filename: value.annotation.file_id,
|
|
@@ -6349,6 +6380,9 @@ function isResponseOutputItemDoneChunk(chunk) {
|
|
|
6349
6380
|
function isResponseFinishedChunk(chunk) {
|
|
6350
6381
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
6351
6382
|
}
|
|
6383
|
+
function isResponseFailedChunk(chunk) {
|
|
6384
|
+
return chunk.type === "response.failed";
|
|
6385
|
+
}
|
|
6352
6386
|
function isResponseCreatedChunk(chunk) {
|
|
6353
6387
|
return chunk.type === "response.created";
|
|
6354
6388
|
}
|
|
@@ -6775,7 +6809,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6775
6809
|
};
|
|
6776
6810
|
|
|
6777
6811
|
// src/version.ts
|
|
6778
|
-
var VERSION = true ? "4.0.0-beta.
|
|
6812
|
+
var VERSION = true ? "4.0.0-beta.15" : "0.0.0-test";
|
|
6779
6813
|
|
|
6780
6814
|
// src/openai-provider.ts
|
|
6781
6815
|
function createOpenAI(options = {}) {
|