@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/index.mjs
CHANGED
|
@@ -46,14 +46,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
46
46
|
const gptVersion = getGptVersion(modelId);
|
|
47
47
|
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);
|
|
48
48
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
49
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
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 || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
|
|
52
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
53
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
53
54
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
54
55
|
return {
|
|
55
56
|
supportsFlexProcessing,
|
|
56
57
|
supportsPriorityProcessing,
|
|
58
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
59
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
57
60
|
isReasoningModel,
|
|
58
61
|
systemMessageMode,
|
|
59
62
|
supportsNonReasoningParameters
|
|
@@ -748,6 +751,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
748
751
|
);
|
|
749
752
|
warnings.push(...messageWarnings);
|
|
750
753
|
const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
|
|
754
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
755
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
756
|
+
resolvedReasoningEffort
|
|
757
|
+
)) {
|
|
758
|
+
warnings.push({
|
|
759
|
+
type: "unsupported-setting",
|
|
760
|
+
setting: "reasoningEffort",
|
|
761
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
762
|
+
});
|
|
763
|
+
resolvedReasoningEffort = void 0;
|
|
764
|
+
}
|
|
751
765
|
const baseArgs = {
|
|
752
766
|
// model id:
|
|
753
767
|
model: this.modelId,
|
|
@@ -781,7 +795,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
781
795
|
store: openaiOptions.store,
|
|
782
796
|
metadata: openaiOptions.metadata,
|
|
783
797
|
prediction: openaiOptions.prediction,
|
|
784
|
-
reasoning_effort:
|
|
798
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
785
799
|
service_tier: openaiOptions.serviceTier,
|
|
786
800
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
787
801
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -790,6 +804,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
790
804
|
// messages:
|
|
791
805
|
messages
|
|
792
806
|
};
|
|
807
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
808
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
809
|
+
warnings.push({
|
|
810
|
+
type: "unsupported-setting",
|
|
811
|
+
setting: "promptCacheRetention",
|
|
812
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
813
|
+
});
|
|
814
|
+
}
|
|
793
815
|
if (modelCapabilities.isReasoningModel) {
|
|
794
816
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
795
817
|
if (baseArgs.temperature != null) {
|
|
@@ -3319,7 +3341,8 @@ var openaiResponsesReasoningModelIds = [
|
|
|
3319
3341
|
"gpt-5.6",
|
|
3320
3342
|
"gpt-5.6-luna",
|
|
3321
3343
|
"gpt-5.6-sol",
|
|
3322
|
-
"gpt-5.6-terra"
|
|
3344
|
+
"gpt-5.6-terra",
|
|
3345
|
+
"gpt-6-astra"
|
|
3323
3346
|
];
|
|
3324
3347
|
var openaiResponsesModelIds = [
|
|
3325
3348
|
"gpt-4.1",
|
|
@@ -3420,6 +3443,15 @@ var openaiResponsesProviderOptionsSchema = lazyValidator10(
|
|
|
3420
3443
|
* Supported values vary by model.
|
|
3421
3444
|
*/
|
|
3422
3445
|
reasoningEffort: z18.string().nullish(),
|
|
3446
|
+
/**
|
|
3447
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
3448
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
3449
|
+
* request prefix for prompt caching.
|
|
3450
|
+
*
|
|
3451
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
3452
|
+
* combined with automatic truncation.
|
|
3453
|
+
*/
|
|
3454
|
+
reasoningEffortUpdate: z18.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
3423
3455
|
/**
|
|
3424
3456
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
3425
3457
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -3618,7 +3650,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3618
3650
|
toolChoice,
|
|
3619
3651
|
responseFormat
|
|
3620
3652
|
}) {
|
|
3621
|
-
var _a2, _b, _c, _d;
|
|
3653
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3622
3654
|
const warnings = [];
|
|
3623
3655
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
3624
3656
|
if (topK != null) {
|
|
@@ -3662,6 +3694,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3662
3694
|
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
3663
3695
|
});
|
|
3664
3696
|
warnings.push(...inputWarnings);
|
|
3697
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
3698
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
3699
|
+
resolvedReasoningEffort
|
|
3700
|
+
)) {
|
|
3701
|
+
warnings.push({
|
|
3702
|
+
type: "unsupported-setting",
|
|
3703
|
+
setting: "reasoningEffort",
|
|
3704
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
3705
|
+
});
|
|
3706
|
+
resolvedReasoningEffort = void 0;
|
|
3707
|
+
}
|
|
3708
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
3709
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
3710
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
3711
|
+
warnings.push({
|
|
3712
|
+
type: "unsupported-setting",
|
|
3713
|
+
setting: "reasoningEffortUpdate",
|
|
3714
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
3715
|
+
});
|
|
3716
|
+
} else if (reasoningEffortUpdate != null) {
|
|
3717
|
+
input.unshift({
|
|
3718
|
+
type: "configuration_update",
|
|
3719
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3665
3722
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
3666
3723
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
3667
3724
|
function addInclude(key) {
|
|
@@ -3733,10 +3790,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3733
3790
|
top_logprobs: topLogprobs,
|
|
3734
3791
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
3735
3792
|
// model-specific settings:
|
|
3736
|
-
...modelCapabilities.isReasoningModel && (
|
|
3793
|
+
...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) && {
|
|
3737
3794
|
reasoning: {
|
|
3738
|
-
...
|
|
3739
|
-
effort:
|
|
3795
|
+
...resolvedReasoningEffort != null && {
|
|
3796
|
+
effort: resolvedReasoningEffort
|
|
3740
3797
|
},
|
|
3741
3798
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
3742
3799
|
summary: openaiOptions.reasoningSummary
|
|
@@ -3750,6 +3807,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3750
3807
|
}
|
|
3751
3808
|
}
|
|
3752
3809
|
};
|
|
3810
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
3811
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
3812
|
+
warnings.push({
|
|
3813
|
+
type: "unsupported-setting",
|
|
3814
|
+
setting: "promptCacheRetention",
|
|
3815
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
3753
3818
|
if (modelCapabilities.isReasoningModel) {
|
|
3754
3819
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
3755
3820
|
if (baseArgs.temperature != null) {
|
|
@@ -3768,6 +3833,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3768
3833
|
details: "topP is not supported for reasoning models"
|
|
3769
3834
|
});
|
|
3770
3835
|
}
|
|
3836
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_e = baseArgs.include) == null ? void 0 : _e.includes("message.output_text.logprobs")))) {
|
|
3837
|
+
baseArgs.top_logprobs = void 0;
|
|
3838
|
+
const filteredInclude = (_f = baseArgs.include) == null ? void 0 : _f.filter(
|
|
3839
|
+
(value) => value !== "message.output_text.logprobs"
|
|
3840
|
+
);
|
|
3841
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
3842
|
+
warnings.push({
|
|
3843
|
+
type: "unsupported-setting",
|
|
3844
|
+
setting: "logprobs",
|
|
3845
|
+
details: "logprobs is not supported for reasoning models"
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3771
3848
|
}
|
|
3772
3849
|
} else {
|
|
3773
3850
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
@@ -5106,7 +5183,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5106
5183
|
};
|
|
5107
5184
|
|
|
5108
5185
|
// src/version.ts
|
|
5109
|
-
var VERSION = true ? "2.0.
|
|
5186
|
+
var VERSION = true ? "2.0.125" : "0.0.0-test";
|
|
5110
5187
|
|
|
5111
5188
|
// src/openai-provider.ts
|
|
5112
5189
|
function createOpenAI(options = {}) {
|