@ai-sdk/openai 3.0.0-beta.83 → 3.0.0-beta.85

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.
@@ -79,13 +79,20 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
79
79
  errorToMessage: (data) => data.error.message
80
80
  });
81
81
 
82
- // src/openai-is-reasoning-model.ts
83
- function isReasoningModel(modelId) {
84
- if (modelId.startsWith("gpt-3")) return false;
85
- if (modelId.startsWith("gpt-4")) return false;
86
- if (modelId.startsWith("chatgpt-4o")) return false;
87
- if (modelId.startsWith("gpt-5-chat")) return false;
88
- return true;
82
+ // src/openai-language-model-capabilities.ts
83
+ function getOpenAILanguageModelCapabilities(modelId) {
84
+ const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
85
+ 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");
86
+ const isReasoningModel = !(modelId.startsWith("gpt-3") || modelId.startsWith("gpt-4") || modelId.startsWith("chatgpt-4o") || modelId.startsWith("gpt-5-chat"));
87
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1");
88
+ const systemMessageMode = isReasoningModel ? "developer" : "system";
89
+ return {
90
+ supportsFlexProcessing,
91
+ supportsPriorityProcessing,
92
+ isReasoningModel,
93
+ systemMessageMode,
94
+ supportsNonReasoningParameters
95
+ };
89
96
  }
90
97
 
91
98
  // src/chat/convert-to-openai-chat-messages.ts
@@ -635,13 +642,14 @@ var OpenAIChatLanguageModel = class {
635
642
  providerOptions,
636
643
  schema: openaiChatLanguageModelOptions
637
644
  })) != null ? _a : {};
645
+ const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
638
646
  if (topK != null) {
639
647
  warnings.push({ type: "unsupported", feature: "topK" });
640
648
  }
641
649
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
642
650
  {
643
651
  prompt,
644
- systemMessageMode: getSystemMessageMode(this.modelId)
652
+ systemMessageMode: modelCapabilities.systemMessageMode
645
653
  }
646
654
  );
647
655
  warnings.push(...messageWarnings);
@@ -687,22 +695,31 @@ var OpenAIChatLanguageModel = class {
687
695
  // messages:
688
696
  messages
689
697
  };
690
- if (isReasoningModel(this.modelId)) {
691
- if (baseArgs.temperature != null) {
692
- baseArgs.temperature = void 0;
693
- warnings.push({
694
- type: "unsupported",
695
- feature: "temperature",
696
- details: "temperature is not supported for reasoning models"
697
- });
698
- }
699
- if (baseArgs.top_p != null) {
700
- baseArgs.top_p = void 0;
701
- warnings.push({
702
- type: "unsupported",
703
- feature: "topP",
704
- details: "topP is not supported for reasoning models"
705
- });
698
+ if (modelCapabilities.isReasoningModel) {
699
+ if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
700
+ if (baseArgs.temperature != null) {
701
+ baseArgs.temperature = void 0;
702
+ warnings.push({
703
+ type: "unsupported",
704
+ feature: "temperature",
705
+ details: "temperature is not supported for reasoning models"
706
+ });
707
+ }
708
+ if (baseArgs.top_p != null) {
709
+ baseArgs.top_p = void 0;
710
+ warnings.push({
711
+ type: "unsupported",
712
+ feature: "topP",
713
+ details: "topP is not supported for reasoning models"
714
+ });
715
+ }
716
+ if (baseArgs.logprobs != null) {
717
+ baseArgs.logprobs = void 0;
718
+ warnings.push({
719
+ type: "other",
720
+ message: "logprobs is not supported for reasoning models"
721
+ });
722
+ }
706
723
  }
707
724
  if (baseArgs.frequency_penalty != null) {
708
725
  baseArgs.frequency_penalty = void 0;
@@ -727,13 +744,6 @@ var OpenAIChatLanguageModel = class {
727
744
  message: "logitBias is not supported for reasoning models"
728
745
  });
729
746
  }
730
- if (baseArgs.logprobs != null) {
731
- baseArgs.logprobs = void 0;
732
- warnings.push({
733
- type: "other",
734
- message: "logprobs is not supported for reasoning models"
735
- });
736
- }
737
747
  if (baseArgs.top_logprobs != null) {
738
748
  baseArgs.top_logprobs = void 0;
739
749
  warnings.push({
@@ -757,7 +767,7 @@ var OpenAIChatLanguageModel = class {
757
767
  });
758
768
  }
759
769
  }
760
- if (openaiOptions.serviceTier === "flex" && !supportsFlexProcessing(this.modelId)) {
770
+ if (openaiOptions.serviceTier === "flex" && !modelCapabilities.supportsFlexProcessing) {
761
771
  warnings.push({
762
772
  type: "unsupported",
763
773
  feature: "serviceTier",
@@ -765,7 +775,7 @@ var OpenAIChatLanguageModel = class {
765
775
  });
766
776
  baseArgs.service_tier = void 0;
767
777
  }
768
- if (openaiOptions.serviceTier === "priority" && !supportsPriorityProcessing(this.modelId)) {
778
+ if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
769
779
  warnings.push({
770
780
  type: "unsupported",
771
781
  feature: "serviceTier",
@@ -1084,15 +1094,6 @@ var OpenAIChatLanguageModel = class {
1084
1094
  };
1085
1095
  }
1086
1096
  };
1087
- function supportsFlexProcessing(modelId) {
1088
- return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
1089
- }
1090
- function supportsPriorityProcessing(modelId) {
1091
- 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");
1092
- }
1093
- function getSystemMessageMode(modelId) {
1094
- return isReasoningModel(modelId) ? "developer" : "system";
1095
- }
1096
1097
 
1097
1098
  // src/completion/openai-completion-language-model.ts
1098
1099
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
@@ -4006,7 +4007,7 @@ var OpenAIResponsesLanguageModel = class {
4006
4007
  }) {
4007
4008
  var _a, _b, _c, _d;
4008
4009
  const warnings = [];
4009
- const modelConfig = getResponsesModelConfig(this.modelId);
4010
+ const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4010
4011
  if (topK != null) {
4011
4012
  warnings.push({ type: "unsupported", feature: "topK" });
4012
4013
  }
@@ -4051,7 +4052,7 @@ var OpenAIResponsesLanguageModel = class {
4051
4052
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4052
4053
  prompt,
4053
4054
  toolNameMapping,
4054
- systemMessageMode: modelConfig.systemMessageMode,
4055
+ systemMessageMode: modelCapabilities.systemMessageMode,
4055
4056
  fileIdPrefixes: this.config.fileIdPrefixes,
4056
4057
  store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
4057
4058
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
@@ -4085,7 +4086,7 @@ var OpenAIResponsesLanguageModel = class {
4085
4086
  addInclude("code_interpreter_call.outputs");
4086
4087
  }
4087
4088
  const store = openaiOptions == null ? void 0 : openaiOptions.store;
4088
- if (store === false && modelConfig.isReasoningModel) {
4089
+ if (store === false && modelCapabilities.isReasoningModel) {
4089
4090
  addInclude("reasoning.encrypted_content");
4090
4091
  }
4091
4092
  const baseArgs = {
@@ -4127,7 +4128,7 @@ var OpenAIResponsesLanguageModel = class {
4127
4128
  top_logprobs: topLogprobs,
4128
4129
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
4129
4130
  // model-specific settings:
4130
- ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4131
+ ...modelCapabilities.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4131
4132
  reasoning: {
4132
4133
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
4133
4134
  effort: openaiOptions.reasoningEffort
@@ -4138,7 +4139,7 @@ var OpenAIResponsesLanguageModel = class {
4138
4139
  }
4139
4140
  }
4140
4141
  };
4141
- if (modelConfig.isReasoningModel) {
4142
+ if (modelCapabilities.isReasoningModel || (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters) {
4142
4143
  if (baseArgs.temperature != null) {
4143
4144
  baseArgs.temperature = void 0;
4144
4145
  warnings.push({
@@ -4171,7 +4172,7 @@ var OpenAIResponsesLanguageModel = class {
4171
4172
  });
4172
4173
  }
4173
4174
  }
4174
- if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelConfig.supportsFlexProcessing) {
4175
+ if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
4175
4176
  warnings.push({
4176
4177
  type: "unsupported",
4177
4178
  feature: "serviceTier",
@@ -4179,7 +4180,7 @@ var OpenAIResponsesLanguageModel = class {
4179
4180
  });
4180
4181
  delete baseArgs.service_tier;
4181
4182
  }
4182
- if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelConfig.supportsPriorityProcessing) {
4183
+ if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
4183
4184
  warnings.push({
4184
4185
  type: "unsupported",
4185
4186
  feature: "serviceTier",
@@ -5312,18 +5313,6 @@ function isResponseAnnotationAddedChunk(chunk) {
5312
5313
  function isErrorChunk(chunk) {
5313
5314
  return chunk.type === "error";
5314
5315
  }
5315
- function getResponsesModelConfig(modelId) {
5316
- const supportsFlexProcessing2 = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
5317
- 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");
5318
- const isReasoningModel2 = isReasoningModel(modelId);
5319
- const systemMessageMode = isReasoningModel2 ? "developer" : "system";
5320
- return {
5321
- systemMessageMode,
5322
- supportsFlexProcessing: supportsFlexProcessing2,
5323
- supportsPriorityProcessing: supportsPriorityProcessing2,
5324
- isReasoningModel: isReasoningModel2
5325
- };
5326
- }
5327
5316
  function mapWebSearchOutput(action) {
5328
5317
  var _a;
5329
5318
  switch (action.type) {