@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.125
4
+
5
+ ### Patch Changes
6
+
7
+ - e0d0bd1: feat(openai): add GPT-6 reasoning configuration updates
8
+
3
9
  ## 2.0.124
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts 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?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
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;
@@ -33,7 +33,7 @@ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large
33
33
 
34
34
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | (string & {});
35
35
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
36
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
36
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
37
37
  background?: "auto" | "transparent" | "opaque" | undefined;
38
38
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
39
39
  outputCompression?: number | undefined;
@@ -41,13 +41,13 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
41
41
  }>;
42
42
  type OpenAIImageModelOptions = InferValidator<typeof openaiImageModelOptions>;
43
43
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazyValidator<{
44
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
44
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
45
45
  background?: "auto" | "transparent" | "opaque" | undefined;
46
46
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
47
47
  outputCompression?: number | undefined;
48
48
  user?: string | undefined;
49
49
  style?: "vivid" | "natural" | undefined;
50
- moderation?: "auto" | "low" | undefined;
50
+ moderation?: "low" | "auto" | undefined;
51
51
  }>;
52
52
  type OpenAIImageModelGenerationOptions = InferValidator<typeof openaiImageModelGenerationOptions>;
53
53
 
@@ -375,6 +375,7 @@ declare const openaiResponsesProviderOptionsSchema: _ai_sdk_provider_utils.LazyV
375
375
  } | undefined;
376
376
  promptCacheRetention?: "in_memory" | "24h" | null | undefined;
377
377
  reasoningEffort?: string | null | undefined;
378
+ reasoningEffortUpdate?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
378
379
  reasoningMode?: "standard" | "pro" | undefined;
379
380
  reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
380
381
  reasoningSummary?: string | null | undefined;
package/dist/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?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
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;
@@ -33,7 +33,7 @@ type OpenAIEmbeddingModelId = 'text-embedding-3-small' | 'text-embedding-3-large
33
33
 
34
34
  type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | (string & {});
35
35
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
36
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
36
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
37
37
  background?: "auto" | "transparent" | "opaque" | undefined;
38
38
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
39
39
  outputCompression?: number | undefined;
@@ -41,13 +41,13 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
41
41
  }>;
42
42
  type OpenAIImageModelOptions = InferValidator<typeof openaiImageModelOptions>;
43
43
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazyValidator<{
44
- quality?: "auto" | "low" | "medium" | "high" | "standard" | "hd" | undefined;
44
+ quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
45
45
  background?: "auto" | "transparent" | "opaque" | undefined;
46
46
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
47
47
  outputCompression?: number | undefined;
48
48
  user?: string | undefined;
49
49
  style?: "vivid" | "natural" | undefined;
50
- moderation?: "auto" | "low" | undefined;
50
+ moderation?: "low" | "auto" | undefined;
51
51
  }>;
52
52
  type OpenAIImageModelGenerationOptions = InferValidator<typeof openaiImageModelGenerationOptions>;
53
53
 
@@ -375,6 +375,7 @@ declare const openaiResponsesProviderOptionsSchema: _ai_sdk_provider_utils.LazyV
375
375
  } | undefined;
376
376
  promptCacheRetention?: "in_memory" | "24h" | null | undefined;
377
377
  reasoningEffort?: string | null | undefined;
378
+ reasoningEffortUpdate?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
378
379
  reasoningMode?: "standard" | "pro" | undefined;
379
380
  reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
380
381
  reasoningSummary?: string | null | undefined;
package/dist/index.js CHANGED
@@ -59,14 +59,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
59
59
  const gptVersion = getGptVersion(modelId);
60
60
  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);
61
61
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
62
+ const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
62
63
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
63
64
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
64
65
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
65
- const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
66
+ const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
66
67
  const systemMessageMode = isReasoningModel ? "developer" : "system";
67
68
  return {
68
69
  supportsFlexProcessing,
69
70
  supportsPriorityProcessing,
71
+ supportsConfigurationUpdate: isGpt6OrLaterModel,
72
+ supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
70
73
  isReasoningModel,
71
74
  systemMessageMode,
72
75
  supportsNonReasoningParameters
@@ -751,6 +754,17 @@ var OpenAIChatLanguageModel = class {
751
754
  );
752
755
  warnings.push(...messageWarnings);
753
756
  const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
757
+ let resolvedReasoningEffort = openaiOptions.reasoningEffort;
758
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
759
+ resolvedReasoningEffort
760
+ )) {
761
+ warnings.push({
762
+ type: "unsupported-setting",
763
+ setting: "reasoningEffort",
764
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
765
+ });
766
+ resolvedReasoningEffort = void 0;
767
+ }
754
768
  const baseArgs = {
755
769
  // model id:
756
770
  model: this.modelId,
@@ -784,7 +798,7 @@ var OpenAIChatLanguageModel = class {
784
798
  store: openaiOptions.store,
785
799
  metadata: openaiOptions.metadata,
786
800
  prediction: openaiOptions.prediction,
787
- reasoning_effort: openaiOptions.reasoningEffort,
801
+ reasoning_effort: resolvedReasoningEffort,
788
802
  service_tier: openaiOptions.serviceTier,
789
803
  prompt_cache_key: openaiOptions.promptCacheKey,
790
804
  prompt_cache_options: openaiOptions.promptCacheOptions,
@@ -793,6 +807,14 @@ var OpenAIChatLanguageModel = class {
793
807
  // messages:
794
808
  messages
795
809
  };
810
+ if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
811
+ baseArgs.prompt_cache_retention = void 0;
812
+ warnings.push({
813
+ type: "unsupported-setting",
814
+ setting: "promptCacheRetention",
815
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
816
+ });
817
+ }
796
818
  if (modelCapabilities.isReasoningModel) {
797
819
  if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
798
820
  if (baseArgs.temperature != null) {
@@ -3345,6 +3367,15 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils23.lazyValid
3345
3367
  * Supported values vary by model.
3346
3368
  */
3347
3369
  reasoningEffort: import_v418.z.string().nullish(),
3370
+ /**
3371
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
3372
+ * without changing the request-level reasoning effort. This preserves the
3373
+ * request prefix for prompt caching.
3374
+ *
3375
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
3376
+ * combined with automatic truncation.
3377
+ */
3378
+ reasoningEffortUpdate: import_v418.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
3348
3379
  /**
3349
3380
  * Controls how much model work GPT-5.6 performs before returning a final answer.
3350
3381
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -3541,7 +3572,7 @@ var OpenAIResponsesLanguageModel = class {
3541
3572
  toolChoice,
3542
3573
  responseFormat
3543
3574
  }) {
3544
- var _a2, _b, _c, _d;
3575
+ var _a2, _b, _c, _d, _e, _f;
3545
3576
  const warnings = [];
3546
3577
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
3547
3578
  if (topK != null) {
@@ -3585,6 +3616,31 @@ var OpenAIResponsesLanguageModel = class {
3585
3616
  hasLocalShellTool: hasOpenAITool("openai.local_shell")
3586
3617
  });
3587
3618
  warnings.push(...inputWarnings);
3619
+ let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
3620
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
3621
+ resolvedReasoningEffort
3622
+ )) {
3623
+ warnings.push({
3624
+ type: "unsupported-setting",
3625
+ setting: "reasoningEffort",
3626
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
3627
+ });
3628
+ resolvedReasoningEffort = void 0;
3629
+ }
3630
+ const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
3631
+ const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
3632
+ if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
3633
+ warnings.push({
3634
+ type: "unsupported-setting",
3635
+ setting: "reasoningEffortUpdate",
3636
+ details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
3637
+ });
3638
+ } else if (reasoningEffortUpdate != null) {
3639
+ input.unshift({
3640
+ type: "configuration_update",
3641
+ reasoning: { effort: reasoningEffortUpdate }
3642
+ });
3643
+ }
3588
3644
  const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
3589
3645
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
3590
3646
  function addInclude(key) {
@@ -3656,10 +3712,10 @@ var OpenAIResponsesLanguageModel = class {
3656
3712
  top_logprobs: topLogprobs,
3657
3713
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
3658
3714
  // model-specific settings:
3659
- ...modelCapabilities.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) && {
3715
+ ...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) && {
3660
3716
  reasoning: {
3661
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
3662
- effort: openaiOptions.reasoningEffort
3717
+ ...resolvedReasoningEffort != null && {
3718
+ effort: resolvedReasoningEffort
3663
3719
  },
3664
3720
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
3665
3721
  summary: openaiOptions.reasoningSummary
@@ -3673,6 +3729,14 @@ var OpenAIResponsesLanguageModel = class {
3673
3729
  }
3674
3730
  }
3675
3731
  };
3732
+ if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
3733
+ baseArgs.prompt_cache_retention = void 0;
3734
+ warnings.push({
3735
+ type: "unsupported-setting",
3736
+ setting: "promptCacheRetention",
3737
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
3738
+ });
3739
+ }
3676
3740
  if (modelCapabilities.isReasoningModel) {
3677
3741
  if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
3678
3742
  if (baseArgs.temperature != null) {
@@ -3691,6 +3755,18 @@ var OpenAIResponsesLanguageModel = class {
3691
3755
  details: "topP is not supported for reasoning models"
3692
3756
  });
3693
3757
  }
3758
+ if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_e = baseArgs.include) == null ? void 0 : _e.includes("message.output_text.logprobs")))) {
3759
+ baseArgs.top_logprobs = void 0;
3760
+ const filteredInclude = (_f = baseArgs.include) == null ? void 0 : _f.filter(
3761
+ (value) => value !== "message.output_text.logprobs"
3762
+ );
3763
+ baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
3764
+ warnings.push({
3765
+ type: "unsupported-setting",
3766
+ setting: "logprobs",
3767
+ details: "logprobs is not supported for reasoning models"
3768
+ });
3769
+ }
3694
3770
  }
3695
3771
  } else {
3696
3772
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
@@ -5011,7 +5087,7 @@ var OpenAITranscriptionModel = class {
5011
5087
  };
5012
5088
 
5013
5089
  // src/version.ts
5014
- var VERSION = true ? "2.0.124" : "0.0.0-test";
5090
+ var VERSION = true ? "2.0.125" : "0.0.0-test";
5015
5091
 
5016
5092
  // src/openai-provider.ts
5017
5093
  function createOpenAI(options = {}) {