@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/index.mjs
CHANGED
|
@@ -45,14 +45,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
45
45
|
const gptVersion = getGptVersion(modelId);
|
|
46
46
|
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);
|
|
47
47
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
48
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
48
49
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
49
50
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
50
51
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
51
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
52
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
52
53
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
53
54
|
return {
|
|
54
55
|
supportsFlexProcessing,
|
|
55
56
|
supportsPriorityProcessing,
|
|
57
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
58
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
56
59
|
isReasoningModel,
|
|
57
60
|
systemMessageMode,
|
|
58
61
|
supportsNonReasoningParameters
|
|
@@ -734,6 +737,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
734
737
|
user: z3.string().optional(),
|
|
735
738
|
/**
|
|
736
739
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
740
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
737
741
|
*/
|
|
738
742
|
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
739
743
|
/**
|
|
@@ -932,6 +936,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
932
936
|
})) != null ? _a2 : {};
|
|
933
937
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
934
938
|
const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
939
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
940
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
941
|
+
resolvedReasoningEffort
|
|
942
|
+
)) {
|
|
943
|
+
warnings.push({
|
|
944
|
+
type: "unsupported",
|
|
945
|
+
feature: "reasoningEffort",
|
|
946
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
947
|
+
});
|
|
948
|
+
resolvedReasoningEffort = void 0;
|
|
949
|
+
}
|
|
935
950
|
if (topK != null) {
|
|
936
951
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
937
952
|
}
|
|
@@ -976,7 +991,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
976
991
|
store: openaiOptions.store,
|
|
977
992
|
metadata: openaiOptions.metadata,
|
|
978
993
|
prediction: openaiOptions.prediction,
|
|
979
|
-
reasoning_effort:
|
|
994
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
980
995
|
service_tier: openaiOptions.serviceTier,
|
|
981
996
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
982
997
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -985,6 +1000,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
985
1000
|
// messages:
|
|
986
1001
|
messages
|
|
987
1002
|
};
|
|
1003
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
1004
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
1005
|
+
warnings.push({
|
|
1006
|
+
type: "unsupported",
|
|
1007
|
+
feature: "promptCacheRetention",
|
|
1008
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
988
1011
|
if (isReasoningModel) {
|
|
989
1012
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
990
1013
|
if (baseArgs.temperature != null) {
|
|
@@ -5104,7 +5127,8 @@ var openaiResponsesReasoningModelIds = [
|
|
|
5104
5127
|
"gpt-5.6",
|
|
5105
5128
|
"gpt-5.6-luna",
|
|
5106
5129
|
"gpt-5.6-sol",
|
|
5107
|
-
"gpt-5.6-terra"
|
|
5130
|
+
"gpt-5.6-terra",
|
|
5131
|
+
"gpt-6-astra"
|
|
5108
5132
|
];
|
|
5109
5133
|
var openaiResponsesModelIds = [
|
|
5110
5134
|
"gpt-4.1",
|
|
@@ -5223,9 +5247,19 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
|
|
|
5223
5247
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5224
5248
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5225
5249
|
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5250
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5226
5251
|
* Supported values vary by model.
|
|
5227
5252
|
*/
|
|
5228
5253
|
reasoningEffort: z23.string().nullish(),
|
|
5254
|
+
/**
|
|
5255
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
5256
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
5257
|
+
* request prefix for prompt caching.
|
|
5258
|
+
*
|
|
5259
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
5260
|
+
* combined with automatic truncation.
|
|
5261
|
+
*/
|
|
5262
|
+
reasoningEffortUpdate: z23.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5229
5263
|
/**
|
|
5230
5264
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5231
5265
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -5825,7 +5859,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5825
5859
|
toolChoice,
|
|
5826
5860
|
responseFormat
|
|
5827
5861
|
}) {
|
|
5828
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5862
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
5829
5863
|
const warnings = [];
|
|
5830
5864
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5831
5865
|
if (topK != null) {
|
|
@@ -5857,6 +5891,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5857
5891
|
});
|
|
5858
5892
|
}
|
|
5859
5893
|
const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
|
|
5894
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
5895
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
5896
|
+
resolvedReasoningEffort
|
|
5897
|
+
)) {
|
|
5898
|
+
warnings.push({
|
|
5899
|
+
type: "unsupported",
|
|
5900
|
+
feature: "reasoningEffort",
|
|
5901
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
5902
|
+
});
|
|
5903
|
+
resolvedReasoningEffort = void 0;
|
|
5904
|
+
}
|
|
5860
5905
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
5861
5906
|
warnings.push({
|
|
5862
5907
|
type: "unsupported",
|
|
@@ -5909,6 +5954,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5909
5954
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5910
5955
|
});
|
|
5911
5956
|
warnings.push(...inputWarnings);
|
|
5957
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
5958
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
5959
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
5960
|
+
warnings.push({
|
|
5961
|
+
type: "unsupported",
|
|
5962
|
+
feature: "reasoningEffortUpdate",
|
|
5963
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
5964
|
+
});
|
|
5965
|
+
} else if (reasoningEffortUpdate != null) {
|
|
5966
|
+
input.unshift({
|
|
5967
|
+
type: "configuration_update",
|
|
5968
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
5969
|
+
});
|
|
5970
|
+
}
|
|
5912
5971
|
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
5913
5972
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5914
5973
|
function addInclude(key) {
|
|
@@ -5982,10 +6041,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5982
6041
|
top_logprobs: topLogprobs,
|
|
5983
6042
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5984
6043
|
// model-specific settings:
|
|
5985
|
-
...isReasoningModel && (
|
|
6044
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5986
6045
|
reasoning: {
|
|
5987
|
-
...
|
|
5988
|
-
effort:
|
|
6046
|
+
...resolvedReasoningEffort != null && {
|
|
6047
|
+
effort: resolvedReasoningEffort
|
|
5989
6048
|
},
|
|
5990
6049
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
5991
6050
|
summary: openaiOptions.reasoningSummary
|
|
@@ -5999,6 +6058,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5999
6058
|
}
|
|
6000
6059
|
}
|
|
6001
6060
|
};
|
|
6061
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
6062
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
6063
|
+
warnings.push({
|
|
6064
|
+
type: "unsupported",
|
|
6065
|
+
feature: "promptCacheRetention",
|
|
6066
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
6067
|
+
});
|
|
6068
|
+
}
|
|
6002
6069
|
if (isReasoningModel) {
|
|
6003
6070
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
6004
6071
|
if (baseArgs.temperature != null) {
|
|
@@ -6018,6 +6085,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6018
6085
|
});
|
|
6019
6086
|
}
|
|
6020
6087
|
}
|
|
6088
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
|
|
6089
|
+
baseArgs.top_logprobs = void 0;
|
|
6090
|
+
const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
|
|
6091
|
+
(value) => value !== "message.output_text.logprobs"
|
|
6092
|
+
);
|
|
6093
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
6094
|
+
warnings.push({
|
|
6095
|
+
type: "unsupported",
|
|
6096
|
+
feature: "logprobs",
|
|
6097
|
+
details: "logprobs is not supported for reasoning models"
|
|
6098
|
+
});
|
|
6099
|
+
}
|
|
6021
6100
|
} else {
|
|
6022
6101
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
6023
6102
|
warnings.push({
|
|
@@ -6064,9 +6143,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6064
6143
|
});
|
|
6065
6144
|
delete baseArgs.service_tier;
|
|
6066
6145
|
}
|
|
6067
|
-
const shellToolEnvType = (
|
|
6146
|
+
const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
|
|
6068
6147
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
6069
|
-
)) == null ? void 0 :
|
|
6148
|
+
)) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
|
|
6070
6149
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
6071
6150
|
return {
|
|
6072
6151
|
webSearchToolName,
|
|
@@ -8085,7 +8164,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8085
8164
|
};
|
|
8086
8165
|
|
|
8087
8166
|
// src/version.ts
|
|
8088
|
-
var VERSION = true ? "3.0.
|
|
8167
|
+
var VERSION = true ? "3.0.109" : "0.0.0-test";
|
|
8089
8168
|
|
|
8090
8169
|
// src/openai-provider.ts
|
|
8091
8170
|
function createOpenAI(options = {}) {
|