@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/dist/index.mjs CHANGED
@@ -46,14 +46,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
46
46
  const gptVersion = getGptVersion(modelId);
47
47
  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);
48
48
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
49
+ const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
49
50
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
50
51
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
51
52
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
52
- const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
53
+ const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
53
54
  const systemMessageMode = isReasoningModel ? "developer" : "system";
54
55
  return {
55
56
  supportsFlexProcessing,
56
57
  supportsPriorityProcessing,
58
+ supportsConfigurationUpdate: isGpt6OrLaterModel,
59
+ supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
57
60
  isReasoningModel,
58
61
  systemMessageMode,
59
62
  supportsNonReasoningParameters
@@ -748,6 +751,17 @@ var OpenAIChatLanguageModel = class {
748
751
  );
749
752
  warnings.push(...messageWarnings);
750
753
  const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
754
+ let resolvedReasoningEffort = openaiOptions.reasoningEffort;
755
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
756
+ resolvedReasoningEffort
757
+ )) {
758
+ warnings.push({
759
+ type: "unsupported-setting",
760
+ setting: "reasoningEffort",
761
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
762
+ });
763
+ resolvedReasoningEffort = void 0;
764
+ }
751
765
  const baseArgs = {
752
766
  // model id:
753
767
  model: this.modelId,
@@ -781,7 +795,7 @@ var OpenAIChatLanguageModel = class {
781
795
  store: openaiOptions.store,
782
796
  metadata: openaiOptions.metadata,
783
797
  prediction: openaiOptions.prediction,
784
- reasoning_effort: openaiOptions.reasoningEffort,
798
+ reasoning_effort: resolvedReasoningEffort,
785
799
  service_tier: openaiOptions.serviceTier,
786
800
  prompt_cache_key: openaiOptions.promptCacheKey,
787
801
  prompt_cache_options: openaiOptions.promptCacheOptions,
@@ -790,6 +804,14 @@ var OpenAIChatLanguageModel = class {
790
804
  // messages:
791
805
  messages
792
806
  };
807
+ if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
808
+ baseArgs.prompt_cache_retention = void 0;
809
+ warnings.push({
810
+ type: "unsupported-setting",
811
+ setting: "promptCacheRetention",
812
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
813
+ });
814
+ }
793
815
  if (modelCapabilities.isReasoningModel) {
794
816
  if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
795
817
  if (baseArgs.temperature != null) {
@@ -3421,6 +3443,15 @@ var openaiResponsesProviderOptionsSchema = lazyValidator10(
3421
3443
  * Supported values vary by model.
3422
3444
  */
3423
3445
  reasoningEffort: z18.string().nullish(),
3446
+ /**
3447
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
3448
+ * without changing the request-level reasoning effort. This preserves the
3449
+ * request prefix for prompt caching.
3450
+ *
3451
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
3452
+ * combined with automatic truncation.
3453
+ */
3454
+ reasoningEffortUpdate: z18.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
3424
3455
  /**
3425
3456
  * Controls how much model work GPT-5.6 performs before returning a final answer.
3426
3457
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -3619,7 +3650,7 @@ var OpenAIResponsesLanguageModel = class {
3619
3650
  toolChoice,
3620
3651
  responseFormat
3621
3652
  }) {
3622
- var _a2, _b, _c, _d;
3653
+ var _a2, _b, _c, _d, _e, _f;
3623
3654
  const warnings = [];
3624
3655
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
3625
3656
  if (topK != null) {
@@ -3663,6 +3694,31 @@ var OpenAIResponsesLanguageModel = class {
3663
3694
  hasLocalShellTool: hasOpenAITool("openai.local_shell")
3664
3695
  });
3665
3696
  warnings.push(...inputWarnings);
3697
+ let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
3698
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
3699
+ resolvedReasoningEffort
3700
+ )) {
3701
+ warnings.push({
3702
+ type: "unsupported-setting",
3703
+ setting: "reasoningEffort",
3704
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
3705
+ });
3706
+ resolvedReasoningEffort = void 0;
3707
+ }
3708
+ const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
3709
+ const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
3710
+ if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
3711
+ warnings.push({
3712
+ type: "unsupported-setting",
3713
+ setting: "reasoningEffortUpdate",
3714
+ details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
3715
+ });
3716
+ } else if (reasoningEffortUpdate != null) {
3717
+ input.unshift({
3718
+ type: "configuration_update",
3719
+ reasoning: { effort: reasoningEffortUpdate }
3720
+ });
3721
+ }
3666
3722
  const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
3667
3723
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
3668
3724
  function addInclude(key) {
@@ -3734,10 +3790,10 @@ var OpenAIResponsesLanguageModel = class {
3734
3790
  top_logprobs: topLogprobs,
3735
3791
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
3736
3792
  // model-specific settings:
3737
- ...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) && {
3793
+ ...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) && {
3738
3794
  reasoning: {
3739
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
3740
- effort: openaiOptions.reasoningEffort
3795
+ ...resolvedReasoningEffort != null && {
3796
+ effort: resolvedReasoningEffort
3741
3797
  },
3742
3798
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
3743
3799
  summary: openaiOptions.reasoningSummary
@@ -3751,6 +3807,14 @@ var OpenAIResponsesLanguageModel = class {
3751
3807
  }
3752
3808
  }
3753
3809
  };
3810
+ if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
3811
+ baseArgs.prompt_cache_retention = void 0;
3812
+ warnings.push({
3813
+ type: "unsupported-setting",
3814
+ setting: "promptCacheRetention",
3815
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
3816
+ });
3817
+ }
3754
3818
  if (modelCapabilities.isReasoningModel) {
3755
3819
  if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
3756
3820
  if (baseArgs.temperature != null) {
@@ -3769,6 +3833,18 @@ var OpenAIResponsesLanguageModel = class {
3769
3833
  details: "topP is not supported for reasoning models"
3770
3834
  });
3771
3835
  }
3836
+ if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_e = baseArgs.include) == null ? void 0 : _e.includes("message.output_text.logprobs")))) {
3837
+ baseArgs.top_logprobs = void 0;
3838
+ const filteredInclude = (_f = baseArgs.include) == null ? void 0 : _f.filter(
3839
+ (value) => value !== "message.output_text.logprobs"
3840
+ );
3841
+ baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
3842
+ warnings.push({
3843
+ type: "unsupported-setting",
3844
+ setting: "logprobs",
3845
+ details: "logprobs is not supported for reasoning models"
3846
+ });
3847
+ }
3772
3848
  }
3773
3849
  } else {
3774
3850
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
@@ -5107,7 +5183,7 @@ var OpenAITranscriptionModel = class {
5107
5183
  };
5108
5184
 
5109
5185
  // src/version.ts
5110
- var VERSION = true ? "2.0.124" : "0.0.0-test";
5186
+ var VERSION = true ? "2.0.125" : "0.0.0-test";
5111
5187
 
5112
5188
  // src/openai-provider.ts
5113
5189
  function createOpenAI(options = {}) {