@ai-sdk/gateway 3.0.142 → 3.0.144

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.
@@ -159,6 +159,8 @@ You can connect your own provider credentials to use with Vercel AI Gateway. Thi
159
159
 
160
160
  To set up BYOK, add your provider credentials in your Vercel team's AI Gateway settings. Once configured, AI Gateway automatically uses your credentials. No code changes are needed.
161
161
 
162
+ For providers like Azure where you can use custom deployment names, you can configure model mappings to map gateway model slugs to your deployment names. See [model mappings](https://vercel.com/docs/ai-gateway/byok#model-mappings) for details.
163
+
162
164
  Learn more in the [BYOK documentation](https://vercel.com/docs/ai-gateway/byok).
163
165
 
164
166
  ## Language Models
@@ -935,15 +937,18 @@ The following gateway provider options are available:
935
937
 
936
938
  Each provider can have multiple credentials (tried in order). The structure is a record where keys are provider slugs and values are arrays of credential objects.
937
939
 
940
+ Each credential can optionally include a `modelMappings` array to map AI Gateway model slugs to your deployment names (for example, custom Azure deployment names). If a BYOK request fails, the gateway falls back to system credentials using the default model name.
941
+
938
942
  Examples:
939
943
 
940
944
  - Single provider: `byok: { 'anthropic': [{ apiKey: 'sk-ant-...' }] }`
941
945
  - Multiple credentials: `byok: { 'vertex': [{ project: 'proj-1', googleCredentials: { privateKey: '...', clientEmail: '...' } }, { project: 'proj-2', googleCredentials: { privateKey: '...', clientEmail: '...' } }] }`
942
946
  - Multiple providers: `byok: { 'anthropic': [{ apiKey: '...' }], 'bedrock': [{ accessKeyId: '...', secretAccessKey: '...' }] }`
947
+ - With model mappings: `byok: { 'azure': [{ apiKey: '...', resourceName: '...', modelMappings: [{ gatewayModelSlug: 'openai/gpt-5.4-nano', customModelId: 'my-deployment' }] }] }`
943
948
 
944
949
  - **zeroDataRetention** _boolean_
945
950
 
946
- Restricts routing requests to providers that have zero data retention agreements with Vercel for AI Gateway. If there are no providers available for the model with zero data retention, the request will fail. BYOK credentials are skipped when `zeroDataRetention` is set to `true` to ensure that requests are only routed to providers that support ZDR compliance. Request-level ZDR is only available for Vercel Pro and Enterprise plans.
951
+ Restricts routing to providers with zero data retention agreements with Vercel for AI Gateway. BYOK credentials are skipped by default, since your provider agreements differ from Vercel's. When this filter is on, AI Gateway routes only to providers Vercel has ZDR agreements with for the model. If you have BYOK keys marked as ZDR, those keys are tried first, then AI Gateway falls back to its system credentials. You are responsible for the accuracy of that marking. Applies to both account-wide and request-level ZDR. The request fails if no ZDR-eligible credentials are available. Request-level ZDR is only available for Vercel Pro and Enterprise plans.
947
952
 
948
953
  - **disallowPromptTraining** _boolean_
949
954
 
@@ -1036,7 +1041,7 @@ const { text } = await generateText({
1036
1041
 
1037
1042
  #### Zero Data Retention Example
1038
1043
 
1039
- Set `zeroDataRetention` to true to route requests to providers that have zero data retention agreements with Vercel for AI Gateway. If there are no providers available for the model with zero data retention, the request will fail. When `zeroDataRetention` is `false` or not specified, there is no enforcement of restricting routing. BYOK credentials are skipped when `zeroDataRetention` is set to `true` to ensure that requests are only routed to providers that support ZDR compliance. Request-level ZDR is only available for Vercel Pro and Enterprise plans.
1044
+ Set `zeroDataRetention` to true to route requests to providers with zero data retention agreements with Vercel for AI Gateway. BYOK credentials are skipped by default, since your provider agreements differ from Vercel's. When this filter is on, AI Gateway routes only to providers Vercel has ZDR agreements with for the model. If you have BYOK keys marked as ZDR, those keys are tried first, then AI Gateway falls back to its system credentials. You are responsible for the accuracy of that marking. Applies to both account-wide and request-level ZDR. The request fails if no ZDR-eligible credentials are available. When `zeroDataRetention` is `false` or not specified, there is no enforcement of restricting routing. Request-level ZDR is only available for Vercel Pro and Enterprise plans.
1040
1045
 
1041
1046
  ```ts
1042
1047
  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": "3.0.142",
4
+ "version": "3.0.144",
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.13",
35
- "@ai-sdk/provider-utils": "4.0.35"
35
+ "@ai-sdk/provider-utils": "4.0.36"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "18.15.11",
@@ -1,4 +1,5 @@
1
1
  import type { APICallError } from '@ai-sdk/provider';
2
+ import { secureJsonParse } from '@ai-sdk/provider-utils';
2
3
 
3
4
  export function extractApiCallResponse(error: APICallError): unknown {
4
5
  if (error.data !== undefined) {
@@ -6,7 +7,7 @@ export function extractApiCallResponse(error: APICallError): unknown {
6
7
  }
7
8
  if (error.responseBody != null) {
8
9
  try {
9
- return JSON.parse(error.responseBody);
10
+ return secureJsonParse(error.responseBody);
10
11
  } catch {
11
12
  return error.responseBody;
12
13
  }
@@ -29,6 +29,7 @@ export type GatewayModelId =
29
29
  | 'amazon/nova-pro'
30
30
  | 'anthropic/claude-3-haiku'
31
31
  | 'anthropic/claude-3.5-haiku'
32
+ | 'anthropic/claude-fable-5'
32
33
  | 'anthropic/claude-haiku-4.5'
33
34
  | 'anthropic/claude-opus-4'
34
35
  | 'anthropic/claude-opus-4.1'