@ai-sdk/openai 2.0.124 → 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 +6 -0
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +83 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -7
- 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 +82 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +82 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@ declare const openaiChatLanguageModelOptions: _ai_sdk_provider_utils.LazyValidat
|
|
|
8
8
|
logprobs?: number | boolean | undefined;
|
|
9
9
|
parallelToolCalls?: boolean | undefined;
|
|
10
10
|
user?: string | undefined;
|
|
11
|
-
reasoningEffort?: "
|
|
11
|
+
reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" | undefined;
|
|
12
12
|
maxCompletionTokens?: number | undefined;
|
|
13
13
|
store?: boolean | undefined;
|
|
14
14
|
metadata?: Record<string, string> | undefined;
|
|
@@ -126,7 +126,7 @@ declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
|
|
|
126
126
|
declare function hasDefaultResponseFormat(modelId: string): boolean;
|
|
127
127
|
declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
|
|
128
128
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
129
|
-
quality?: "
|
|
129
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
130
130
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
131
131
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
132
132
|
outputCompression?: number | undefined;
|
|
@@ -134,13 +134,13 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
134
134
|
}>;
|
|
135
135
|
type OpenAIImageModelOptions = InferValidator<typeof openaiImageModelOptions>;
|
|
136
136
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
137
|
-
quality?: "
|
|
137
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
138
138
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
139
139
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
140
140
|
outputCompression?: number | undefined;
|
|
141
141
|
user?: string | undefined;
|
|
142
142
|
style?: "vivid" | "natural" | undefined;
|
|
143
|
-
moderation?: "
|
|
143
|
+
moderation?: "low" | "auto" | undefined;
|
|
144
144
|
}>;
|
|
145
145
|
type OpenAIImageModelGenerationOptions = InferValidator<typeof openaiImageModelGenerationOptions>;
|
|
146
146
|
|
|
@@ -436,7 +436,7 @@ declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
436
436
|
outputCompression?: number | undefined;
|
|
437
437
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
438
438
|
partialImages?: number | undefined;
|
|
439
|
-
quality?: "
|
|
439
|
+
quality?: "low" | "medium" | "high" | "auto" | undefined;
|
|
440
440
|
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | undefined;
|
|
441
441
|
}>;
|
|
442
442
|
declare const imageGenerationOutputSchema: _ai_sdk_provider_utils.LazySchema<{
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const openaiChatLanguageModelOptions: _ai_sdk_provider_utils.LazyValidat
|
|
|
8
8
|
logprobs?: number | boolean | undefined;
|
|
9
9
|
parallelToolCalls?: boolean | undefined;
|
|
10
10
|
user?: string | undefined;
|
|
11
|
-
reasoningEffort?: "
|
|
11
|
+
reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" | undefined;
|
|
12
12
|
maxCompletionTokens?: number | undefined;
|
|
13
13
|
store?: boolean | undefined;
|
|
14
14
|
metadata?: Record<string, string> | undefined;
|
|
@@ -126,7 +126,7 @@ declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
|
|
|
126
126
|
declare function hasDefaultResponseFormat(modelId: string): boolean;
|
|
127
127
|
declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
|
|
128
128
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
129
|
-
quality?: "
|
|
129
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
130
130
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
131
131
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
132
132
|
outputCompression?: number | undefined;
|
|
@@ -134,13 +134,13 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
134
134
|
}>;
|
|
135
135
|
type OpenAIImageModelOptions = InferValidator<typeof openaiImageModelOptions>;
|
|
136
136
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
137
|
-
quality?: "
|
|
137
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
138
138
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
139
139
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
140
140
|
outputCompression?: number | undefined;
|
|
141
141
|
user?: string | undefined;
|
|
142
142
|
style?: "vivid" | "natural" | undefined;
|
|
143
|
-
moderation?: "
|
|
143
|
+
moderation?: "low" | "auto" | undefined;
|
|
144
144
|
}>;
|
|
145
145
|
type OpenAIImageModelGenerationOptions = InferValidator<typeof openaiImageModelGenerationOptions>;
|
|
146
146
|
|
|
@@ -436,7 +436,7 @@ declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
436
436
|
outputCompression?: number | undefined;
|
|
437
437
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
438
438
|
partialImages?: number | undefined;
|
|
439
|
-
quality?: "
|
|
439
|
+
quality?: "low" | "medium" | "high" | "auto" | undefined;
|
|
440
440
|
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | undefined;
|
|
441
441
|
}>;
|
|
442
442
|
declare const imageGenerationOutputSchema: _ai_sdk_provider_utils.LazySchema<{
|
package/dist/internal/index.js
CHANGED
|
@@ -88,14 +88,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
88
88
|
const gptVersion = getGptVersion(modelId);
|
|
89
89
|
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);
|
|
90
90
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
91
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
91
92
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
92
93
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
93
94
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
|
|
94
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
95
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
95
96
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
96
97
|
return {
|
|
97
98
|
supportsFlexProcessing,
|
|
98
99
|
supportsPriorityProcessing,
|
|
100
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
101
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
99
102
|
isReasoningModel,
|
|
100
103
|
systemMessageMode,
|
|
101
104
|
supportsNonReasoningParameters
|
|
@@ -780,6 +783,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
780
783
|
);
|
|
781
784
|
warnings.push(...messageWarnings);
|
|
782
785
|
const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
|
|
786
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
787
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
788
|
+
resolvedReasoningEffort
|
|
789
|
+
)) {
|
|
790
|
+
warnings.push({
|
|
791
|
+
type: "unsupported-setting",
|
|
792
|
+
setting: "reasoningEffort",
|
|
793
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
794
|
+
});
|
|
795
|
+
resolvedReasoningEffort = void 0;
|
|
796
|
+
}
|
|
783
797
|
const baseArgs = {
|
|
784
798
|
// model id:
|
|
785
799
|
model: this.modelId,
|
|
@@ -813,7 +827,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
813
827
|
store: openaiOptions.store,
|
|
814
828
|
metadata: openaiOptions.metadata,
|
|
815
829
|
prediction: openaiOptions.prediction,
|
|
816
|
-
reasoning_effort:
|
|
830
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
817
831
|
service_tier: openaiOptions.serviceTier,
|
|
818
832
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
819
833
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -822,6 +836,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
822
836
|
// messages:
|
|
823
837
|
messages
|
|
824
838
|
};
|
|
839
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
840
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
841
|
+
warnings.push({
|
|
842
|
+
type: "unsupported-setting",
|
|
843
|
+
setting: "promptCacheRetention",
|
|
844
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
845
|
+
});
|
|
846
|
+
}
|
|
825
847
|
if (modelCapabilities.isReasoningModel) {
|
|
826
848
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
827
849
|
if (baseArgs.temperature != null) {
|
|
@@ -3418,6 +3440,15 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils23.lazyValid
|
|
|
3418
3440
|
* Supported values vary by model.
|
|
3419
3441
|
*/
|
|
3420
3442
|
reasoningEffort: import_v416.z.string().nullish(),
|
|
3443
|
+
/**
|
|
3444
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
3445
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
3446
|
+
* request prefix for prompt caching.
|
|
3447
|
+
*
|
|
3448
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
3449
|
+
* combined with automatic truncation.
|
|
3450
|
+
*/
|
|
3451
|
+
reasoningEffortUpdate: import_v416.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
3421
3452
|
/**
|
|
3422
3453
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
3423
3454
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -3853,7 +3884,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3853
3884
|
toolChoice,
|
|
3854
3885
|
responseFormat
|
|
3855
3886
|
}) {
|
|
3856
|
-
var _a2, _b, _c, _d;
|
|
3887
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3857
3888
|
const warnings = [];
|
|
3858
3889
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
3859
3890
|
if (topK != null) {
|
|
@@ -3897,6 +3928,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3897
3928
|
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
3898
3929
|
});
|
|
3899
3930
|
warnings.push(...inputWarnings);
|
|
3931
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
3932
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
3933
|
+
resolvedReasoningEffort
|
|
3934
|
+
)) {
|
|
3935
|
+
warnings.push({
|
|
3936
|
+
type: "unsupported-setting",
|
|
3937
|
+
setting: "reasoningEffort",
|
|
3938
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
3939
|
+
});
|
|
3940
|
+
resolvedReasoningEffort = void 0;
|
|
3941
|
+
}
|
|
3942
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
3943
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
3944
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
3945
|
+
warnings.push({
|
|
3946
|
+
type: "unsupported-setting",
|
|
3947
|
+
setting: "reasoningEffortUpdate",
|
|
3948
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
3949
|
+
});
|
|
3950
|
+
} else if (reasoningEffortUpdate != null) {
|
|
3951
|
+
input.unshift({
|
|
3952
|
+
type: "configuration_update",
|
|
3953
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
3954
|
+
});
|
|
3955
|
+
}
|
|
3900
3956
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
3901
3957
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
3902
3958
|
function addInclude(key) {
|
|
@@ -3968,10 +4024,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3968
4024
|
top_logprobs: topLogprobs,
|
|
3969
4025
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
3970
4026
|
// model-specific settings:
|
|
3971
|
-
...modelCapabilities.isReasoningModel && (
|
|
4027
|
+
...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) && {
|
|
3972
4028
|
reasoning: {
|
|
3973
|
-
...
|
|
3974
|
-
effort:
|
|
4029
|
+
...resolvedReasoningEffort != null && {
|
|
4030
|
+
effort: resolvedReasoningEffort
|
|
3975
4031
|
},
|
|
3976
4032
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
3977
4033
|
summary: openaiOptions.reasoningSummary
|
|
@@ -3985,6 +4041,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3985
4041
|
}
|
|
3986
4042
|
}
|
|
3987
4043
|
};
|
|
4044
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
4045
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
4046
|
+
warnings.push({
|
|
4047
|
+
type: "unsupported-setting",
|
|
4048
|
+
setting: "promptCacheRetention",
|
|
4049
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
4050
|
+
});
|
|
4051
|
+
}
|
|
3988
4052
|
if (modelCapabilities.isReasoningModel) {
|
|
3989
4053
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
3990
4054
|
if (baseArgs.temperature != null) {
|
|
@@ -4003,6 +4067,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4003
4067
|
details: "topP is not supported for reasoning models"
|
|
4004
4068
|
});
|
|
4005
4069
|
}
|
|
4070
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_e = baseArgs.include) == null ? void 0 : _e.includes("message.output_text.logprobs")))) {
|
|
4071
|
+
baseArgs.top_logprobs = void 0;
|
|
4072
|
+
const filteredInclude = (_f = baseArgs.include) == null ? void 0 : _f.filter(
|
|
4073
|
+
(value) => value !== "message.output_text.logprobs"
|
|
4074
|
+
);
|
|
4075
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
4076
|
+
warnings.push({
|
|
4077
|
+
type: "unsupported-setting",
|
|
4078
|
+
setting: "logprobs",
|
|
4079
|
+
details: "logprobs is not supported for reasoning models"
|
|
4080
|
+
});
|
|
4081
|
+
}
|
|
4006
4082
|
}
|
|
4007
4083
|
} else {
|
|
4008
4084
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|