@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.116
4
+
5
+ ### Patch Changes
6
+
7
+ - 8591016: Add blocked domain filters to the OpenAI and Azure Responses API web search tools.
8
+
9
+ ## 2.0.115
10
+
11
+ ### Patch Changes
12
+
13
+ - 11a02d9: Apply reasoning, service tier, and image defaults to recognizable future OpenAI model family versions.
14
+
3
15
  ## 2.0.114
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -113,8 +113,15 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFa
113
113
  * Allowed domains for the search.
114
114
  * If not provided, all domains are allowed.
115
115
  * Subdomains of the provided domains are allowed as well.
116
+ * Omit the HTTP or HTTPS prefix. Maximum 100 domains.
116
117
  */
117
118
  allowedDomains?: string[];
119
+ /**
120
+ * Blocked domains for the search.
121
+ * Subdomains of the provided domains are blocked as well.
122
+ * Omit the HTTP or HTTPS prefix. Maximum 100 domains.
123
+ */
124
+ blockedDomains?: string[];
118
125
  };
119
126
  /**
120
127
  * Search context size to use for the web search.
package/dist/index.d.ts CHANGED
@@ -113,8 +113,15 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFa
113
113
  * Allowed domains for the search.
114
114
  * If not provided, all domains are allowed.
115
115
  * Subdomains of the provided domains are allowed as well.
116
+ * Omit the HTTP or HTTPS prefix. Maximum 100 domains.
116
117
  */
117
118
  allowedDomains?: string[];
119
+ /**
120
+ * Blocked domains for the search.
121
+ * Subdomains of the provided domains are blocked as well.
122
+ * Omit the HTTP or HTTPS prefix. Maximum 100 domains.
123
+ */
124
+ blockedDomains?: string[];
118
125
  };
119
126
  /**
120
127
  * Search context size to use for the web search.
package/dist/index.js CHANGED
@@ -54,10 +54,15 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
54
54
 
55
55
  // src/openai-language-model-capabilities.ts
56
56
  function getOpenAILanguageModelCapabilities(modelId) {
57
- const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
58
- 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");
59
- const isReasoningModel = !(modelId.startsWith("gpt-3") || modelId.startsWith("gpt-4") || modelId.startsWith("chatgpt-4o") || modelId.startsWith("gpt-5-chat"));
60
- 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");
57
+ var _a, _b, _c, _d, _e;
58
+ const oSeriesVersion = getOSeriesVersion(modelId);
59
+ const gptVersion = getGptVersion(modelId);
60
+ 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);
61
+ const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
62
+ const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
63
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
64
+ const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
65
+ const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
61
66
  const systemMessageMode = isReasoningModel ? "developer" : "system";
62
67
  return {
63
68
  supportsFlexProcessing,
@@ -67,6 +72,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
67
72
  supportsNonReasoningParameters
68
73
  };
69
74
  }
75
+ function getOSeriesVersion(modelId) {
76
+ const match = /^o(\d+)(?:-|$)/.exec(modelId);
77
+ return match == null ? void 0 : Number(match[1]);
78
+ }
79
+ function getGptVersion(modelId) {
80
+ const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
81
+ if (match == null) {
82
+ return void 0;
83
+ }
84
+ return {
85
+ major: Number(match[1]),
86
+ minor: match[2] == null ? void 0 : Number(match[2]),
87
+ variant: match[3]
88
+ };
89
+ }
70
90
 
71
91
  // src/chat/convert-to-openai-chat-messages.ts
72
92
  var import_provider = require("@ai-sdk/provider");
@@ -1768,12 +1788,16 @@ var modelMaxImagesPerCall = {
1768
1788
  "gpt-image-1.5": 10,
1769
1789
  "gpt-image-2": 10
1770
1790
  };
1771
- var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
1772
- "gpt-image-1",
1773
- "gpt-image-1-mini",
1774
- "gpt-image-1.5",
1775
- "gpt-image-2"
1776
- ]);
1791
+ var defaultResponseFormatPrefixes = ["gpt-image-"];
1792
+ function hasDefaultResponseFormat(modelId) {
1793
+ return defaultResponseFormatPrefixes.some(
1794
+ (prefix) => modelId.startsWith(prefix)
1795
+ );
1796
+ }
1797
+ function getMaxImagesPerCall(modelId) {
1798
+ var _a;
1799
+ return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
1800
+ }
1777
1801
  var baseImageModelOptionsObject = import_v49.z.object({
1778
1802
  /**
1779
1803
  * Quality of the generated image(s).
@@ -1832,8 +1856,7 @@ var OpenAIImageModel = class {
1832
1856
  this.specificationVersion = "v2";
1833
1857
  }
1834
1858
  get maxImagesPerCall() {
1835
- var _a;
1836
- return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
1859
+ return getMaxImagesPerCall(this.modelId);
1837
1860
  }
1838
1861
  get provider() {
1839
1862
  return this.config.provider;
@@ -1884,7 +1907,7 @@ var OpenAIImageModel = class {
1884
1907
  output_format: openaiOptions.outputFormat,
1885
1908
  output_compression: openaiOptions.outputCompression,
1886
1909
  user: openaiOptions.user,
1887
- ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1910
+ ...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
1888
1911
  },
1889
1912
  failedResponseHandler: openaiFailedResponseHandler,
1890
1913
  successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
@@ -2115,7 +2138,10 @@ var webSearchArgsSchema = (0, import_provider_utils19.lazySchema)(
2115
2138
  () => (0, import_provider_utils19.zodSchema)(
2116
2139
  import_v414.z.object({
2117
2140
  externalWebAccess: import_v414.z.boolean().optional(),
2118
- filters: import_v414.z.object({ allowedDomains: import_v414.z.array(import_v414.z.string()).optional() }).optional(),
2141
+ filters: import_v414.z.object({
2142
+ allowedDomains: import_v414.z.array(import_v414.z.string()).optional(),
2143
+ blockedDomains: import_v414.z.array(import_v414.z.string()).optional()
2144
+ }).optional(),
2119
2145
  searchContextSize: import_v414.z.enum(["low", "medium", "high"]).optional(),
2120
2146
  userLocation: import_v414.z.object({
2121
2147
  type: import_v414.z.literal("approximate"),
@@ -3402,7 +3428,10 @@ async function prepareResponsesTools({
3402
3428
  });
3403
3429
  openaiTools2.push({
3404
3430
  type: "web_search",
3405
- filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
3431
+ filters: args.filters != null ? {
3432
+ allowed_domains: args.filters.allowedDomains,
3433
+ blocked_domains: args.filters.blockedDomains
3434
+ } : void 0,
3406
3435
  external_web_access: args.externalWebAccess,
3407
3436
  search_context_size: args.searchContextSize,
3408
3437
  user_location: args.userLocation
@@ -4973,7 +5002,7 @@ var OpenAITranscriptionModel = class {
4973
5002
  };
4974
5003
 
4975
5004
  // src/version.ts
4976
- var VERSION = true ? "2.0.114" : "0.0.0-test";
5005
+ var VERSION = true ? "2.0.116" : "0.0.0-test";
4977
5006
 
4978
5007
  // src/openai-provider.ts
4979
5008
  function createOpenAI(options = {}) {