@ai-sdk/openai 2.0.113 → 2.0.115

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
@@ -41,10 +41,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
41
41
 
42
42
  // src/openai-language-model-capabilities.ts
43
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") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || 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") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4") || modelId.startsWith("gpt-5.6");
44
+ var _a, _b, _c, _d, _e;
45
+ const oSeriesVersion = getOSeriesVersion(modelId);
46
+ const gptVersion = getGptVersion(modelId);
47
+ 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);
48
+ const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
49
+ const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
50
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
51
+ 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);
48
53
  const systemMessageMode = isReasoningModel ? "developer" : "system";
49
54
  return {
50
55
  supportsFlexProcessing,
@@ -54,6 +59,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
54
59
  supportsNonReasoningParameters
55
60
  };
56
61
  }
62
+ function getOSeriesVersion(modelId) {
63
+ const match = /^o(\d+)(?:-|$)/.exec(modelId);
64
+ return match == null ? void 0 : Number(match[1]);
65
+ }
66
+ function getGptVersion(modelId) {
67
+ const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
68
+ if (match == null) {
69
+ return void 0;
70
+ }
71
+ return {
72
+ major: Number(match[1]),
73
+ minor: match[2] == null ? void 0 : Number(match[2]),
74
+ variant: match[3]
75
+ };
76
+ }
57
77
 
58
78
  // src/chat/convert-to-openai-chat-messages.ts
59
79
  import {
@@ -1798,12 +1818,16 @@ var modelMaxImagesPerCall = {
1798
1818
  "gpt-image-1.5": 10,
1799
1819
  "gpt-image-2": 10
1800
1820
  };
1801
- var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
1802
- "gpt-image-1",
1803
- "gpt-image-1-mini",
1804
- "gpt-image-1.5",
1805
- "gpt-image-2"
1806
- ]);
1821
+ var defaultResponseFormatPrefixes = ["gpt-image-"];
1822
+ function hasDefaultResponseFormat(modelId) {
1823
+ return defaultResponseFormatPrefixes.some(
1824
+ (prefix) => modelId.startsWith(prefix)
1825
+ );
1826
+ }
1827
+ function getMaxImagesPerCall(modelId) {
1828
+ var _a;
1829
+ return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
1830
+ }
1807
1831
  var baseImageModelOptionsObject = z9.object({
1808
1832
  /**
1809
1833
  * Quality of the generated image(s).
@@ -1862,8 +1886,7 @@ var OpenAIImageModel = class {
1862
1886
  this.specificationVersion = "v2";
1863
1887
  }
1864
1888
  get maxImagesPerCall() {
1865
- var _a;
1866
- return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
1889
+ return getMaxImagesPerCall(this.modelId);
1867
1890
  }
1868
1891
  get provider() {
1869
1892
  return this.config.provider;
@@ -1914,7 +1937,7 @@ var OpenAIImageModel = class {
1914
1937
  output_format: openaiOptions.outputFormat,
1915
1938
  output_compression: openaiOptions.outputCompression,
1916
1939
  user: openaiOptions.user,
1917
- ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1940
+ ...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
1918
1941
  },
1919
1942
  failedResponseHandler: openaiFailedResponseHandler,
1920
1943
  successfulResponseHandler: createJsonResponseHandler4(
@@ -5068,7 +5091,7 @@ var OpenAITranscriptionModel = class {
5068
5091
  };
5069
5092
 
5070
5093
  // src/version.ts
5071
- var VERSION = true ? "2.0.113" : "0.0.0-test";
5094
+ var VERSION = true ? "2.0.115" : "0.0.0-test";
5072
5095
 
5073
5096
  // src/openai-provider.ts
5074
5097
  function createOpenAI(options = {}) {