@ai-sdk/openai 2.0.114 → 2.0.116

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(
@@ -3564,7 +3587,10 @@ var webSearchArgsSchema = lazySchema4(
3564
3587
  () => zodSchema17(
3565
3588
  z19.object({
3566
3589
  externalWebAccess: z19.boolean().optional(),
3567
- filters: z19.object({ allowedDomains: z19.array(z19.string()).optional() }).optional(),
3590
+ filters: z19.object({
3591
+ allowedDomains: z19.array(z19.string()).optional(),
3592
+ blockedDomains: z19.array(z19.string()).optional()
3593
+ }).optional(),
3568
3594
  searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
3569
3595
  userLocation: z19.object({
3570
3596
  type: z19.literal("approximate"),
@@ -3610,6 +3636,7 @@ var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3610
3636
  inputSchema: webSearchInputSchema,
3611
3637
  outputSchema: webSearchOutputSchema
3612
3638
  });
3639
+ var webSearch = (args = {}) => webSearchToolFactory(args);
3613
3640
 
3614
3641
  // src/tool/web-search-preview.ts
3615
3642
  import {
@@ -3771,7 +3798,10 @@ async function prepareResponsesTools({
3771
3798
  });
3772
3799
  openaiTools.push({
3773
3800
  type: "web_search",
3774
- filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
3801
+ filters: args.filters != null ? {
3802
+ allowed_domains: args.filters.allowedDomains,
3803
+ blocked_domains: args.filters.blockedDomains
3804
+ } : void 0,
3775
3805
  external_web_access: args.externalWebAccess,
3776
3806
  search_context_size: args.searchContextSize,
3777
3807
  user_location: args.userLocation
@@ -5004,6 +5034,7 @@ export {
5004
5034
  fileSearch,
5005
5035
  fileSearchArgsSchema,
5006
5036
  fileSearchOutputSchema,
5037
+ getMaxImagesPerCall,
5007
5038
  hasDefaultResponseFormat,
5008
5039
  imageGeneration,
5009
5040
  imageGenerationArgsSchema,
@@ -5016,8 +5047,12 @@ export {
5016
5047
  openaiImageModelGenerationOptions,
5017
5048
  openaiImageModelOptions,
5018
5049
  openaiSpeechProviderOptionsSchema,
5050
+ webSearch,
5051
+ webSearchArgsSchema,
5052
+ webSearchOutputSchema,
5019
5053
  webSearchPreview,
5020
5054
  webSearchPreviewArgsSchema,
5021
- webSearchPreviewInputSchema
5055
+ webSearchPreviewInputSchema,
5056
+ webSearchToolFactory
5022
5057
  };
5023
5058
  //# sourceMappingURL=index.mjs.map