@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.
@@ -33,10 +33,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
33
33
 
34
34
  // src/openai-language-model-capabilities.ts
35
35
  function getOpenAILanguageModelCapabilities(modelId) {
36
- const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
37
- 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");
38
- const isReasoningModel = !(modelId.startsWith("gpt-3") || modelId.startsWith("gpt-4") || modelId.startsWith("chatgpt-4o") || modelId.startsWith("gpt-5-chat"));
39
- 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");
36
+ var _a, _b, _c, _d, _e;
37
+ const oSeriesVersion = getOSeriesVersion(modelId);
38
+ const gptVersion = getGptVersion(modelId);
39
+ 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);
40
+ const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
41
+ const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
42
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
43
+ const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
44
+ const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
40
45
  const systemMessageMode = isReasoningModel ? "developer" : "system";
41
46
  return {
42
47
  supportsFlexProcessing,
@@ -46,6 +51,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
46
51
  supportsNonReasoningParameters
47
52
  };
48
53
  }
54
+ function getOSeriesVersion(modelId) {
55
+ const match = /^o(\d+)(?:-|$)/.exec(modelId);
56
+ return match == null ? void 0 : Number(match[1]);
57
+ }
58
+ function getGptVersion(modelId) {
59
+ const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
60
+ if (match == null) {
61
+ return void 0;
62
+ }
63
+ return {
64
+ major: Number(match[1]),
65
+ minor: match[2] == null ? void 0 : Number(match[2]),
66
+ variant: match[3]
67
+ };
68
+ }
49
69
 
50
70
  // src/chat/convert-to-openai-chat-messages.ts
51
71
  import {
@@ -1790,12 +1810,16 @@ var modelMaxImagesPerCall = {
1790
1810
  "gpt-image-1.5": 10,
1791
1811
  "gpt-image-2": 10
1792
1812
  };
1793
- var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
1794
- "gpt-image-1",
1795
- "gpt-image-1-mini",
1796
- "gpt-image-1.5",
1797
- "gpt-image-2"
1798
- ]);
1813
+ var defaultResponseFormatPrefixes = ["gpt-image-"];
1814
+ function hasDefaultResponseFormat(modelId) {
1815
+ return defaultResponseFormatPrefixes.some(
1816
+ (prefix) => modelId.startsWith(prefix)
1817
+ );
1818
+ }
1819
+ function getMaxImagesPerCall(modelId) {
1820
+ var _a;
1821
+ return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
1822
+ }
1799
1823
  var baseImageModelOptionsObject = z9.object({
1800
1824
  /**
1801
1825
  * Quality of the generated image(s).
@@ -1854,8 +1878,7 @@ var OpenAIImageModel = class {
1854
1878
  this.specificationVersion = "v2";
1855
1879
  }
1856
1880
  get maxImagesPerCall() {
1857
- var _a;
1858
- return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
1881
+ return getMaxImagesPerCall(this.modelId);
1859
1882
  }
1860
1883
  get provider() {
1861
1884
  return this.config.provider;
@@ -1906,7 +1929,7 @@ var OpenAIImageModel = class {
1906
1929
  output_format: openaiOptions.outputFormat,
1907
1930
  output_compression: openaiOptions.outputCompression,
1908
1931
  user: openaiOptions.user,
1909
- ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1932
+ ...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
1910
1933
  },
1911
1934
  failedResponseHandler: openaiFailedResponseHandler,
1912
1935
  successfulResponseHandler: createJsonResponseHandler4(
@@ -5004,6 +5027,7 @@ export {
5004
5027
  fileSearch,
5005
5028
  fileSearchArgsSchema,
5006
5029
  fileSearchOutputSchema,
5030
+ getMaxImagesPerCall,
5007
5031
  hasDefaultResponseFormat,
5008
5032
  imageGeneration,
5009
5033
  imageGenerationArgsSchema,