@ai-sdk/gateway 3.0.218 → 3.0.220

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.
@@ -889,7 +889,7 @@ for await (const part of result.stream) {
889
889
 
890
890
  #### Parallel Search
891
891
 
892
- The Parallel Search tool enables models to search the web using [Parallel AI's Search API](https://docs.parallel.ai/api-reference/search-beta/search). This tool is optimized for LLM consumption, returning relevant excerpts from web pages that can replace multiple keyword searches with a single call.
892
+ The Parallel Search tool enables models to search the web using [Parallel AI's Search API](https://docs.parallel.ai/api-reference/search/search). The model provides a research objective and a few keyword queries, and the tool returns relevant excerpts from web pages, optimized for LLM consumption.
893
893
 
894
894
  ```ts
895
895
  import { gateway, generateText } from "ai";
@@ -917,7 +917,8 @@ const result = await generateText({
917
917
  prompt: "Find detailed information about TypeScript 5.0 features.",
918
918
  tools: {
919
919
  parallel_search: gateway.tools.parallelSearch({
920
- mode: "agentic",
920
+ mode: "advanced",
921
+ location: "us",
921
922
  maxResults: 5,
922
923
  sourcePolicy: {
923
924
  includeDomains: ["typescriptlang.org", "github.com"],
@@ -936,12 +937,16 @@ console.log("Tool results:", JSON.stringify(result.toolResults, null, 2));
936
937
 
937
938
  The Parallel Search tool supports the following optional configuration options:
938
939
 
939
- - **mode** _'one-shot' | 'agentic'_
940
+ - **mode** _'turbo' | 'fast' | 'basic' | 'advanced'_
940
941
 
941
- Mode preset for different use cases:
942
+ Search mode. Defaults to `'basic'`. See the [AI Gateway web search docs](https://vercel.com/docs/ai-gateway/models-and-providers/web-search#using-parallel-search) for pricing.
942
943
 
943
- - `'one-shot'` - Comprehensive results with longer excerpts for single-response answers (default)
944
- - `'agentic'` - Concise, token-efficient results optimized for multi-step agentic workflows
944
+ - `'turbo'` - Lowest latency, shorter excerpts. Supports English and Japanese only.
945
+ - `'fast'` - Low latency, shorter excerpts.
946
+ - `'basic'` - Balanced latency and excerpt depth (default).
947
+ - `'advanced'` - Most thorough retrieval, higher latency.
948
+
949
+ `'one-shot'` and `'agentic'` are deprecated but still accepted: `'one-shot'` runs as `'basic'` and `'agentic'` runs as `'advanced'`.
945
950
 
946
951
  - **maxResults** _number_
947
952
 
@@ -951,22 +956,36 @@ The Parallel Search tool supports the following optional configuration options:
951
956
 
952
957
  Source policy for controlling which domains to include/exclude:
953
958
 
954
- - `includeDomains` - List of domains to include in search results
955
- - `excludeDomains` - List of domains to exclude from search results
956
- - `afterDate` - Only include results published after this date (ISO 8601 format)
959
+ - `includeDomains` - Domains or domain/path prefixes to include, such as `'wikipedia.org'` or `'docs.python.org/3'`. When set, `excludeDomains` is ignored.
960
+ - `excludeDomains` - Domains or domain/path prefixes to exclude
961
+ - `afterDate` - Only include results published on or after this date (`YYYY-MM-DD`)
962
+
963
+ The include and exclude lists can hold up to 200 entries combined.
964
+
965
+ - **maxCharsTotal** _number_
966
+
967
+ Maximum total characters across all result excerpts.
957
968
 
958
969
  - **excerpts** _object_
959
970
 
960
971
  Excerpt configuration for controlling result length:
961
972
 
962
973
  - `maxCharsPerResult` - Maximum characters per result
963
- - `maxCharsTotal` - Maximum total characters across all results
974
+ - `maxCharsTotal` - Deprecated; use the top-level `maxCharsTotal`
964
975
 
965
976
  - **fetchPolicy** _object_
966
977
 
967
978
  Fetch policy for controlling content freshness:
968
979
 
969
- - `maxAgeSeconds` - Maximum age in seconds for cached content (set to 0 for always fresh)
980
+ - `maxAgeSeconds` - Maximum age of cached content, in seconds, before a live fetch is attempted. Minimum 600; lower values are raised to 600.
981
+ - `timeoutSeconds` - Timeout for a live fetch, in seconds. The gateway caps it to stay within its own tool timeout.
982
+ - `disableCacheFallback` - Return an error instead of older cached content when a live fetch fails. Defaults to `false`.
983
+
984
+ - **location** _string_
985
+
986
+ ISO 3166-1 alpha-2 country code to localize results, such as `'us'`. Invalid codes are ignored with a warning.
987
+
988
+ Each tool result contains a `search_id` and `results`, ordered by decreasing relevance, and may include a `session_id`. Each result has a `url`, a `title`, a `publish_date` (both may be `null`), and `excerpts` (an array of markdown strings). The result can also include `warnings`, for example when an invalid `location` is ignored.
970
989
 
971
990
  The tool works with both `generateText` and `streamText`:
972
991
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "3.0.218",
4
+ "version": "3.0.220",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@vercel/oidc": "3.2.0",
34
34
  "@ai-sdk/provider": "3.0.19",
35
- "@ai-sdk/provider-utils": "4.0.61"
35
+ "@ai-sdk/provider-utils": "4.0.62"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "18.15.11",
@@ -97,29 +97,30 @@ export class GatewayEmbeddingModel implements EmbeddingModelV3 {
97
97
  }
98
98
  }
99
99
 
100
- const gatewayEmbeddingWarningSchema = z.discriminatedUnion('type', [
101
- z.object({
102
- type: z.literal('unsupported'),
103
- feature: z.string(),
104
- details: z.string().optional(),
105
- }),
106
- z.object({
107
- type: z.literal('compatibility'),
108
- feature: z.string(),
109
- details: z.string().optional(),
110
- }),
111
- z.object({
112
- type: z.literal('other'),
113
- message: z.string(),
114
- }),
115
- ]);
100
+ const gatewayEmbeddingWarningSchema = () =>
101
+ z.discriminatedUnion('type', [
102
+ z.object({
103
+ type: z.literal('unsupported'),
104
+ feature: z.string(),
105
+ details: z.string().optional(),
106
+ }),
107
+ z.object({
108
+ type: z.literal('compatibility'),
109
+ feature: z.string(),
110
+ details: z.string().optional(),
111
+ }),
112
+ z.object({
113
+ type: z.literal('other'),
114
+ message: z.string(),
115
+ }),
116
+ ]);
116
117
 
117
118
  const gatewayEmbeddingResponseSchema = lazySchema(() =>
118
119
  zodSchema(
119
120
  z.object({
120
121
  embeddings: z.array(z.array(z.number())),
121
122
  usage: z.object({ tokens: z.number() }).nullish(),
122
- warnings: z.array(gatewayEmbeddingWarningSchema).optional(),
123
+ warnings: z.array(gatewayEmbeddingWarningSchema()).optional(),
123
124
  providerMetadata: z
124
125
  .record(z.string(), z.record(z.string(), z.unknown()))
125
126
  .optional(),
@@ -4,6 +4,8 @@ import type {
4
4
  ImageModelV3ProviderMetadata,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
+ lazySchema,
8
+ zodSchema,
7
9
  combineHeaders,
8
10
  convertUint8ArrayToBase64,
9
11
  createJsonErrorResponseHandler,
@@ -135,46 +137,53 @@ function maybeEncodeImageFile(file: ImageModelV3File) {
135
137
  return file;
136
138
  }
137
139
 
138
- const providerMetadataEntrySchema = z
139
- .object({
140
- images: z.array(z.unknown()).optional(),
141
- })
142
- .catchall(z.unknown());
140
+ const providerMetadataEntrySchema = () =>
141
+ z
142
+ .object({
143
+ images: z.array(z.unknown()).optional(),
144
+ })
145
+ .catchall(z.unknown());
143
146
 
144
- const gatewayImageWarningSchema = z.discriminatedUnion('type', [
145
- z.object({
146
- type: z.literal('unsupported'),
147
- feature: z.string(),
148
- details: z.string().optional(),
149
- }),
150
- z.object({
151
- type: z.literal('compatibility'),
152
- feature: z.string(),
153
- details: z.string().optional(),
154
- }),
155
- z.object({
156
- type: z.literal('deprecated'),
157
- setting: z.string(),
158
- message: z.string(),
159
- }),
160
- z.object({
161
- type: z.literal('other'),
162
- message: z.string(),
163
- }),
164
- ]);
147
+ const gatewayImageWarningSchema = () =>
148
+ z.discriminatedUnion('type', [
149
+ z.object({
150
+ type: z.literal('unsupported'),
151
+ feature: z.string(),
152
+ details: z.string().optional(),
153
+ }),
154
+ z.object({
155
+ type: z.literal('compatibility'),
156
+ feature: z.string(),
157
+ details: z.string().optional(),
158
+ }),
159
+ z.object({
160
+ type: z.literal('deprecated'),
161
+ setting: z.string(),
162
+ message: z.string(),
163
+ }),
164
+ z.object({
165
+ type: z.literal('other'),
166
+ message: z.string(),
167
+ }),
168
+ ]);
165
169
 
166
- const gatewayImageUsageSchema = z.object({
167
- inputTokens: z.number().nullish(),
168
- outputTokens: z.number().nullish(),
169
- totalTokens: z.number().nullish(),
170
- });
170
+ const gatewayImageUsageSchema = () =>
171
+ z.object({
172
+ inputTokens: z.number().nullish(),
173
+ outputTokens: z.number().nullish(),
174
+ totalTokens: z.number().nullish(),
175
+ });
171
176
 
172
- const gatewayImageResponseSchema = z.object({
173
- images: z.array(z.string()), // Always base64 strings over the wire
174
- isRetryable: z.boolean().optional(),
175
- warnings: z.array(gatewayImageWarningSchema).optional(),
176
- providerMetadata: z
177
- .record(z.string(), providerMetadataEntrySchema)
178
- .optional(),
179
- usage: gatewayImageUsageSchema.optional(),
180
- });
177
+ const gatewayImageResponseSchema = lazySchema(() =>
178
+ zodSchema(
179
+ z.object({
180
+ images: z.array(z.string()), // Always base64 strings over the wire
181
+ isRetryable: z.boolean().optional(),
182
+ warnings: z.array(gatewayImageWarningSchema()).optional(),
183
+ providerMetadata: z
184
+ .record(z.string(), providerMetadataEntrySchema())
185
+ .optional(),
186
+ usage: gatewayImageUsageSchema().optional(),
187
+ }),
188
+ ),
189
+ );
@@ -113,6 +113,7 @@ export type GatewayModelId =
113
113
  | 'google/gemma-4-31b-it'
114
114
  | 'inception/mercury-2'
115
115
  | 'inception/mercury-2.5'
116
+ | 'inception/mercury-3'
116
117
  | 'inception/mercury-coder-small'
117
118
  | 'inclusionai/ling-3.0-flash'
118
119
  | 'inclusionai/ling-3.0-flash-fin'
@@ -270,6 +271,8 @@ export type GatewayModelId =
270
271
  | 'sakana/fugu-ultra'
271
272
  | 'sakana/fugu-ultra-v2'
272
273
  | 'sakana/namazu'
274
+ | 'scaledown/scaledown-extract-1'
275
+ | 'scaledown/scaledown-summarize-1'
273
276
  | 'spacexai/grok-4.1-fast-non-reasoning'
274
277
  | 'spacexai/grok-4.1-fast-reasoning'
275
278
  | 'spacexai/grok-4.20-multi-agent'
@@ -287,7 +290,6 @@ export type GatewayModelId =
287
290
  | 'spacexai/grok-4.6'
288
291
  | 'spacexai/grok-4.7'
289
292
  | 'spacexai/grok-build-0.1'
290
- | 'stealth/cat-jam'
291
293
  | 'stealth/glyph-cluster'
292
294
  | 'stepfun/step-3.7-flash'
293
295
  | 'stepfun/step-5-preview'
@@ -2,6 +2,8 @@ export type GatewayRerankingModelId =
2
2
  | 'cohere/rerank-v3.5'
3
3
  | 'cohere/rerank-v4-fast'
4
4
  | 'cohere/rerank-v4-pro'
5
+ | 'cohere/rerank-v5-fast'
6
+ | 'cohere/rerank-v5-pro'
5
7
  | 'voyage/rerank-2.5'
6
8
  | 'voyage/rerank-2.5-lite'
7
9
  | 'voyage/rerank-3'
@@ -98,22 +98,23 @@ export class GatewayRerankingModel implements RerankingModelV3 {
98
98
  }
99
99
  }
100
100
 
101
- const gatewayRerankingWarningSchema = z.discriminatedUnion('type', [
102
- z.object({
103
- type: z.literal('unsupported'),
104
- feature: z.string(),
105
- details: z.string().optional(),
106
- }),
107
- z.object({
108
- type: z.literal('compatibility'),
109
- feature: z.string(),
110
- details: z.string().optional(),
111
- }),
112
- z.object({
113
- type: z.literal('other'),
114
- message: z.string(),
115
- }),
116
- ]);
101
+ const gatewayRerankingWarningSchema = () =>
102
+ z.discriminatedUnion('type', [
103
+ z.object({
104
+ type: z.literal('unsupported'),
105
+ feature: z.string(),
106
+ details: z.string().optional(),
107
+ }),
108
+ z.object({
109
+ type: z.literal('compatibility'),
110
+ feature: z.string(),
111
+ details: z.string().optional(),
112
+ }),
113
+ z.object({
114
+ type: z.literal('other'),
115
+ message: z.string(),
116
+ }),
117
+ ]);
117
118
 
118
119
  const gatewayRerankingResponseSchema = lazySchema(() =>
119
120
  zodSchema(
@@ -124,7 +125,7 @@ const gatewayRerankingResponseSchema = lazySchema(() =>
124
125
  relevanceScore: z.number(),
125
126
  }),
126
127
  ),
127
- warnings: z.array(gatewayRerankingWarningSchema).optional(),
128
+ warnings: z.array(gatewayRerankingWarningSchema()).optional(),
128
129
  providerMetadata: z
129
130
  .record(z.string(), z.record(z.string(), z.unknown()))
130
131
  .optional(),
@@ -9,6 +9,7 @@ export type GatewaySpeechModelId =
9
9
  | 'microsoft/mai-voice-2-flash'
10
10
  | 'microsoft/mai-voice-2.1'
11
11
  | 'microsoft/mai-voice-2.1-flash'
12
+ | 'mistral/voxtral-mini-tts-3'
12
13
  | 'openai/tts-1'
13
14
  | 'openai/tts-1-hd'
14
15
  | 'spacexai/grok-tts'
@@ -1,5 +1,7 @@
1
1
  import type { SharedV3ProviderMetadata, SpeechModelV3 } from '@ai-sdk/provider';
2
2
  import {
3
+ lazySchema,
4
+ zodSchema,
3
5
  combineHeaders,
4
6
  createJsonErrorResponseHandler,
5
7
  createJsonResponseHandler,
@@ -108,34 +110,39 @@ export class GatewaySpeechModel implements SpeechModelV3 {
108
110
  }
109
111
  }
110
112
 
111
- const providerMetadataEntrySchema = z.object({}).catchall(z.unknown());
113
+ const providerMetadataEntrySchema = () => z.object({}).catchall(z.unknown());
112
114
 
113
- const gatewaySpeechWarningSchema = z.discriminatedUnion('type', [
114
- z.object({
115
- type: z.literal('unsupported'),
116
- feature: z.string(),
117
- details: z.string().optional(),
118
- }),
119
- z.object({
120
- type: z.literal('compatibility'),
121
- feature: z.string(),
122
- details: z.string().optional(),
123
- }),
124
- z.object({
125
- type: z.literal('deprecated'),
126
- setting: z.string(),
127
- message: z.string(),
128
- }),
129
- z.object({
130
- type: z.literal('other'),
131
- message: z.string(),
132
- }),
133
- ]);
115
+ const gatewaySpeechWarningSchema = () =>
116
+ z.discriminatedUnion('type', [
117
+ z.object({
118
+ type: z.literal('unsupported'),
119
+ feature: z.string(),
120
+ details: z.string().optional(),
121
+ }),
122
+ z.object({
123
+ type: z.literal('compatibility'),
124
+ feature: z.string(),
125
+ details: z.string().optional(),
126
+ }),
127
+ z.object({
128
+ type: z.literal('deprecated'),
129
+ setting: z.string(),
130
+ message: z.string(),
131
+ }),
132
+ z.object({
133
+ type: z.literal('other'),
134
+ message: z.string(),
135
+ }),
136
+ ]);
134
137
 
135
- const gatewaySpeechResponseSchema = z.object({
136
- audio: z.string(),
137
- warnings: z.array(gatewaySpeechWarningSchema).optional(),
138
- providerMetadata: z
139
- .record(z.string(), providerMetadataEntrySchema)
140
- .optional(),
141
- });
138
+ const gatewaySpeechResponseSchema = lazySchema(() =>
139
+ zodSchema(
140
+ z.object({
141
+ audio: z.string(),
142
+ warnings: z.array(gatewaySpeechWarningSchema()).optional(),
143
+ providerMetadata: z
144
+ .record(z.string(), providerMetadataEntrySchema())
145
+ .optional(),
146
+ }),
147
+ ),
148
+ );
@@ -4,6 +4,8 @@ export type GatewayTranscriptionModelId =
4
4
  | 'google/gemini-3.5-transcribe-live'
5
5
  | 'microsoft/mai-transcribe-2'
6
6
  | 'microsoft/mai-transcribe-2-streaming'
7
+ | 'mistral/voxtral-mini-transcribe-3'
8
+ | 'mistral/voxtral-small-transcribe-3'
7
9
  | 'openai/gpt-4o-mini-transcribe'
8
10
  | 'openai/gpt-4o-transcribe'
9
11
  | 'openai/gpt-realtime-whisper'
@@ -3,6 +3,8 @@ import type {
3
3
  TranscriptionModelV3,
4
4
  } from '@ai-sdk/provider';
5
5
  import {
6
+ lazySchema,
7
+ zodSchema,
6
8
  combineHeaders,
7
9
  convertUint8ArrayToBase64,
8
10
  createJsonErrorResponseHandler,
@@ -110,45 +112,50 @@ export class GatewayTranscriptionModel implements TranscriptionModelV3 {
110
112
  }
111
113
  }
112
114
 
113
- const providerMetadataEntrySchema = z.object({}).catchall(z.unknown());
115
+ const providerMetadataEntrySchema = () => z.object({}).catchall(z.unknown());
114
116
 
115
- const gatewayTranscriptionWarningSchema = z.discriminatedUnion('type', [
116
- z.object({
117
- type: z.literal('unsupported'),
118
- feature: z.string(),
119
- details: z.string().optional(),
120
- }),
121
- z.object({
122
- type: z.literal('compatibility'),
123
- feature: z.string(),
124
- details: z.string().optional(),
125
- }),
126
- z.object({
127
- type: z.literal('deprecated'),
128
- setting: z.string(),
129
- message: z.string(),
130
- }),
131
- z.object({
132
- type: z.literal('other'),
133
- message: z.string(),
134
- }),
135
- ]);
117
+ const gatewayTranscriptionWarningSchema = () =>
118
+ z.discriminatedUnion('type', [
119
+ z.object({
120
+ type: z.literal('unsupported'),
121
+ feature: z.string(),
122
+ details: z.string().optional(),
123
+ }),
124
+ z.object({
125
+ type: z.literal('compatibility'),
126
+ feature: z.string(),
127
+ details: z.string().optional(),
128
+ }),
129
+ z.object({
130
+ type: z.literal('deprecated'),
131
+ setting: z.string(),
132
+ message: z.string(),
133
+ }),
134
+ z.object({
135
+ type: z.literal('other'),
136
+ message: z.string(),
137
+ }),
138
+ ]);
136
139
 
137
- const gatewayTranscriptionResponseSchema = z.object({
138
- text: z.string(),
139
- segments: z
140
- .array(
141
- z.object({
142
- text: z.string(),
143
- startSecond: z.number(),
144
- endSecond: z.number(),
145
- }),
146
- )
147
- .optional(),
148
- language: z.string().nullish(),
149
- durationInSeconds: z.number().nullish(),
150
- warnings: z.array(gatewayTranscriptionWarningSchema).optional(),
151
- providerMetadata: z
152
- .record(z.string(), providerMetadataEntrySchema)
153
- .optional(),
154
- });
140
+ const gatewayTranscriptionResponseSchema = lazySchema(() =>
141
+ zodSchema(
142
+ z.object({
143
+ text: z.string(),
144
+ segments: z
145
+ .array(
146
+ z.object({
147
+ text: z.string(),
148
+ startSecond: z.number(),
149
+ endSecond: z.number(),
150
+ }),
151
+ )
152
+ .optional(),
153
+ language: z.string().nullish(),
154
+ durationInSeconds: z.number().nullish(),
155
+ warnings: z.array(gatewayTranscriptionWarningSchema()).optional(),
156
+ providerMetadata: z
157
+ .record(z.string(), providerMetadataEntrySchema())
158
+ .optional(),
159
+ }),
160
+ ),
161
+ );