@ai-sdk/openai 4.0.59 → 4.0.60

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.60
4
+
5
+ ### Patch Changes
6
+
7
+ - 17e489e: feat(openai): add GPT-6 reasoning configuration updates
8
+
3
9
  ## 4.0.59
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
10
10
  logprobs?: number | boolean | undefined;
11
11
  parallelToolCalls?: boolean | undefined;
12
12
  user?: string | undefined;
13
- reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
13
+ reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" | undefined;
14
14
  maxCompletionTokens?: number | undefined;
15
15
  store?: boolean | undefined;
16
16
  metadata?: Record<string, string> | undefined;
@@ -49,7 +49,7 @@ type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOption
49
49
 
50
50
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
51
51
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
52
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
52
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
53
53
  background?: "auto" | "transparent" | "opaque" | undefined;
54
54
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
55
55
  outputCompression?: number | undefined;
@@ -57,17 +57,17 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
57
57
  }>;
58
58
  type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
59
59
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
60
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
60
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
61
61
  background?: "auto" | "transparent" | "opaque" | undefined;
62
62
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
63
63
  outputCompression?: number | undefined;
64
64
  user?: string | undefined;
65
65
  style?: "vivid" | "natural" | undefined;
66
- moderation?: "auto" | "low" | undefined;
66
+ moderation?: "low" | "auto" | undefined;
67
67
  }>;
68
68
  type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
69
69
  declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
70
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
70
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
71
71
  background?: "auto" | "transparent" | "opaque" | undefined;
72
72
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
73
73
  outputCompression?: number | undefined;
@@ -1382,6 +1382,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
1382
1382
  } | undefined;
1383
1383
  promptCacheRetention?: "in_memory" | "24h" | null | undefined;
1384
1384
  reasoningEffort?: string | null | undefined;
1385
+ reasoningEffortUpdate?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
1385
1386
  reasoningMode?: "standard" | "pro" | undefined;
1386
1387
  reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
1387
1388
  reasoningSummary?: string | null | undefined;
@@ -1429,7 +1430,7 @@ declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema
1429
1430
  silenceDurationMs?: number | undefined;
1430
1431
  } | undefined;
1431
1432
  streaming?: {
1432
- delay?: "minimal" | "low" | "medium" | "high" | "xhigh" | undefined;
1433
+ delay?: "low" | "medium" | "high" | "xhigh" | "minimal" | undefined;
1433
1434
  include?: string[] | undefined;
1434
1435
  } | undefined;
1435
1436
  }>;
package/dist/index.js CHANGED
@@ -48,14 +48,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
48
48
  const gptVersion = getGptVersion(modelId);
49
49
  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);
50
50
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
51
+ const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
51
52
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
52
53
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
53
54
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
54
- const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
55
+ const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
55
56
  const systemMessageMode = isReasoningModel ? "developer" : "system";
56
57
  return {
57
58
  supportsFlexProcessing,
58
59
  supportsPriorityProcessing,
60
+ supportsConfigurationUpdate: isGpt6OrLaterModel,
61
+ supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
59
62
  isReasoningModel,
60
63
  systemMessageMode,
61
64
  supportsNonReasoningParameters
@@ -1020,7 +1023,17 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1020
1023
  schema: openaiLanguageModelChatOptions
1021
1024
  })) != null ? _a2 : {};
1022
1025
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
1023
- const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
1026
+ let resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
1027
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
1028
+ resolvedReasoningEffort
1029
+ )) {
1030
+ warnings.push({
1031
+ type: "unsupported",
1032
+ feature: "reasoningEffort",
1033
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
1034
+ });
1035
+ resolvedReasoningEffort = void 0;
1036
+ }
1024
1037
  const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
1025
1038
  if (topK != null) {
1026
1039
  warnings.push({ type: "unsupported", feature: "topK" });
@@ -1075,6 +1088,14 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1075
1088
  // messages:
1076
1089
  messages
1077
1090
  };
1091
+ if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
1092
+ baseArgs.prompt_cache_retention = void 0;
1093
+ warnings.push({
1094
+ type: "unsupported",
1095
+ feature: "promptCacheRetention",
1096
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
1097
+ });
1098
+ }
1078
1099
  if (isReasoningModel) {
1079
1100
  if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
1080
1101
  if (baseArgs.temperature != null) {
@@ -6073,6 +6094,15 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema25(
6073
6094
  * Supported values vary by model.
6074
6095
  */
6075
6096
  reasoningEffort: z27.string().nullish(),
6097
+ /**
6098
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
6099
+ * without changing the request-level reasoning effort. This preserves the
6100
+ * request prefix for prompt caching.
6101
+ *
6102
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
6103
+ * combined with automatic compaction or automatic truncation.
6104
+ */
6105
+ reasoningEffortUpdate: z27.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
6076
6106
  /**
6077
6107
  * Controls how much model work GPT-5.6 performs before returning a final answer.
6078
6108
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -6798,7 +6828,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6798
6828
  toolChoice,
6799
6829
  responseFormat
6800
6830
  }) {
6801
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6831
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6802
6832
  const warnings = [];
6803
6833
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
6804
6834
  if (topK != null) {
@@ -6829,7 +6859,17 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6829
6859
  schema: openaiLanguageModelResponsesOptionsSchema
6830
6860
  });
6831
6861
  }
6832
- const resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
6862
+ let resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
6863
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
6864
+ resolvedReasoningEffort
6865
+ )) {
6866
+ warnings.push({
6867
+ type: "unsupported",
6868
+ feature: "reasoningEffort",
6869
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
6870
+ });
6871
+ resolvedReasoningEffort = void 0;
6872
+ }
6833
6873
  const resolvedReasoningSummary = (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
6834
6874
  const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
6835
6875
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
@@ -6889,6 +6929,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6889
6929
  outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
6890
6930
  });
6891
6931
  warnings.push(...inputWarnings);
6932
+ const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
6933
+ const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.contextManagement) == null && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
6934
+ if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
6935
+ warnings.push({
6936
+ type: "unsupported",
6937
+ feature: "reasoningEffortUpdate",
6938
+ details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic compaction or automatic truncation"
6939
+ });
6940
+ } else if (reasoningEffortUpdate != null) {
6941
+ input.unshift({
6942
+ type: "configuration_update",
6943
+ reasoning: { effort: reasoningEffortUpdate }
6944
+ });
6945
+ }
6892
6946
  if (openaiOptions == null ? void 0 : openaiOptions.compactionTrigger) {
6893
6947
  input.push({ type: "compaction_trigger" });
6894
6948
  }
@@ -6989,6 +7043,14 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6989
7043
  }
6990
7044
  }
6991
7045
  };
7046
+ if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
7047
+ baseArgs.prompt_cache_retention = void 0;
7048
+ warnings.push({
7049
+ type: "unsupported",
7050
+ feature: "promptCacheRetention",
7051
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
7052
+ });
7053
+ }
6992
7054
  if (isReasoningModel) {
6993
7055
  if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
6994
7056
  if (baseArgs.temperature != null) {
@@ -7007,6 +7069,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7007
7069
  details: "topP is not supported for reasoning models"
7008
7070
  });
7009
7071
  }
7072
+ if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_j = baseArgs.include) == null ? void 0 : _j.includes("message.output_text.logprobs")))) {
7073
+ baseArgs.top_logprobs = void 0;
7074
+ const filteredInclude = (_k = baseArgs.include) == null ? void 0 : _k.filter(
7075
+ (value) => value !== "message.output_text.logprobs"
7076
+ );
7077
+ baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
7078
+ warnings.push({
7079
+ type: "unsupported",
7080
+ feature: "logprobs",
7081
+ details: "logprobs is not supported for reasoning models"
7082
+ });
7083
+ }
7010
7084
  }
7011
7085
  } else {
7012
7086
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
@@ -7054,9 +7128,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7054
7128
  });
7055
7129
  delete baseArgs.service_tier;
7056
7130
  }
7057
- const shellToolEnvType = (_l = (_k = (_j = tools == null ? void 0 : tools.find(
7131
+ const shellToolEnvType = (_n = (_m = (_l = tools == null ? void 0 : tools.find(
7058
7132
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
7059
- )) == null ? void 0 : _j.args) == null ? void 0 : _k.environment) == null ? void 0 : _l.type;
7133
+ )) == null ? void 0 : _l.args) == null ? void 0 : _m.environment) == null ? void 0 : _n.type;
7060
7134
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
7061
7135
  return {
7062
7136
  webSearchToolName,
@@ -11060,7 +11134,7 @@ var OpenAISkills = class {
11060
11134
  };
11061
11135
 
11062
11136
  // src/version.ts
11063
- var VERSION = true ? "4.0.59" : "0.0.0-test";
11137
+ var VERSION = true ? "4.0.60" : "0.0.0-test";
11064
11138
 
11065
11139
  // src/openai-provider.ts
11066
11140
  function createOpenAI(options = {}) {