@ai-sdk/openai 4.0.18 → 4.0.19

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.19
4
+
5
+ ### Patch Changes
6
+
7
+ - 34c53c0: Apply reasoning, service tier, and image defaults to recognizable future OpenAI model family versions.
8
+
3
9
  ## 4.0.18
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -43,10 +43,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
43
43
 
44
44
  // src/openai-language-model-capabilities.ts
45
45
  function getOpenAILanguageModelCapabilities(modelId) {
46
- const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
47
- const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
48
- const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
49
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4") || modelId.startsWith("gpt-5.5") || modelId.startsWith("gpt-5.6");
46
+ var _a, _b, _c, _d, _e;
47
+ const oSeriesVersion = getOSeriesVersion(modelId);
48
+ const gptVersion = getGptVersion(modelId);
49
+ const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a.startsWith("chat")) != null ? _b : false);
50
+ const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
51
+ const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
52
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
53
+ 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);
50
55
  const systemMessageMode = isReasoningModel ? "developer" : "system";
51
56
  return {
52
57
  supportsFlexProcessing,
@@ -56,6 +61,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
56
61
  supportsNonReasoningParameters
57
62
  };
58
63
  }
64
+ function getOSeriesVersion(modelId) {
65
+ const match = /^o(\d+)(?:-|$)/.exec(modelId);
66
+ return match == null ? void 0 : Number(match[1]);
67
+ }
68
+ function getGptVersion(modelId) {
69
+ const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
70
+ if (match == null) {
71
+ return void 0;
72
+ }
73
+ return {
74
+ major: Number(match[1]),
75
+ minor: match[2] == null ? void 0 : Number(match[2]),
76
+ variant: match[3]
77
+ };
78
+ }
59
79
 
60
80
  // src/openai-stream-error.ts
61
81
  import { APICallError } from "@ai-sdk/provider";
@@ -2136,18 +2156,16 @@ var modelMaxImagesPerCall = {
2136
2156
  "gpt-image-2": 10,
2137
2157
  "chatgpt-image-latest": 10
2138
2158
  };
2139
- var defaultResponseFormatPrefixes = [
2140
- "chatgpt-image-",
2141
- "gpt-image-1-mini",
2142
- "gpt-image-1.5",
2143
- "gpt-image-1",
2144
- "gpt-image-2"
2145
- ];
2159
+ var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
2146
2160
  function hasDefaultResponseFormat(modelId) {
2147
2161
  return defaultResponseFormatPrefixes.some(
2148
2162
  (prefix) => modelId.startsWith(prefix)
2149
2163
  );
2150
2164
  }
2165
+ function getMaxImagesPerCall(modelId) {
2166
+ var _a;
2167
+ return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
2168
+ }
2151
2169
  var baseImageModelOptionsObject = z11.object({
2152
2170
  /**
2153
2171
  * Quality of the generated image(s).
@@ -2225,8 +2243,7 @@ var OpenAIImageModel = class _OpenAIImageModel {
2225
2243
  return new _OpenAIImageModel(options.modelId, options.config);
2226
2244
  }
2227
2245
  get maxImagesPerCall() {
2228
- var _a;
2229
- return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
2246
+ return getMaxImagesPerCall(this.modelId);
2230
2247
  }
2231
2248
  get provider() {
2232
2249
  return this.config.provider;
@@ -8873,7 +8890,7 @@ var OpenAISkills = class {
8873
8890
  };
8874
8891
 
8875
8892
  // src/version.ts
8876
- var VERSION = true ? "4.0.18" : "0.0.0-test";
8893
+ var VERSION = true ? "4.0.19" : "0.0.0-test";
8877
8894
 
8878
8895
  // src/openai-provider.ts
8879
8896
  function createOpenAI(options = {}) {