@ai-sdk/openai 3.0.0-beta.84 → 3.0.0-beta.86

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
@@ -39,13 +39,20 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
39
39
  errorToMessage: (data) => data.error.message
40
40
  });
41
41
 
42
- // src/openai-is-reasoning-model.ts
43
- function isReasoningModel(modelId) {
44
- if (modelId.startsWith("gpt-3")) return false;
45
- if (modelId.startsWith("gpt-4")) return false;
46
- if (modelId.startsWith("chatgpt-4o")) return false;
47
- if (modelId.startsWith("gpt-5-chat")) return false;
48
- return true;
42
+ // src/openai-language-model-capabilities.ts
43
+ function getOpenAILanguageModelCapabilities(modelId) {
44
+ const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
45
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
46
+ const isReasoningModel = !(modelId.startsWith("gpt-3") || modelId.startsWith("gpt-4") || modelId.startsWith("chatgpt-4o") || modelId.startsWith("gpt-5-chat"));
47
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1");
48
+ const systemMessageMode = isReasoningModel ? "developer" : "system";
49
+ return {
50
+ supportsFlexProcessing,
51
+ supportsPriorityProcessing,
52
+ isReasoningModel,
53
+ systemMessageMode,
54
+ supportsNonReasoningParameters
55
+ };
49
56
  }
50
57
 
51
58
  // src/chat/convert-to-openai-chat-messages.ts
@@ -599,13 +606,14 @@ var OpenAIChatLanguageModel = class {
599
606
  providerOptions,
600
607
  schema: openaiChatLanguageModelOptions
601
608
  })) != null ? _a : {};
609
+ const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
602
610
  if (topK != null) {
603
611
  warnings.push({ type: "unsupported", feature: "topK" });
604
612
  }
605
613
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
606
614
  {
607
615
  prompt,
608
- systemMessageMode: getSystemMessageMode(this.modelId)
616
+ systemMessageMode: modelCapabilities.systemMessageMode
609
617
  }
610
618
  );
611
619
  warnings.push(...messageWarnings);
@@ -651,22 +659,31 @@ var OpenAIChatLanguageModel = class {
651
659
  // messages:
652
660
  messages
653
661
  };
654
- if (isReasoningModel(this.modelId)) {
655
- if (baseArgs.temperature != null) {
656
- baseArgs.temperature = void 0;
657
- warnings.push({
658
- type: "unsupported",
659
- feature: "temperature",
660
- details: "temperature is not supported for reasoning models"
661
- });
662
- }
663
- if (baseArgs.top_p != null) {
664
- baseArgs.top_p = void 0;
665
- warnings.push({
666
- type: "unsupported",
667
- feature: "topP",
668
- details: "topP is not supported for reasoning models"
669
- });
662
+ if (modelCapabilities.isReasoningModel) {
663
+ if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
664
+ if (baseArgs.temperature != null) {
665
+ baseArgs.temperature = void 0;
666
+ warnings.push({
667
+ type: "unsupported",
668
+ feature: "temperature",
669
+ details: "temperature is not supported for reasoning models"
670
+ });
671
+ }
672
+ if (baseArgs.top_p != null) {
673
+ baseArgs.top_p = void 0;
674
+ warnings.push({
675
+ type: "unsupported",
676
+ feature: "topP",
677
+ details: "topP is not supported for reasoning models"
678
+ });
679
+ }
680
+ if (baseArgs.logprobs != null) {
681
+ baseArgs.logprobs = void 0;
682
+ warnings.push({
683
+ type: "other",
684
+ message: "logprobs is not supported for reasoning models"
685
+ });
686
+ }
670
687
  }
671
688
  if (baseArgs.frequency_penalty != null) {
672
689
  baseArgs.frequency_penalty = void 0;
@@ -691,13 +708,6 @@ var OpenAIChatLanguageModel = class {
691
708
  message: "logitBias is not supported for reasoning models"
692
709
  });
693
710
  }
694
- if (baseArgs.logprobs != null) {
695
- baseArgs.logprobs = void 0;
696
- warnings.push({
697
- type: "other",
698
- message: "logprobs is not supported for reasoning models"
699
- });
700
- }
701
711
  if (baseArgs.top_logprobs != null) {
702
712
  baseArgs.top_logprobs = void 0;
703
713
  warnings.push({
@@ -721,7 +731,7 @@ var OpenAIChatLanguageModel = class {
721
731
  });
722
732
  }
723
733
  }
724
- if (openaiOptions.serviceTier === "flex" && !supportsFlexProcessing(this.modelId)) {
734
+ if (openaiOptions.serviceTier === "flex" && !modelCapabilities.supportsFlexProcessing) {
725
735
  warnings.push({
726
736
  type: "unsupported",
727
737
  feature: "serviceTier",
@@ -729,7 +739,7 @@ var OpenAIChatLanguageModel = class {
729
739
  });
730
740
  baseArgs.service_tier = void 0;
731
741
  }
732
- if (openaiOptions.serviceTier === "priority" && !supportsPriorityProcessing(this.modelId)) {
742
+ if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
733
743
  warnings.push({
734
744
  type: "unsupported",
735
745
  feature: "serviceTier",
@@ -1048,15 +1058,6 @@ var OpenAIChatLanguageModel = class {
1048
1058
  };
1049
1059
  }
1050
1060
  };
1051
- function supportsFlexProcessing(modelId) {
1052
- return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
1053
- }
1054
- function supportsPriorityProcessing(modelId) {
1055
- return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
1056
- }
1057
- function getSystemMessageMode(modelId) {
1058
- return isReasoningModel(modelId) ? "developer" : "system";
1059
- }
1060
1061
 
1061
1062
  // src/completion/openai-completion-language-model.ts
1062
1063
  import {
@@ -3789,7 +3790,7 @@ var OpenAIResponsesLanguageModel = class {
3789
3790
  }) {
3790
3791
  var _a, _b, _c, _d;
3791
3792
  const warnings = [];
3792
- const modelConfig = getResponsesModelConfig(this.modelId);
3793
+ const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
3793
3794
  if (topK != null) {
3794
3795
  warnings.push({ type: "unsupported", feature: "topK" });
3795
3796
  }
@@ -3834,7 +3835,7 @@ var OpenAIResponsesLanguageModel = class {
3834
3835
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
3835
3836
  prompt,
3836
3837
  toolNameMapping,
3837
- systemMessageMode: modelConfig.systemMessageMode,
3838
+ systemMessageMode: modelCapabilities.systemMessageMode,
3838
3839
  fileIdPrefixes: this.config.fileIdPrefixes,
3839
3840
  store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
3840
3841
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
@@ -3868,7 +3869,7 @@ var OpenAIResponsesLanguageModel = class {
3868
3869
  addInclude("code_interpreter_call.outputs");
3869
3870
  }
3870
3871
  const store = openaiOptions == null ? void 0 : openaiOptions.store;
3871
- if (store === false && modelConfig.isReasoningModel) {
3872
+ if (store === false && modelCapabilities.isReasoningModel) {
3872
3873
  addInclude("reasoning.encrypted_content");
3873
3874
  }
3874
3875
  const baseArgs = {
@@ -3910,7 +3911,7 @@ var OpenAIResponsesLanguageModel = class {
3910
3911
  top_logprobs: topLogprobs,
3911
3912
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
3912
3913
  // model-specific settings:
3913
- ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
3914
+ ...modelCapabilities.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
3914
3915
  reasoning: {
3915
3916
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
3916
3917
  effort: openaiOptions.reasoningEffort
@@ -3921,22 +3922,24 @@ var OpenAIResponsesLanguageModel = class {
3921
3922
  }
3922
3923
  }
3923
3924
  };
3924
- if (modelConfig.isReasoningModel) {
3925
- if (baseArgs.temperature != null) {
3926
- baseArgs.temperature = void 0;
3927
- warnings.push({
3928
- type: "unsupported",
3929
- feature: "temperature",
3930
- details: "temperature is not supported for reasoning models"
3931
- });
3932
- }
3933
- if (baseArgs.top_p != null) {
3934
- baseArgs.top_p = void 0;
3935
- warnings.push({
3936
- type: "unsupported",
3937
- feature: "topP",
3938
- details: "topP is not supported for reasoning models"
3939
- });
3925
+ if (modelCapabilities.isReasoningModel) {
3926
+ if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
3927
+ if (baseArgs.temperature != null) {
3928
+ baseArgs.temperature = void 0;
3929
+ warnings.push({
3930
+ type: "unsupported",
3931
+ feature: "temperature",
3932
+ details: "temperature is not supported for reasoning models"
3933
+ });
3934
+ }
3935
+ if (baseArgs.top_p != null) {
3936
+ baseArgs.top_p = void 0;
3937
+ warnings.push({
3938
+ type: "unsupported",
3939
+ feature: "topP",
3940
+ details: "topP is not supported for reasoning models"
3941
+ });
3942
+ }
3940
3943
  }
3941
3944
  } else {
3942
3945
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
@@ -3954,7 +3957,7 @@ var OpenAIResponsesLanguageModel = class {
3954
3957
  });
3955
3958
  }
3956
3959
  }
3957
- if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelConfig.supportsFlexProcessing) {
3960
+ if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
3958
3961
  warnings.push({
3959
3962
  type: "unsupported",
3960
3963
  feature: "serviceTier",
@@ -3962,7 +3965,7 @@ var OpenAIResponsesLanguageModel = class {
3962
3965
  });
3963
3966
  delete baseArgs.service_tier;
3964
3967
  }
3965
- if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelConfig.supportsPriorityProcessing) {
3968
+ if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
3966
3969
  warnings.push({
3967
3970
  type: "unsupported",
3968
3971
  feature: "serviceTier",
@@ -5095,18 +5098,6 @@ function isResponseAnnotationAddedChunk(chunk) {
5095
5098
  function isErrorChunk(chunk) {
5096
5099
  return chunk.type === "error";
5097
5100
  }
5098
- function getResponsesModelConfig(modelId) {
5099
- const supportsFlexProcessing2 = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
5100
- const supportsPriorityProcessing2 = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
5101
- const isReasoningModel2 = isReasoningModel(modelId);
5102
- const systemMessageMode = isReasoningModel2 ? "developer" : "system";
5103
- return {
5104
- systemMessageMode,
5105
- supportsFlexProcessing: supportsFlexProcessing2,
5106
- supportsPriorityProcessing: supportsPriorityProcessing2,
5107
- isReasoningModel: isReasoningModel2
5108
- };
5109
- }
5110
5101
  function mapWebSearchOutput(action) {
5111
5102
  var _a;
5112
5103
  switch (action.type) {
@@ -5490,7 +5481,7 @@ var OpenAITranscriptionModel = class {
5490
5481
  };
5491
5482
 
5492
5483
  // src/version.ts
5493
- var VERSION = true ? "3.0.0-beta.84" : "0.0.0-test";
5484
+ var VERSION = true ? "3.0.0-beta.86" : "0.0.0-test";
5494
5485
 
5495
5486
  // src/openai-provider.ts
5496
5487
  function createOpenAI(options = {}) {