@ai-sdk/openai 3.0.108 → 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/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: openaiOptions.reasoningEffort,
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) {
@@ -5224,9 +5247,19 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
5224
5247
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
5225
5248
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
5226
5249
  * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
5250
+ * GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
5227
5251
  * Supported values vary by model.
5228
5252
  */
5229
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(),
5230
5263
  /**
5231
5264
  * Controls how much model work GPT-5.6 performs before returning a final answer.
5232
5265
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -5826,7 +5859,7 @@ var OpenAIResponsesLanguageModel = class {
5826
5859
  toolChoice,
5827
5860
  responseFormat
5828
5861
  }) {
5829
- 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;
5830
5863
  const warnings = [];
5831
5864
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
5832
5865
  if (topK != null) {
@@ -5858,6 +5891,17 @@ var OpenAIResponsesLanguageModel = class {
5858
5891
  });
5859
5892
  }
5860
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
+ }
5861
5905
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
5862
5906
  warnings.push({
5863
5907
  type: "unsupported",
@@ -5910,6 +5954,20 @@ var OpenAIResponsesLanguageModel = class {
5910
5954
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
5911
5955
  });
5912
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
+ }
5913
5971
  const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
5914
5972
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
5915
5973
  function addInclude(key) {
@@ -5983,10 +6041,10 @@ var OpenAIResponsesLanguageModel = class {
5983
6041
  top_logprobs: topLogprobs,
5984
6042
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
5985
6043
  // model-specific settings:
5986
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
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) && {
5987
6045
  reasoning: {
5988
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
5989
- effort: openaiOptions.reasoningEffort
6046
+ ...resolvedReasoningEffort != null && {
6047
+ effort: resolvedReasoningEffort
5990
6048
  },
5991
6049
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
5992
6050
  summary: openaiOptions.reasoningSummary
@@ -6000,6 +6058,14 @@ var OpenAIResponsesLanguageModel = class {
6000
6058
  }
6001
6059
  }
6002
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
+ }
6003
6069
  if (isReasoningModel) {
6004
6070
  if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
6005
6071
  if (baseArgs.temperature != null) {
@@ -6019,6 +6085,18 @@ var OpenAIResponsesLanguageModel = class {
6019
6085
  });
6020
6086
  }
6021
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
+ }
6022
6100
  } else {
6023
6101
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
6024
6102
  warnings.push({
@@ -6065,9 +6143,9 @@ var OpenAIResponsesLanguageModel = class {
6065
6143
  });
6066
6144
  delete baseArgs.service_tier;
6067
6145
  }
6068
- const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
6146
+ const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
6069
6147
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
6070
- )) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
6148
+ )) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
6071
6149
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
6072
6150
  return {
6073
6151
  webSearchToolName,
@@ -8086,7 +8164,7 @@ var OpenAITranscriptionModel = class {
8086
8164
  };
8087
8165
 
8088
8166
  // src/version.ts
8089
- var VERSION = true ? "3.0.108" : "0.0.0-test";
8167
+ var VERSION = true ? "3.0.109" : "0.0.0-test";
8090
8168
 
8091
8169
  // src/openai-provider.ts
8092
8170
  function createOpenAI(options = {}) {