@ai-sdk/openai 3.0.115 → 3.0.117
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 +22 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +5 -5
- package/dist/internal/index.d.ts +5 -5
- package/dist/internal/index.js +22 -15
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -15
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +5 -3
- package/package.json +3 -3
- package/src/chat/openai-chat-api.ts +5 -0
- package/src/chat/openai-chat-language-model.ts +4 -1
- package/src/chat/openai-chat-options.ts +2 -0
- package/src/openai-language-model-capabilities.ts +7 -3
- package/src/openai-stream-error.ts +4 -0
- package/src/responses/openai-responses-api.ts +2 -2
- package/src/responses/openai-responses-language-model.ts +1 -1
- package/src/responses/openai-responses-options.ts +4 -0
package/dist/index.mjs
CHANGED
|
@@ -46,6 +46,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
46
46
|
const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
|
|
47
47
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
48
48
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
49
|
+
const isGpt6SolOrLuna = modelId === "gpt-6-sol" || modelId === "gpt-6-luna";
|
|
49
50
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
50
51
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
51
52
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
@@ -56,7 +57,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
56
57
|
supportsPriorityProcessing,
|
|
57
58
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
58
59
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
59
|
-
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
60
|
+
supportedReasoningEfforts: isGpt6SolOrLuna ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
60
61
|
isReasoningModel,
|
|
61
62
|
systemMessageMode,
|
|
62
63
|
supportsNonReasoningParameters
|
|
@@ -152,7 +153,8 @@ function createOpenAIStreamError({
|
|
|
152
153
|
statusCode: streamError == null ? 500 : getStatusCode(streamError),
|
|
153
154
|
responseHeaders,
|
|
154
155
|
responseBody: JSON.stringify(frame),
|
|
155
|
-
data: frame
|
|
156
|
+
data: frame,
|
|
157
|
+
isRetryable: streamError == null ? true : isRetryableStreamError(streamError, getStatusCode(streamError))
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
function parseStreamError(frame) {
|
|
@@ -571,6 +573,9 @@ var openaiChatResponseSchema = lazySchema(
|
|
|
571
573
|
message: z2.object({
|
|
572
574
|
role: z2.literal("assistant").nullish(),
|
|
573
575
|
content: z2.string().nullish(),
|
|
576
|
+
audio: z2.object({
|
|
577
|
+
transcript: z2.string().nullish()
|
|
578
|
+
}).nullish(),
|
|
574
579
|
tool_calls: z2.array(
|
|
575
580
|
z2.object({
|
|
576
581
|
id: z2.string().nullish(),
|
|
@@ -1115,7 +1120,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1115
1120
|
};
|
|
1116
1121
|
}
|
|
1117
1122
|
async doGenerate(options) {
|
|
1118
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1123
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1119
1124
|
const { args: body, warnings } = await this.getArgs(options);
|
|
1120
1125
|
const {
|
|
1121
1126
|
responseHeaders,
|
|
@@ -1143,19 +1148,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
1143
1148
|
});
|
|
1144
1149
|
}
|
|
1145
1150
|
const content = [];
|
|
1146
|
-
const text = choice.message.content;
|
|
1151
|
+
const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
|
|
1147
1152
|
if (text != null && text.length > 0) {
|
|
1148
1153
|
content.push({ type: "text", text });
|
|
1149
1154
|
}
|
|
1150
|
-
for (const toolCall of (
|
|
1155
|
+
for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
|
|
1151
1156
|
content.push({
|
|
1152
1157
|
type: "tool-call",
|
|
1153
|
-
toolCallId: (
|
|
1158
|
+
toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
|
|
1154
1159
|
toolName: toolCall.function.name,
|
|
1155
1160
|
input: toolCall.function.arguments
|
|
1156
1161
|
});
|
|
1157
1162
|
}
|
|
1158
|
-
for (const annotation of (
|
|
1163
|
+
for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
|
|
1159
1164
|
content.push({
|
|
1160
1165
|
type: "source",
|
|
1161
1166
|
sourceType: "url",
|
|
@@ -1164,8 +1169,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
1164
1169
|
title: annotation.url_citation.title
|
|
1165
1170
|
});
|
|
1166
1171
|
}
|
|
1167
|
-
const completionTokenDetails = (
|
|
1168
|
-
const promptTokenDetails = (
|
|
1172
|
+
const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
|
|
1173
|
+
const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
|
|
1169
1174
|
const providerMetadata = { openai: {} };
|
|
1170
1175
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
1171
1176
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -1173,14 +1178,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1173
1178
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
1174
1179
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
1175
1180
|
}
|
|
1176
|
-
if (((
|
|
1181
|
+
if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
|
|
1177
1182
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
1178
1183
|
}
|
|
1179
1184
|
return {
|
|
1180
1185
|
content,
|
|
1181
1186
|
finishReason: {
|
|
1182
1187
|
unified: mapOpenAIFinishReason(choice.finish_reason),
|
|
1183
|
-
raw: (
|
|
1188
|
+
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
1184
1189
|
},
|
|
1185
1190
|
usage: convertOpenAIChatUsage(response.usage),
|
|
1186
1191
|
request: { body },
|
|
@@ -4530,7 +4535,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
4530
4535
|
name: z22.string(),
|
|
4531
4536
|
arguments: z22.string(),
|
|
4532
4537
|
async: z22.boolean().nullish(),
|
|
4533
|
-
status: z22.
|
|
4538
|
+
status: z22.enum(["in_progress", "completed", "incomplete"]),
|
|
4534
4539
|
namespace: z22.string().nullish()
|
|
4535
4540
|
}),
|
|
4536
4541
|
z22.object({
|
|
@@ -4540,7 +4545,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
4540
4545
|
name: z22.string(),
|
|
4541
4546
|
input: z22.string(),
|
|
4542
4547
|
async: z22.boolean().nullish(),
|
|
4543
|
-
status: z22.
|
|
4548
|
+
status: z22.enum(["in_progress", "completed", "incomplete"])
|
|
4544
4549
|
}),
|
|
4545
4550
|
z22.object({
|
|
4546
4551
|
type: z22.literal("code_interpreter_call"),
|
|
@@ -5175,7 +5180,9 @@ var openaiResponsesReasoningModelIds = [
|
|
|
5175
5180
|
"gpt-5.6-luna",
|
|
5176
5181
|
"gpt-5.6-sol",
|
|
5177
5182
|
"gpt-5.6-terra",
|
|
5178
|
-
"gpt-6-astra"
|
|
5183
|
+
"gpt-6-astra",
|
|
5184
|
+
"gpt-6-luna",
|
|
5185
|
+
"gpt-6-sol"
|
|
5179
5186
|
];
|
|
5180
5187
|
var openaiResponsesModelIds = [
|
|
5181
5188
|
"gpt-4.1",
|
|
@@ -6993,7 +7000,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6993
7000
|
};
|
|
6994
7001
|
} else if (value.item.type === "shell_call_output") {
|
|
6995
7002
|
} else if (value.item.type === "message") {
|
|
6996
|
-
ongoingAnnotations.splice(0
|
|
7003
|
+
ongoingAnnotations.splice(0);
|
|
6997
7004
|
activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
|
|
6998
7005
|
controller.enqueue({
|
|
6999
7006
|
type: "text-start",
|
|
@@ -8253,7 +8260,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8253
8260
|
};
|
|
8254
8261
|
|
|
8255
8262
|
// src/version.ts
|
|
8256
|
-
var VERSION = true ? "3.0.
|
|
8263
|
+
var VERSION = true ? "3.0.117" : "0.0.0-test";
|
|
8257
8264
|
|
|
8258
8265
|
// src/openai-provider.ts
|
|
8259
8266
|
function createOpenAI(options = {}) {
|