@ai-sdk/openai 3.0.107 → 3.0.109
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 +12 -0
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +89 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +8 -8
- package/dist/internal/index.d.ts +8 -8
- package/dist/internal/index.js +88 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +88 -9
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +68 -1
- package/package.json +1 -1
- package/src/chat/openai-chat-language-model.ts +31 -1
- package/src/chat/openai-chat-options.ts +2 -0
- package/src/openai-language-model-capabilities.ts +8 -0
- package/src/responses/openai-responses-api.ts +9 -1
- package/src/responses/openai-responses-language-model.ts +75 -3
- package/src/responses/openai-responses-options.ts +15 -0
package/dist/internal/index.mjs
CHANGED
|
@@ -37,14 +37,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
37
37
|
const gptVersion = getGptVersion(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
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
40
41
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
41
42
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
42
43
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
43
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
44
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
44
45
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
45
46
|
return {
|
|
46
47
|
supportsFlexProcessing,
|
|
47
48
|
supportsPriorityProcessing,
|
|
49
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
50
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
48
51
|
isReasoningModel,
|
|
49
52
|
systemMessageMode,
|
|
50
53
|
supportsNonReasoningParameters
|
|
@@ -726,6 +729,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
726
729
|
user: z3.string().optional(),
|
|
727
730
|
/**
|
|
728
731
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
732
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
729
733
|
*/
|
|
730
734
|
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
731
735
|
/**
|
|
@@ -924,6 +928,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
924
928
|
})) != null ? _a2 : {};
|
|
925
929
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
926
930
|
const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
931
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
932
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
933
|
+
resolvedReasoningEffort
|
|
934
|
+
)) {
|
|
935
|
+
warnings.push({
|
|
936
|
+
type: "unsupported",
|
|
937
|
+
feature: "reasoningEffort",
|
|
938
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
939
|
+
});
|
|
940
|
+
resolvedReasoningEffort = void 0;
|
|
941
|
+
}
|
|
927
942
|
if (topK != null) {
|
|
928
943
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
929
944
|
}
|
|
@@ -968,7 +983,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
968
983
|
store: openaiOptions.store,
|
|
969
984
|
metadata: openaiOptions.metadata,
|
|
970
985
|
prediction: openaiOptions.prediction,
|
|
971
|
-
reasoning_effort:
|
|
986
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
972
987
|
service_tier: openaiOptions.serviceTier,
|
|
973
988
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
974
989
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -977,6 +992,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
977
992
|
// messages:
|
|
978
993
|
messages
|
|
979
994
|
};
|
|
995
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
996
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
997
|
+
warnings.push({
|
|
998
|
+
type: "unsupported",
|
|
999
|
+
feature: "promptCacheRetention",
|
|
1000
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
980
1003
|
if (isReasoningModel) {
|
|
981
1004
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
982
1005
|
if (baseArgs.temperature != null) {
|
|
@@ -4995,7 +5018,8 @@ var openaiResponsesReasoningModelIds = [
|
|
|
4995
5018
|
"gpt-5.6",
|
|
4996
5019
|
"gpt-5.6-luna",
|
|
4997
5020
|
"gpt-5.6-sol",
|
|
4998
|
-
"gpt-5.6-terra"
|
|
5021
|
+
"gpt-5.6-terra",
|
|
5022
|
+
"gpt-6-astra"
|
|
4999
5023
|
];
|
|
5000
5024
|
var openaiResponsesModelIds = [
|
|
5001
5025
|
"gpt-4.1",
|
|
@@ -5114,9 +5138,19 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
|
|
|
5114
5138
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5115
5139
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5116
5140
|
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5141
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5117
5142
|
* Supported values vary by model.
|
|
5118
5143
|
*/
|
|
5119
5144
|
reasoningEffort: z19.string().nullish(),
|
|
5145
|
+
/**
|
|
5146
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
5147
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
5148
|
+
* request prefix for prompt caching.
|
|
5149
|
+
*
|
|
5150
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
5151
|
+
* combined with automatic truncation.
|
|
5152
|
+
*/
|
|
5153
|
+
reasoningEffortUpdate: z19.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5120
5154
|
/**
|
|
5121
5155
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5122
5156
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -6068,7 +6102,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6068
6102
|
toolChoice,
|
|
6069
6103
|
responseFormat
|
|
6070
6104
|
}) {
|
|
6071
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6105
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
6072
6106
|
const warnings = [];
|
|
6073
6107
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
6074
6108
|
if (topK != null) {
|
|
@@ -6100,6 +6134,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6100
6134
|
});
|
|
6101
6135
|
}
|
|
6102
6136
|
const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
|
|
6137
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
6138
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
6139
|
+
resolvedReasoningEffort
|
|
6140
|
+
)) {
|
|
6141
|
+
warnings.push({
|
|
6142
|
+
type: "unsupported",
|
|
6143
|
+
feature: "reasoningEffort",
|
|
6144
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
6145
|
+
});
|
|
6146
|
+
resolvedReasoningEffort = void 0;
|
|
6147
|
+
}
|
|
6103
6148
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
6104
6149
|
warnings.push({
|
|
6105
6150
|
type: "unsupported",
|
|
@@ -6152,6 +6197,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6152
6197
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
6153
6198
|
});
|
|
6154
6199
|
warnings.push(...inputWarnings);
|
|
6200
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
6201
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
6202
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
6203
|
+
warnings.push({
|
|
6204
|
+
type: "unsupported",
|
|
6205
|
+
feature: "reasoningEffortUpdate",
|
|
6206
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
6207
|
+
});
|
|
6208
|
+
} else if (reasoningEffortUpdate != null) {
|
|
6209
|
+
input.unshift({
|
|
6210
|
+
type: "configuration_update",
|
|
6211
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
6212
|
+
});
|
|
6213
|
+
}
|
|
6155
6214
|
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
6156
6215
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
6157
6216
|
function addInclude(key) {
|
|
@@ -6225,10 +6284,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6225
6284
|
top_logprobs: topLogprobs,
|
|
6226
6285
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
6227
6286
|
// model-specific settings:
|
|
6228
|
-
...isReasoningModel && (
|
|
6287
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
6229
6288
|
reasoning: {
|
|
6230
|
-
...
|
|
6231
|
-
effort:
|
|
6289
|
+
...resolvedReasoningEffort != null && {
|
|
6290
|
+
effort: resolvedReasoningEffort
|
|
6232
6291
|
},
|
|
6233
6292
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
6234
6293
|
summary: openaiOptions.reasoningSummary
|
|
@@ -6242,6 +6301,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6242
6301
|
}
|
|
6243
6302
|
}
|
|
6244
6303
|
};
|
|
6304
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
6305
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
6306
|
+
warnings.push({
|
|
6307
|
+
type: "unsupported",
|
|
6308
|
+
feature: "promptCacheRetention",
|
|
6309
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
6310
|
+
});
|
|
6311
|
+
}
|
|
6245
6312
|
if (isReasoningModel) {
|
|
6246
6313
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
6247
6314
|
if (baseArgs.temperature != null) {
|
|
@@ -6261,6 +6328,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6261
6328
|
});
|
|
6262
6329
|
}
|
|
6263
6330
|
}
|
|
6331
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
|
|
6332
|
+
baseArgs.top_logprobs = void 0;
|
|
6333
|
+
const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
|
|
6334
|
+
(value) => value !== "message.output_text.logprobs"
|
|
6335
|
+
);
|
|
6336
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
6337
|
+
warnings.push({
|
|
6338
|
+
type: "unsupported",
|
|
6339
|
+
feature: "logprobs",
|
|
6340
|
+
details: "logprobs is not supported for reasoning models"
|
|
6341
|
+
});
|
|
6342
|
+
}
|
|
6264
6343
|
} else {
|
|
6265
6344
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
6266
6345
|
warnings.push({
|
|
@@ -6307,9 +6386,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6307
6386
|
});
|
|
6308
6387
|
delete baseArgs.service_tier;
|
|
6309
6388
|
}
|
|
6310
|
-
const shellToolEnvType = (
|
|
6389
|
+
const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
|
|
6311
6390
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
6312
|
-
)) == null ? void 0 :
|
|
6391
|
+
)) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
|
|
6313
6392
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
6314
6393
|
return {
|
|
6315
6394
|
webSearchToolName,
|