@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.
@@ -37,14 +37,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
37
37
  const gptVersion = getGptVersion(modelId);
38
38
  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);
39
39
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
40
+ const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
40
41
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
41
42
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
42
43
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
43
- const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
44
+ const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
44
45
  const systemMessageMode = isReasoningModel ? "developer" : "system";
45
46
  return {
46
47
  supportsFlexProcessing,
47
48
  supportsPriorityProcessing,
49
+ supportsConfigurationUpdate: isGpt6OrLaterModel,
50
+ supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
48
51
  isReasoningModel,
49
52
  systemMessageMode,
50
53
  supportsNonReasoningParameters
@@ -726,6 +729,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
726
729
  user: z3.string().optional(),
727
730
  /**
728
731
  * Reasoning effort for reasoning models. Defaults to `medium`.
732
+ * GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
729
733
  */
730
734
  reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
731
735
  /**
@@ -924,6 +928,17 @@ var OpenAIChatLanguageModel = class {
924
928
  })) != null ? _a2 : {};
925
929
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
926
930
  const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
931
+ let resolvedReasoningEffort = openaiOptions.reasoningEffort;
932
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
933
+ resolvedReasoningEffort
934
+ )) {
935
+ warnings.push({
936
+ type: "unsupported",
937
+ feature: "reasoningEffort",
938
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
939
+ });
940
+ resolvedReasoningEffort = void 0;
941
+ }
927
942
  if (topK != null) {
928
943
  warnings.push({ type: "unsupported", feature: "topK" });
929
944
  }
@@ -968,7 +983,7 @@ var OpenAIChatLanguageModel = class {
968
983
  store: openaiOptions.store,
969
984
  metadata: openaiOptions.metadata,
970
985
  prediction: openaiOptions.prediction,
971
- reasoning_effort: openaiOptions.reasoningEffort,
986
+ reasoning_effort: resolvedReasoningEffort,
972
987
  service_tier: openaiOptions.serviceTier,
973
988
  prompt_cache_key: openaiOptions.promptCacheKey,
974
989
  prompt_cache_options: openaiOptions.promptCacheOptions,
@@ -977,6 +992,14 @@ var OpenAIChatLanguageModel = class {
977
992
  // messages:
978
993
  messages
979
994
  };
995
+ if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
996
+ baseArgs.prompt_cache_retention = void 0;
997
+ warnings.push({
998
+ type: "unsupported",
999
+ feature: "promptCacheRetention",
1000
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
1001
+ });
1002
+ }
980
1003
  if (isReasoningModel) {
981
1004
  if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
982
1005
  if (baseArgs.temperature != null) {
@@ -5115,9 +5138,19 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
5115
5138
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
5116
5139
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
5117
5140
  * GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
5141
+ * GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
5118
5142
  * Supported values vary by model.
5119
5143
  */
5120
5144
  reasoningEffort: z19.string().nullish(),
5145
+ /**
5146
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
5147
+ * without changing the request-level reasoning effort. This preserves the
5148
+ * request prefix for prompt caching.
5149
+ *
5150
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
5151
+ * combined with automatic truncation.
5152
+ */
5153
+ reasoningEffortUpdate: z19.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
5121
5154
  /**
5122
5155
  * Controls how much model work GPT-5.6 performs before returning a final answer.
5123
5156
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -6069,7 +6102,7 @@ var OpenAIResponsesLanguageModel = class {
6069
6102
  toolChoice,
6070
6103
  responseFormat
6071
6104
  }) {
6072
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
6105
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
6073
6106
  const warnings = [];
6074
6107
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
6075
6108
  if (topK != null) {
@@ -6101,6 +6134,17 @@ var OpenAIResponsesLanguageModel = class {
6101
6134
  });
6102
6135
  }
6103
6136
  const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
6137
+ let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
6138
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
6139
+ resolvedReasoningEffort
6140
+ )) {
6141
+ warnings.push({
6142
+ type: "unsupported",
6143
+ feature: "reasoningEffort",
6144
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
6145
+ });
6146
+ resolvedReasoningEffort = void 0;
6147
+ }
6104
6148
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
6105
6149
  warnings.push({
6106
6150
  type: "unsupported",
@@ -6153,6 +6197,20 @@ var OpenAIResponsesLanguageModel = class {
6153
6197
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
6154
6198
  });
6155
6199
  warnings.push(...inputWarnings);
6200
+ const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
6201
+ const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
6202
+ if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
6203
+ warnings.push({
6204
+ type: "unsupported",
6205
+ feature: "reasoningEffortUpdate",
6206
+ details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
6207
+ });
6208
+ } else if (reasoningEffortUpdate != null) {
6209
+ input.unshift({
6210
+ type: "configuration_update",
6211
+ reasoning: { effort: reasoningEffortUpdate }
6212
+ });
6213
+ }
6156
6214
  const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
6157
6215
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
6158
6216
  function addInclude(key) {
@@ -6226,10 +6284,10 @@ var OpenAIResponsesLanguageModel = class {
6226
6284
  top_logprobs: topLogprobs,
6227
6285
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
6228
6286
  // model-specific settings:
6229
- ...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) && {
6287
+ ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
6230
6288
  reasoning: {
6231
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
6232
- effort: openaiOptions.reasoningEffort
6289
+ ...resolvedReasoningEffort != null && {
6290
+ effort: resolvedReasoningEffort
6233
6291
  },
6234
6292
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
6235
6293
  summary: openaiOptions.reasoningSummary
@@ -6243,6 +6301,14 @@ var OpenAIResponsesLanguageModel = class {
6243
6301
  }
6244
6302
  }
6245
6303
  };
6304
+ if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
6305
+ baseArgs.prompt_cache_retention = void 0;
6306
+ warnings.push({
6307
+ type: "unsupported",
6308
+ feature: "promptCacheRetention",
6309
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
6310
+ });
6311
+ }
6246
6312
  if (isReasoningModel) {
6247
6313
  if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
6248
6314
  if (baseArgs.temperature != null) {
@@ -6262,6 +6328,18 @@ var OpenAIResponsesLanguageModel = class {
6262
6328
  });
6263
6329
  }
6264
6330
  }
6331
+ if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
6332
+ baseArgs.top_logprobs = void 0;
6333
+ const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
6334
+ (value) => value !== "message.output_text.logprobs"
6335
+ );
6336
+ baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
6337
+ warnings.push({
6338
+ type: "unsupported",
6339
+ feature: "logprobs",
6340
+ details: "logprobs is not supported for reasoning models"
6341
+ });
6342
+ }
6265
6343
  } else {
6266
6344
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
6267
6345
  warnings.push({
@@ -6308,9 +6386,9 @@ var OpenAIResponsesLanguageModel = class {
6308
6386
  });
6309
6387
  delete baseArgs.service_tier;
6310
6388
  }
6311
- const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
6389
+ const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
6312
6390
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
6313
- )) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
6391
+ )) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
6314
6392
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
6315
6393
  return {
6316
6394
  webSearchToolName,