@ai-sdk/gateway 4.0.87 → 4.0.89

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.
@@ -220,7 +220,7 @@ the failure without inspecting the Gateway's serialized error payload.
220
220
  </Note>
221
221
 
222
222
  AI Gateway supports durable text batches through `experimental_startBatch`,
223
- `experimental_getBatchStatus`, and `experimental_getBatchResults`. See
223
+ `experimental_getBatchStatus`, `experimental_getBatchResults`, and `experimental_cancelBatch`. See
224
224
  [Batch](/docs/ai-sdk-core/batch) for the provider-agnostic workflow,
225
225
  and the [AI Gateway batch processing guide](https://vercel.com/docs/ai-gateway/models-and-providers/batch-processing)
226
226
  for supported models, limits, and Gateway-specific behavior.
@@ -414,6 +414,19 @@ Each request specifies its `type` and `model`. AI Gateway currently requires
414
414
  every text request in a batch to use the same model and throws before submission
415
415
  when the models differ.
416
416
 
417
+ ### Cancelling a batch
418
+
419
+ Pass the batch reference returned by `experimental_startBatch` to request cancellation:
420
+
421
+ ```ts
422
+ import { gateway } from '@ai-sdk/gateway';
423
+ import { experimental_cancelBatch as cancelBatch } from 'ai';
424
+
425
+ await cancelBatch({ provider: gateway, batch });
426
+ ```
427
+
428
+ Cancellation is asynchronous. Continue checking `experimental_getBatchStatus` until the batch is terminal, then read `experimental_getBatchResults` for any partial results. A batch may finish before cancellation takes effect, and successful requests remain billable. Cancellation returns acknowledgement metadata, not confirmation that provider execution has stopped.
429
+
417
430
  ## Reranking Models
418
431
 
419
432
  You can create reranking models using the `rerankingModel` method on the provider instance:
@@ -736,7 +749,7 @@ import { generateText, tool } from 'ai';
736
749
  import { z } from 'zod';
737
750
 
738
751
  const { text } = await generateText({
739
- model: 'xai/grok-4.6',
752
+ model: 'xai/grok-4.7',
740
753
  prompt: 'What is the weather like in San Francisco?',
741
754
  tools: {
742
755
  getWeather: tool({
@@ -1377,15 +1390,17 @@ The following gateway provider options are available:
1377
1390
 
1378
1391
  The unique identifier for the entity against which quota is tracked. Used for quota management and enforcement purposes.
1379
1392
 
1380
- - **has** _Array&lt;'implicit-caching' | 'vision'&gt;_
1393
+ - **has** _Array&lt;'implicit-caching' | 'reasoning' | 'tool-use' | 'vision'&gt;_
1381
1394
 
1382
1395
  Restricts routing to provider models that have all of the specified capabilities. Applies to both BYOK and system credentials, since the capability is a property of the model rather than the credential. If no provider model for the requested model satisfies the capabilities, the request fails. Unsupported values are rejected.
1383
1396
 
1384
1397
  Supported capabilities:
1385
1398
  - `'implicit-caching'` — models that perform automatic (implicit) prompt caching.
1399
+ - `'reasoning'` — models that support reasoning.
1400
+ - `'tool-use'` — models that support tool calling.
1386
1401
  - `'vision'` — models that accept image input.
1387
1402
 
1388
- Example: `has: ['implicit-caching']` will only route to models that support implicit caching. Example: `has: ['vision']` will only route to models that accept image input.
1403
+ Example: `has: ['implicit-caching']` will only route to models that support implicit caching. Example: `has: ['vision']` will only route to models that accept image input. Example: `has: ['tool-use']` will only route to models that support tool calling.
1389
1404
 
1390
1405
  - **providerTimeouts** _object_
1391
1406
 
@@ -1523,7 +1538,7 @@ const { text } = await generateText({
1523
1538
 
1524
1539
  #### Filtering by Model Capability
1525
1540
 
1526
- Set `has` to restrict routing to provider models that have the specified capabilities. This applies to both BYOK and system credentials, since the capability is a property of the model rather than the credential. `'implicit-caching'` limits routing to models that perform automatic prompt caching, and `'vision'` limits routing to models that accept image input. If no provider model for the requested model satisfies the capabilities, the request fails.
1541
+ Set `has` to restrict routing to provider models that have the specified capabilities. This applies to both BYOK and system credentials, since the capability is a property of the model rather than the credential. `'implicit-caching'` limits routing to models that perform automatic prompt caching, `'vision'` limits routing to models that accept image input, `'reasoning'` limits routing to models that support reasoning, and `'tool-use'` limits routing to models that support tool calling. If no provider model for the requested model satisfies the capabilities, the request fails.
1527
1542
 
1528
1543
  ```ts
1529
1544
  import type { GatewayProviderOptions } from '@ai-sdk/gateway';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "4.0.87",
4
+ "version": "4.0.89",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "sideEffects": false,
@@ -2,6 +2,7 @@ import {
2
2
  InvalidArgumentError,
3
3
  UnsupportedFunctionalityError,
4
4
  type Experimental_BatchV4 as BatchV4,
5
+ type Experimental_BatchV4CancelResult as BatchV4CancelResult,
5
6
  type Experimental_BatchV4ItemResult as BatchV4ItemResult,
6
7
  type Experimental_BatchV4OperationOptions as BatchV4OperationOptions,
7
8
  type Experimental_BatchV4StartResult as BatchV4StartResult,
@@ -213,7 +214,54 @@ export class GatewayBatch implements BatchV4<{ text: GatewayModelId }> {
213
214
  }
214
215
  }
215
216
 
216
- private getBatchUrl(path: 'results' | 'start' | 'status') {
217
+ /** Requests cancellation; status and partial results remain separate reads. */
218
+ async doCancelBatch({
219
+ batchId,
220
+ headers,
221
+ abortSignal,
222
+ }: BatchV4OperationOptions): Promise<BatchV4CancelResult> {
223
+ const resolvedHeaders = this.config.headers
224
+ ? await resolve(this.config.headers)
225
+ : undefined;
226
+
227
+ try {
228
+ const { value: responseBody } = await postJsonToApi({
229
+ url: this.getBatchUrl('cancel'),
230
+ headers: combineHeaders(
231
+ resolvedHeaders,
232
+ headers,
233
+ await resolve(this.config.o11yHeaders),
234
+ ),
235
+ body: { batchId },
236
+ successfulResponseHandler: createJsonResponseHandler(
237
+ gatewayBatchStatusResponseSchema,
238
+ ),
239
+ failedResponseHandler: createJsonErrorResponseHandler({
240
+ errorSchema: z.any(),
241
+ errorToMessage: data => getErrorMessage(data) ?? 'unknown error',
242
+ }),
243
+ ...(abortSignal && { abortSignal }),
244
+ fetch: this.config.fetch,
245
+ });
246
+
247
+ return {
248
+ ...(responseBody.providerMetadata != null && {
249
+ providerMetadata:
250
+ responseBody.providerMetadata as SharedV4ProviderMetadata,
251
+ }),
252
+ };
253
+ } catch (error) {
254
+ if (isAbortOrTimeoutError(error)) {
255
+ throw error;
256
+ }
257
+ throw await asGatewayError(
258
+ error,
259
+ await parseAuthMethod(resolvedHeaders ?? {}),
260
+ );
261
+ }
262
+ }
263
+
264
+ private getBatchUrl(path: 'cancel' | 'results' | 'start' | 'status') {
217
265
  return `${this.config.baseURL}/batch/${path}`;
218
266
  }
219
267
  }
@@ -29,6 +29,7 @@ export type GatewayModelId =
29
29
  | 'alibaba/qwen3.8-flash'
30
30
  | 'alibaba/qwen3.8-max'
31
31
  | 'alibaba/qwen3.8-max-0902'
32
+ | 'alibaba/qwen3.8-omni-flash'
32
33
  | 'amazon/nova-2-lite'
33
34
  | 'amazon/nova-lite'
34
35
  | 'amazon/nova-micro'
@@ -45,6 +46,7 @@ export type GatewayModelId =
45
46
  | 'anthropic/claude-opus-4.8-fast'
46
47
  | 'anthropic/claude-opus-5'
47
48
  | 'anthropic/claude-opus-5-fast'
49
+ | 'anthropic/claude-opus-5.5'
48
50
  | 'anthropic/claude-sonnet-4'
49
51
  | 'anthropic/claude-sonnet-4.5'
50
52
  | 'anthropic/claude-sonnet-4.6'
@@ -124,6 +126,7 @@ export type GatewayModelId =
124
126
  | 'mistral/mistral-medium-3.5'
125
127
  | 'mistral/mistral-nemo'
126
128
  | 'mistral/mistral-small'
129
+ | 'mixedbread/toast-1'
127
130
  | 'moonshotai/kimi-k2'
128
131
  | 'moonshotai/kimi-k2-thinking'
129
132
  | 'moonshotai/kimi-k2.5'
@@ -203,6 +206,8 @@ export type GatewayModelId =
203
206
  | 'perplexity/sonar-reasoning-pro'
204
207
  | 'poolside/laguna-s-2.1'
205
208
  | 'poolside/laguna-s-2.1-free'
209
+ | 'quiverai/arrow-2'
210
+ | 'quiverai/arrow-2-telos'
206
211
  | 'sakana/fugu-max'
207
212
  | 'sakana/fugu-ultra'
208
213
  | 'sakana/fugu-ultra-v2'
@@ -218,9 +223,11 @@ export type GatewayModelId =
218
223
  | 'spacexai/grok-4.3'
219
224
  | 'spacexai/grok-4.5'
220
225
  | 'spacexai/grok-4.6'
226
+ | 'spacexai/grok-4.7'
221
227
  | 'spacexai/grok-build-0.1'
222
228
  | 'stepfun/step-3.5-flash'
223
229
  | 'stepfun/step-3.7-flash'
230
+ | 'stepfun/step-5-preview'
224
231
  | 'tencent/hy-mt2-lite'
225
232
  | 'tencent/hy-mt2-plus'
226
233
  | 'tencent/hy-mt2-pro'
@@ -245,5 +252,6 @@ export type GatewayModelId =
245
252
  | 'zai/glm-5.3'
246
253
  | 'zai/glm-5.3-fast'
247
254
  | 'zai/glm-5.3-flash'
255
+ | 'zai/glm-5.3-flashx'
248
256
  | 'zai/glm-5v-turbo'
249
257
  | (string & {});
@@ -17,9 +17,10 @@ export type GatewayProviderOptions = {
17
17
 
18
18
  /**
19
19
  * Restrict routing to models that have all of the given capabilities.
20
- * Currently supports `'implicit-caching'` and `'vision'` (image input).
20
+ * Currently supports `'implicit-caching'`, `'reasoning'`, `'tool-use'`, and
21
+ * `'vision'` (image input).
21
22
  */
22
- has?: Array<'implicit-caching' | 'vision'>;
23
+ has?: Array<'implicit-caching' | 'reasoning' | 'tool-use' | 'vision'>;
23
24
 
24
25
  /**
25
26
  * Idempotency key for `experimental_startBatch`: retries with the same
@@ -1,10 +1,7 @@
1
1
  export type GatewaySpeechModelId =
2
2
  | 'fish-audio/s1'
3
- | 'fish-audio/s1-free'
4
3
  | 'fish-audio/s2-pro'
5
- | 'fish-audio/s2-pro-free'
6
4
  | 'fish-audio/s2.1-pro'
7
- | 'fish-audio/s2.1-pro-free'
8
5
  | 'openai/tts-1'
9
6
  | 'openai/tts-1-hd'
10
7
  | 'spacexai/grok-tts'
@@ -1,6 +1,5 @@
1
1
  export type GatewayTranscriptionModelId =
2
2
  | 'fish-audio/transcribe-1'
3
- | 'fish-audio/transcribe-1-free'
4
3
  | 'google/gemini-3.5-transcribe'
5
4
  | 'google/gemini-3.5-transcribe-live'
6
5
  | 'openai/gpt-4o-mini-transcribe'