@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/internal/index.mjs
CHANGED
|
@@ -38,6 +38,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
38
38
|
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);
|
|
39
39
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
40
40
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
41
|
+
const isGpt6SolOrLuna = modelId === "gpt-6-sol" || modelId === "gpt-6-luna";
|
|
41
42
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
42
43
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
43
44
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
@@ -48,7 +49,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
48
49
|
supportsPriorityProcessing,
|
|
49
50
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
50
51
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
51
|
-
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
52
|
+
supportedReasoningEfforts: isGpt6SolOrLuna ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
52
53
|
isReasoningModel,
|
|
53
54
|
systemMessageMode,
|
|
54
55
|
supportsNonReasoningParameters
|
|
@@ -144,7 +145,8 @@ function createOpenAIStreamError({
|
|
|
144
145
|
statusCode: streamError == null ? 500 : getStatusCode(streamError),
|
|
145
146
|
responseHeaders,
|
|
146
147
|
responseBody: JSON.stringify(frame),
|
|
147
|
-
data: frame
|
|
148
|
+
data: frame,
|
|
149
|
+
isRetryable: streamError == null ? true : isRetryableStreamError(streamError, getStatusCode(streamError))
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
function parseStreamError(frame) {
|
|
@@ -563,6 +565,9 @@ var openaiChatResponseSchema = lazySchema(
|
|
|
563
565
|
message: z2.object({
|
|
564
566
|
role: z2.literal("assistant").nullish(),
|
|
565
567
|
content: z2.string().nullish(),
|
|
568
|
+
audio: z2.object({
|
|
569
|
+
transcript: z2.string().nullish()
|
|
570
|
+
}).nullish(),
|
|
566
571
|
tool_calls: z2.array(
|
|
567
572
|
z2.object({
|
|
568
573
|
id: z2.string().nullish(),
|
|
@@ -1107,7 +1112,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1107
1112
|
};
|
|
1108
1113
|
}
|
|
1109
1114
|
async doGenerate(options) {
|
|
1110
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1115
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1111
1116
|
const { args: body, warnings } = await this.getArgs(options);
|
|
1112
1117
|
const {
|
|
1113
1118
|
responseHeaders,
|
|
@@ -1135,19 +1140,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
1135
1140
|
});
|
|
1136
1141
|
}
|
|
1137
1142
|
const content = [];
|
|
1138
|
-
const text = choice.message.content;
|
|
1143
|
+
const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
|
|
1139
1144
|
if (text != null && text.length > 0) {
|
|
1140
1145
|
content.push({ type: "text", text });
|
|
1141
1146
|
}
|
|
1142
|
-
for (const toolCall of (
|
|
1147
|
+
for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
|
|
1143
1148
|
content.push({
|
|
1144
1149
|
type: "tool-call",
|
|
1145
|
-
toolCallId: (
|
|
1150
|
+
toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
|
|
1146
1151
|
toolName: toolCall.function.name,
|
|
1147
1152
|
input: toolCall.function.arguments
|
|
1148
1153
|
});
|
|
1149
1154
|
}
|
|
1150
|
-
for (const annotation of (
|
|
1155
|
+
for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
|
|
1151
1156
|
content.push({
|
|
1152
1157
|
type: "source",
|
|
1153
1158
|
sourceType: "url",
|
|
@@ -1156,8 +1161,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
1156
1161
|
title: annotation.url_citation.title
|
|
1157
1162
|
});
|
|
1158
1163
|
}
|
|
1159
|
-
const completionTokenDetails = (
|
|
1160
|
-
const promptTokenDetails = (
|
|
1164
|
+
const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
|
|
1165
|
+
const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
|
|
1161
1166
|
const providerMetadata = { openai: {} };
|
|
1162
1167
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
1163
1168
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -1165,14 +1170,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1165
1170
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
1166
1171
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
1167
1172
|
}
|
|
1168
|
-
if (((
|
|
1173
|
+
if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
|
|
1169
1174
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
1170
1175
|
}
|
|
1171
1176
|
return {
|
|
1172
1177
|
content,
|
|
1173
1178
|
finishReason: {
|
|
1174
1179
|
unified: mapOpenAIFinishReason(choice.finish_reason),
|
|
1175
|
-
raw: (
|
|
1180
|
+
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
1176
1181
|
},
|
|
1177
1182
|
usage: convertOpenAIChatUsage(response.usage),
|
|
1178
1183
|
request: { body },
|
|
@@ -4419,7 +4424,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
4419
4424
|
name: z18.string(),
|
|
4420
4425
|
arguments: z18.string(),
|
|
4421
4426
|
async: z18.boolean().nullish(),
|
|
4422
|
-
status: z18.
|
|
4427
|
+
status: z18.enum(["in_progress", "completed", "incomplete"]),
|
|
4423
4428
|
namespace: z18.string().nullish()
|
|
4424
4429
|
}),
|
|
4425
4430
|
z18.object({
|
|
@@ -4429,7 +4434,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
4429
4434
|
name: z18.string(),
|
|
4430
4435
|
input: z18.string(),
|
|
4431
4436
|
async: z18.boolean().nullish(),
|
|
4432
|
-
status: z18.
|
|
4437
|
+
status: z18.enum(["in_progress", "completed", "incomplete"])
|
|
4433
4438
|
}),
|
|
4434
4439
|
z18.object({
|
|
4435
4440
|
type: z18.literal("code_interpreter_call"),
|
|
@@ -5064,7 +5069,9 @@ var openaiResponsesReasoningModelIds = [
|
|
|
5064
5069
|
"gpt-5.6-luna",
|
|
5065
5070
|
"gpt-5.6-sol",
|
|
5066
5071
|
"gpt-5.6-terra",
|
|
5067
|
-
"gpt-6-astra"
|
|
5072
|
+
"gpt-6-astra",
|
|
5073
|
+
"gpt-6-luna",
|
|
5074
|
+
"gpt-6-sol"
|
|
5068
5075
|
];
|
|
5069
5076
|
var openaiResponsesModelIds = [
|
|
5070
5077
|
"gpt-4.1",
|
|
@@ -7235,7 +7242,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7235
7242
|
};
|
|
7236
7243
|
} else if (value.item.type === "shell_call_output") {
|
|
7237
7244
|
} else if (value.item.type === "message") {
|
|
7238
|
-
ongoingAnnotations.splice(0
|
|
7245
|
+
ongoingAnnotations.splice(0);
|
|
7239
7246
|
activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
|
|
7240
7247
|
controller.enqueue({
|
|
7241
7248
|
type: "text-start",
|