@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 +6 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -1
- package/docs/00-ai-gateway.mdx +25 -0
- package/package.json +1 -1
- package/src/gateway-provider-options.ts +6 -0
package/CHANGELOG.md
CHANGED
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.
|
|
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";
|
package/docs/00-ai-gateway.mdx
CHANGED
|
@@ -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<'implicit-caching'>_
|
|
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
|
@@ -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
|
|