@ai-sdk/openai 2.0.123 → 2.0.125
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 +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +85 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +7 -7
- package/dist/internal/index.d.ts +7 -7
- package/dist/internal/index.js +84 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +84 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.mjs
CHANGED
|
@@ -38,14 +38,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
38
38
|
const gptVersion = getGptVersion(modelId);
|
|
39
39
|
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);
|
|
40
40
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
41
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
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 || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
|
|
44
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
45
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
45
46
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
46
47
|
return {
|
|
47
48
|
supportsFlexProcessing,
|
|
48
49
|
supportsPriorityProcessing,
|
|
50
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
51
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
49
52
|
isReasoningModel,
|
|
50
53
|
systemMessageMode,
|
|
51
54
|
supportsNonReasoningParameters
|
|
@@ -740,6 +743,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
740
743
|
);
|
|
741
744
|
warnings.push(...messageWarnings);
|
|
742
745
|
const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
|
|
746
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
747
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
748
|
+
resolvedReasoningEffort
|
|
749
|
+
)) {
|
|
750
|
+
warnings.push({
|
|
751
|
+
type: "unsupported-setting",
|
|
752
|
+
setting: "reasoningEffort",
|
|
753
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
754
|
+
});
|
|
755
|
+
resolvedReasoningEffort = void 0;
|
|
756
|
+
}
|
|
743
757
|
const baseArgs = {
|
|
744
758
|
// model id:
|
|
745
759
|
model: this.modelId,
|
|
@@ -773,7 +787,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
773
787
|
store: openaiOptions.store,
|
|
774
788
|
metadata: openaiOptions.metadata,
|
|
775
789
|
prediction: openaiOptions.prediction,
|
|
776
|
-
reasoning_effort:
|
|
790
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
777
791
|
service_tier: openaiOptions.serviceTier,
|
|
778
792
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
779
793
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -782,6 +796,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
782
796
|
// messages:
|
|
783
797
|
messages
|
|
784
798
|
};
|
|
799
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
800
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
801
|
+
warnings.push({
|
|
802
|
+
type: "unsupported-setting",
|
|
803
|
+
setting: "promptCacheRetention",
|
|
804
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
805
|
+
});
|
|
806
|
+
}
|
|
785
807
|
if (modelCapabilities.isReasoningModel) {
|
|
786
808
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
787
809
|
if (baseArgs.temperature != null) {
|
|
@@ -3353,7 +3375,8 @@ var openaiResponsesReasoningModelIds = [
|
|
|
3353
3375
|
"gpt-5.6",
|
|
3354
3376
|
"gpt-5.6-luna",
|
|
3355
3377
|
"gpt-5.6-sol",
|
|
3356
|
-
"gpt-5.6-terra"
|
|
3378
|
+
"gpt-5.6-terra",
|
|
3379
|
+
"gpt-6-astra"
|
|
3357
3380
|
];
|
|
3358
3381
|
var openaiResponsesModelIds = [
|
|
3359
3382
|
"gpt-4.1",
|
|
@@ -3454,6 +3477,15 @@ var openaiResponsesProviderOptionsSchema = lazyValidator13(
|
|
|
3454
3477
|
* Supported values vary by model.
|
|
3455
3478
|
*/
|
|
3456
3479
|
reasoningEffort: z16.string().nullish(),
|
|
3480
|
+
/**
|
|
3481
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
3482
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
3483
|
+
* request prefix for prompt caching.
|
|
3484
|
+
*
|
|
3485
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
3486
|
+
* combined with automatic truncation.
|
|
3487
|
+
*/
|
|
3488
|
+
reasoningEffortUpdate: z16.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
3457
3489
|
/**
|
|
3458
3490
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
3459
3491
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -3911,7 +3943,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3911
3943
|
toolChoice,
|
|
3912
3944
|
responseFormat
|
|
3913
3945
|
}) {
|
|
3914
|
-
var _a2, _b, _c, _d;
|
|
3946
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3915
3947
|
const warnings = [];
|
|
3916
3948
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
3917
3949
|
if (topK != null) {
|
|
@@ -3955,6 +3987,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3955
3987
|
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
3956
3988
|
});
|
|
3957
3989
|
warnings.push(...inputWarnings);
|
|
3990
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
3991
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
3992
|
+
resolvedReasoningEffort
|
|
3993
|
+
)) {
|
|
3994
|
+
warnings.push({
|
|
3995
|
+
type: "unsupported-setting",
|
|
3996
|
+
setting: "reasoningEffort",
|
|
3997
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
3998
|
+
});
|
|
3999
|
+
resolvedReasoningEffort = void 0;
|
|
4000
|
+
}
|
|
4001
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
4002
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
4003
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
4004
|
+
warnings.push({
|
|
4005
|
+
type: "unsupported-setting",
|
|
4006
|
+
setting: "reasoningEffortUpdate",
|
|
4007
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
4008
|
+
});
|
|
4009
|
+
} else if (reasoningEffortUpdate != null) {
|
|
4010
|
+
input.unshift({
|
|
4011
|
+
type: "configuration_update",
|
|
4012
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
3958
4015
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
3959
4016
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
3960
4017
|
function addInclude(key) {
|
|
@@ -4026,10 +4083,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4026
4083
|
top_logprobs: topLogprobs,
|
|
4027
4084
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
4028
4085
|
// model-specific settings:
|
|
4029
|
-
...modelCapabilities.isReasoningModel && (
|
|
4086
|
+
...modelCapabilities.isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
4030
4087
|
reasoning: {
|
|
4031
|
-
...
|
|
4032
|
-
effort:
|
|
4088
|
+
...resolvedReasoningEffort != null && {
|
|
4089
|
+
effort: resolvedReasoningEffort
|
|
4033
4090
|
},
|
|
4034
4091
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
4035
4092
|
summary: openaiOptions.reasoningSummary
|
|
@@ -4043,6 +4100,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4043
4100
|
}
|
|
4044
4101
|
}
|
|
4045
4102
|
};
|
|
4103
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
4104
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
4105
|
+
warnings.push({
|
|
4106
|
+
type: "unsupported-setting",
|
|
4107
|
+
setting: "promptCacheRetention",
|
|
4108
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4046
4111
|
if (modelCapabilities.isReasoningModel) {
|
|
4047
4112
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
4048
4113
|
if (baseArgs.temperature != null) {
|
|
@@ -4061,6 +4126,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4061
4126
|
details: "topP is not supported for reasoning models"
|
|
4062
4127
|
});
|
|
4063
4128
|
}
|
|
4129
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_e = baseArgs.include) == null ? void 0 : _e.includes("message.output_text.logprobs")))) {
|
|
4130
|
+
baseArgs.top_logprobs = void 0;
|
|
4131
|
+
const filteredInclude = (_f = baseArgs.include) == null ? void 0 : _f.filter(
|
|
4132
|
+
(value) => value !== "message.output_text.logprobs"
|
|
4133
|
+
);
|
|
4134
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
4135
|
+
warnings.push({
|
|
4136
|
+
type: "unsupported-setting",
|
|
4137
|
+
setting: "logprobs",
|
|
4138
|
+
details: "logprobs is not supported for reasoning models"
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4064
4141
|
}
|
|
4065
4142
|
} else {
|
|
4066
4143
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|