@ai-sdk/gateway 4.0.2 → 4.0.3

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,11 @@
1
1
  # @ai-sdk/gateway
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 728eaa0: feat(provider/gateway): add `has` provider option to restrict routing to models with given capabilities (e.g. `implicit-caching`)
8
+
3
9
  ## 4.0.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -786,6 +786,11 @@ type GatewayProviderOptions = {
786
786
  caching?: 'auto';
787
787
  /** Filter to providers that do not train on prompt data. */
788
788
  disallowPromptTraining?: boolean;
789
+ /**
790
+ * Restrict routing to models that have all of the given capabilities.
791
+ * Currently supports `'implicit-caching'`.
792
+ */
793
+ has?: Array<'implicit-caching'>;
789
794
  /** Filter to providers that are HIPAA compliant with Vercel AI Gateway. */
790
795
  hipaaCompliant?: boolean;
791
796
  /** Array of model slugs specifying fallback models to use in order. */
package/dist/index.js CHANGED
@@ -2356,7 +2356,7 @@ async function getVercelRequestId() {
2356
2356
  }
2357
2357
 
2358
2358
  // src/version.ts
2359
- var VERSION = true ? "4.0.2" : "0.0.0-test";
2359
+ var VERSION = true ? "4.0.3" : "0.0.0-test";
2360
2360
 
2361
2361
  // src/gateway-provider.ts
2362
2362
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
@@ -1045,6 +1045,12 @@ The following gateway provider options are available:
1045
1045
 
1046
1046
  The unique identifier for the entity against which quota is tracked. Used for quota management and enforcement purposes.
1047
1047
 
1048
+ - **has** _Array&lt;'implicit-caching'&gt;_
1049
+
1050
+ Restricts routing to provider models that have all of the specified capabilities. Currently supports `'implicit-caching'`, which limits routing to models that perform automatic (implicit) prompt caching. 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.
1051
+
1052
+ Example: `has: ['implicit-caching']` will only route to models that support implicit caching.
1053
+
1048
1054
  - **providerTimeouts** _object_
1049
1055
 
1050
1056
  Per-provider timeouts for BYOK credentials in milliseconds. Controls how long to wait for a provider to start responding before falling back to the next available provider.
@@ -1198,6 +1204,25 @@ const { text } = await generateText({
1198
1204
  });
1199
1205
  ```
1200
1206
 
1207
+ #### Filtering by Model Capability
1208
+
1209
+ 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. Currently `'implicit-caching'` is supported, which limits routing to models that perform automatic prompt caching. If no provider model for the requested model satisfies the capabilities, the request fails.
1210
+
1211
+ ```ts
1212
+ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1213
+ import { generateText } from 'ai';
1214
+
1215
+ const { text } = await generateText({
1216
+ model: 'openai/gpt-5.5',
1217
+ prompt: 'Summarize this report...',
1218
+ providerOptions: {
1219
+ gateway: {
1220
+ has: ['implicit-caching'],
1221
+ } satisfies GatewayProviderOptions,
1222
+ },
1223
+ });
1224
+ ```
1225
+
1201
1226
  ### Provider-Specific Options
1202
1227
 
1203
1228
  When using provider-specific options through AI Gateway, use the actual provider name (e.g. `anthropic`, `openai`, not `gateway`) as the key:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "4.0.2",
4
+ "version": "4.0.3",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "sideEffects": false,
@@ -15,6 +15,12 @@ export type GatewayProviderOptions = {
15
15
  /** Filter to providers that do not train on prompt data. */
16
16
  disallowPromptTraining?: boolean;
17
17
 
18
+ /**
19
+ * Restrict routing to models that have all of the given capabilities.
20
+ * Currently supports `'implicit-caching'`.
21
+ */
22
+ has?: Array<'implicit-caching'>;
23
+
18
24
  /** Filter to providers that are HIPAA compliant with Vercel AI Gateway. */
19
25
  hipaaCompliant?: boolean;
20
26