@ai-sdk/gateway 3.0.236 → 3.0.238
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 +15 -0
- package/dist/index.d.mts +38 -4
- package/dist/index.d.ts +38 -4
- package/dist/index.js +528 -470
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +794 -737
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/errors/create-gateway-error.ts +21 -0
- package/src/errors/gateway-access-policy-denied-error.ts +72 -0
- package/src/errors/index.ts +1 -0
- package/src/gateway-language-model-settings.ts +4 -5
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/gateway",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.238",
|
|
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.
|
|
35
|
+
"@ai-sdk/provider-utils": "4.0.67"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "18.15.11",
|
|
@@ -13,6 +13,10 @@ import {
|
|
|
13
13
|
GatewayForbiddenError,
|
|
14
14
|
forbiddenParamSchema,
|
|
15
15
|
} from './gateway-forbidden-error';
|
|
16
|
+
import {
|
|
17
|
+
GatewayAccessPolicyDeniedError,
|
|
18
|
+
accessPolicyDeniedParamSchema,
|
|
19
|
+
} from './gateway-access-policy-denied-error';
|
|
16
20
|
import { GatewayResponseError } from './gateway-response-error';
|
|
17
21
|
import {
|
|
18
22
|
lazySchema,
|
|
@@ -132,6 +136,23 @@ export async function createGatewayErrorFromResponse({
|
|
|
132
136
|
ruleId: ruleResult.success ? ruleResult.value.ruleId : undefined,
|
|
133
137
|
});
|
|
134
138
|
}
|
|
139
|
+
case 'access_policy_denied': {
|
|
140
|
+
const paramResult = await safeValidateTypes({
|
|
141
|
+
value: validatedResponse.error.param,
|
|
142
|
+
schema: accessPolicyDeniedParamSchema,
|
|
143
|
+
});
|
|
144
|
+
const param = paramResult.success ? paramResult.value : undefined;
|
|
145
|
+
|
|
146
|
+
return new GatewayAccessPolicyDeniedError({
|
|
147
|
+
message,
|
|
148
|
+
statusCode,
|
|
149
|
+
cause,
|
|
150
|
+
generationId,
|
|
151
|
+
policyIds: param?.policyIds,
|
|
152
|
+
removedModels: param?.removedModels,
|
|
153
|
+
removedProviders: param?.removedProviders,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
135
156
|
default:
|
|
136
157
|
return new GatewayInternalServerError({
|
|
137
158
|
message,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { GatewayError } from './gateway-error';
|
|
3
|
+
import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
4
|
+
|
|
5
|
+
const name = 'GatewayAccessPolicyDeniedError';
|
|
6
|
+
const marker = `vercel.ai.gateway.error.${name}`;
|
|
7
|
+
const symbol = Symbol.for(marker);
|
|
8
|
+
|
|
9
|
+
// Unknown keys in `param` are ignored, and each field may be absent.
|
|
10
|
+
export const accessPolicyDeniedParamSchema = lazySchema(() =>
|
|
11
|
+
zodSchema(
|
|
12
|
+
z.object({
|
|
13
|
+
policyIds: z.optional(z.array(z.string())),
|
|
14
|
+
removedModels: z.optional(z.array(z.string())),
|
|
15
|
+
removedProviders: z.optional(z.array(z.string())),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Access policy denied - an AI Gateway access policy that applies to the
|
|
22
|
+
* request does not allow the requested model or provider.
|
|
23
|
+
*/
|
|
24
|
+
export class GatewayAccessPolicyDeniedError extends GatewayError {
|
|
25
|
+
private readonly [symbol] = true; // used in isInstance
|
|
26
|
+
|
|
27
|
+
readonly name = name;
|
|
28
|
+
readonly type = 'access_policy_denied';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* IDs of the access policies that denied the request, when the gateway
|
|
32
|
+
* includes them.
|
|
33
|
+
*/
|
|
34
|
+
readonly policyIds?: string[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Models the access policies removed, when the gateway includes them.
|
|
38
|
+
*/
|
|
39
|
+
readonly removedModels?: string[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Providers the access policies removed, when the gateway includes them.
|
|
43
|
+
*/
|
|
44
|
+
readonly removedProviders?: string[];
|
|
45
|
+
|
|
46
|
+
constructor({
|
|
47
|
+
message = 'Access policy denied',
|
|
48
|
+
statusCode = 403,
|
|
49
|
+
cause,
|
|
50
|
+
generationId,
|
|
51
|
+
policyIds,
|
|
52
|
+
removedModels,
|
|
53
|
+
removedProviders,
|
|
54
|
+
}: {
|
|
55
|
+
message?: string;
|
|
56
|
+
statusCode?: number;
|
|
57
|
+
cause?: unknown;
|
|
58
|
+
generationId?: string;
|
|
59
|
+
policyIds?: string[];
|
|
60
|
+
removedModels?: string[];
|
|
61
|
+
removedProviders?: string[];
|
|
62
|
+
} = {}) {
|
|
63
|
+
super({ message, statusCode, cause, generationId });
|
|
64
|
+
this.policyIds = policyIds;
|
|
65
|
+
this.removedModels = removedModels;
|
|
66
|
+
this.removedProviders = removedProviders;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static isInstance(error: unknown): error is GatewayAccessPolicyDeniedError {
|
|
70
|
+
return GatewayError.hasMarker(error) && symbol in error;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/errors/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export {
|
|
|
5
5
|
} from './create-gateway-error';
|
|
6
6
|
export { extractApiCallResponse } from './extract-api-call-response';
|
|
7
7
|
export { GatewayError } from './gateway-error';
|
|
8
|
+
export { GatewayAccessPolicyDeniedError } from './gateway-access-policy-denied-error';
|
|
8
9
|
export { GatewayAuthenticationError } from './gateway-authentication-error';
|
|
9
10
|
export { GatewayFailedDependencyError } from './gateway-failed-dependency-error';
|
|
10
11
|
export { GatewayForbiddenError } from './gateway-forbidden-error';
|
|
@@ -25,6 +25,7 @@ export type GatewayModelId =
|
|
|
25
25
|
| 'alibaba/qwen3.8-max-0902'
|
|
26
26
|
| 'alibaba/qwen3.8-max-prime'
|
|
27
27
|
| 'alibaba/qwen3.8-omni-flash'
|
|
28
|
+
| 'alibaba/qwen4-max'
|
|
28
29
|
| 'amazon/nova-2-lite'
|
|
29
30
|
| 'amazon/nova-lite'
|
|
30
31
|
| 'amazon/nova-micro'
|
|
@@ -114,10 +115,7 @@ export type GatewayModelId =
|
|
|
114
115
|
| 'google/gemma-4-26b-a4b-it'
|
|
115
116
|
| 'google/gemma-4-31b-it'
|
|
116
117
|
| 'humansand/ampersand-v0.1'
|
|
117
|
-
| 'inception/mercury-2'
|
|
118
|
-
| 'inception/mercury-2.5'
|
|
119
118
|
| 'inception/mercury-3'
|
|
120
|
-
| 'inception/mercury-coder-small'
|
|
121
119
|
| 'inclusionai/ling-3.0-flash'
|
|
122
120
|
| 'inclusionai/ling-3.0-flash-fin'
|
|
123
121
|
| 'inclusionai/ling-3.0-flash-sante'
|
|
@@ -173,7 +171,6 @@ export type GatewayModelId =
|
|
|
173
171
|
| 'moonshotai/kimi-k3.1-pro-highspeed'
|
|
174
172
|
| 'morph/morph-v3-fast'
|
|
175
173
|
| 'morph/morph-v3-large'
|
|
176
|
-
| 'nvidia/nemotron-3-nano-30b-a3b'
|
|
177
174
|
| 'nvidia/nemotron-3-super-120b-a12b'
|
|
178
175
|
| 'nvidia/nemotron-3-ultra-550b-a55b'
|
|
179
176
|
| 'nvidia/nemotron-3.5-lightning'
|
|
@@ -264,9 +261,9 @@ export type GatewayModelId =
|
|
|
264
261
|
| 'openai/o3-mini'
|
|
265
262
|
| 'openai/o3-pro'
|
|
266
263
|
| 'openai/o4-mini'
|
|
264
|
+
| 'paperinstruments/ultramarine-1-flash'
|
|
267
265
|
| 'particle/particle-1'
|
|
268
266
|
| 'perplexity/sonar'
|
|
269
|
-
| 'poolside/laguna-s-2.1'
|
|
270
267
|
| 'quiverai/arrow-2'
|
|
271
268
|
| 'quiverai/arrow-2-telos'
|
|
272
269
|
| 'reflection/beam'
|
|
@@ -300,8 +297,10 @@ export type GatewayModelId =
|
|
|
300
297
|
| 'tencent/hy-mt2-pro'
|
|
301
298
|
| 'tencent/hy3'
|
|
302
299
|
| 'tencent/hy4'
|
|
300
|
+
| 'tencent/hy4-flash'
|
|
303
301
|
| 'tencent/hy4-preview'
|
|
304
302
|
| 'thinkingmachines/inkling'
|
|
303
|
+
| 'thinkingmachines/inkling-2-small'
|
|
305
304
|
| 'thinkingmachines/inkling-small'
|
|
306
305
|
| 'xiaomi/mimo-v2.6-flash'
|
|
307
306
|
| 'xiaomi/mimo-v2.6-pro'
|