@ai-sdk/gateway 3.0.237 → 3.0.241
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 +29 -0
- package/dist/index.d.mts +40 -6
- package/dist/index.d.ts +40 -6
- 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-image-model-settings.ts +3 -1
- package/src/gateway-language-model-settings.ts +8 -12
- package/src/gateway-video-model-settings.ts +1 -0
- 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.241",
|
|
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';
|
|
@@ -15,9 +15,12 @@ export type GatewayImageModelId =
|
|
|
15
15
|
| 'bytedance/seedream-4.5'
|
|
16
16
|
| 'bytedance/seedream-5.0-lite'
|
|
17
17
|
| 'bytedance/seedream-5.0-pro'
|
|
18
|
+
| 'bytedance/seedream-5.5'
|
|
18
19
|
| 'meta/muse-image-1.0'
|
|
19
20
|
| 'microsoft/mai-image-2.6'
|
|
20
21
|
| 'microsoft/mai-image-2.6-flash'
|
|
22
|
+
| 'microsoft/mai-image-2.7'
|
|
23
|
+
| 'microsoft/mai-image-2.7-flash'
|
|
21
24
|
| 'minimax/minimax-h3-image'
|
|
22
25
|
| 'minimax/minimax-h3-image-highspeed'
|
|
23
26
|
| 'openai/gpt-image-1-mini'
|
|
@@ -27,7 +30,6 @@ export type GatewayImageModelId =
|
|
|
27
30
|
| 'openai/gpt-image-2.5-sunburst'
|
|
28
31
|
| 'openai/gpt-image-2.6-flare'
|
|
29
32
|
| 'openai/gpt-image-2.6-sunburst'
|
|
30
|
-
| 'prodia/flux-fast-schnell'
|
|
31
33
|
| 'recraft/recraft-v2'
|
|
32
34
|
| 'recraft/recraft-v3'
|
|
33
35
|
| 'recraft/recraft-v4'
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export type GatewayModelId =
|
|
2
2
|
| 'alibaba/qwen-3-14b'
|
|
3
|
-
| 'alibaba/qwen-3-235b'
|
|
4
3
|
| 'alibaba/qwen-3-30b'
|
|
5
4
|
| 'alibaba/qwen-3-32b'
|
|
6
|
-
| 'alibaba/qwen3-coder'
|
|
7
5
|
| 'alibaba/qwen3-coder-30b-a3b'
|
|
8
6
|
| 'alibaba/qwen3-coder-next'
|
|
9
7
|
| 'alibaba/qwen3-max-thinking'
|
|
10
8
|
| 'alibaba/qwen3-next-80b-a3b-instruct'
|
|
11
|
-
| 'alibaba/qwen3-next-80b-a3b-thinking'
|
|
12
9
|
| 'alibaba/qwen3-vl-instruct'
|
|
13
10
|
| 'alibaba/qwen3.5-flash'
|
|
14
11
|
| 'alibaba/qwen3.5-plus'
|
|
@@ -25,6 +22,7 @@ export type GatewayModelId =
|
|
|
25
22
|
| 'alibaba/qwen3.8-max-0902'
|
|
26
23
|
| 'alibaba/qwen3.8-max-prime'
|
|
27
24
|
| 'alibaba/qwen3.8-omni-flash'
|
|
25
|
+
| 'alibaba/qwen4-max'
|
|
28
26
|
| 'amazon/nova-2-lite'
|
|
29
27
|
| 'amazon/nova-lite'
|
|
30
28
|
| 'amazon/nova-micro'
|
|
@@ -108,16 +106,14 @@ export type GatewayModelId =
|
|
|
108
106
|
| 'google/gemini-4-argon'
|
|
109
107
|
| 'google/gemini-4-carbon'
|
|
110
108
|
| 'google/gemini-4-hydrogen'
|
|
109
|
+
| 'google/gemini-4-neon'
|
|
111
110
|
| 'google/gemini-nano-banana-2.1'
|
|
112
111
|
| 'google/gemini-omni-1.2-flash'
|
|
113
112
|
| 'google/gemini-omni-flash-preview'
|
|
114
113
|
| 'google/gemma-4-26b-a4b-it'
|
|
115
114
|
| 'google/gemma-4-31b-it'
|
|
116
115
|
| 'humansand/ampersand-v0.1'
|
|
117
|
-
| 'inception/mercury-2'
|
|
118
|
-
| 'inception/mercury-2.5'
|
|
119
116
|
| 'inception/mercury-3'
|
|
120
|
-
| 'inception/mercury-coder-small'
|
|
121
117
|
| 'inclusionai/ling-3.0-flash'
|
|
122
118
|
| 'inclusionai/ling-3.0-flash-fin'
|
|
123
119
|
| 'inclusionai/ling-3.0-flash-sante'
|
|
@@ -143,13 +139,9 @@ export type GatewayModelId =
|
|
|
143
139
|
| 'meta/muse-spark-1.3-contributor'
|
|
144
140
|
| 'meta/muse-spark-open'
|
|
145
141
|
| 'meta/muse-wonder-1.0'
|
|
146
|
-
| 'minimax/minimax-m2'
|
|
147
142
|
| 'minimax/minimax-m2.1'
|
|
148
|
-
| 'minimax/minimax-m2.1-lightning'
|
|
149
143
|
| 'minimax/minimax-m2.5'
|
|
150
|
-
| 'minimax/minimax-m2.5-highspeed'
|
|
151
144
|
| 'minimax/minimax-m2.7'
|
|
152
|
-
| 'minimax/minimax-m2.7-highspeed'
|
|
153
145
|
| 'minimax/minimax-m3'
|
|
154
146
|
| 'minimax/minimax-m3.1-flash'
|
|
155
147
|
| 'mistral/codestral'
|
|
@@ -173,7 +165,6 @@ export type GatewayModelId =
|
|
|
173
165
|
| 'moonshotai/kimi-k3.1-pro-highspeed'
|
|
174
166
|
| 'morph/morph-v3-fast'
|
|
175
167
|
| 'morph/morph-v3-large'
|
|
176
|
-
| 'nvidia/nemotron-3-nano-30b-a3b'
|
|
177
168
|
| 'nvidia/nemotron-3-super-120b-a12b'
|
|
178
169
|
| 'nvidia/nemotron-3-ultra-550b-a55b'
|
|
179
170
|
| 'nvidia/nemotron-3.5-lightning'
|
|
@@ -254,6 +245,10 @@ export type GatewayModelId =
|
|
|
254
245
|
| 'openai/gpt-6.1-sol-fast'
|
|
255
246
|
| 'openai/gpt-6.1-terra'
|
|
256
247
|
| 'openai/gpt-6.1-terra-fast'
|
|
248
|
+
| 'openai/gpt-6.2-astra'
|
|
249
|
+
| 'openai/gpt-6.2-astra-fast'
|
|
250
|
+
| 'openai/gpt-6.2-sol'
|
|
251
|
+
| 'openai/gpt-6.2-sol-fast'
|
|
257
252
|
| 'openai/gpt-oss-120b'
|
|
258
253
|
| 'openai/gpt-oss-20b'
|
|
259
254
|
| 'openai/gpt-oss-safeguard-120b'
|
|
@@ -269,6 +264,7 @@ export type GatewayModelId =
|
|
|
269
264
|
| 'perplexity/sonar'
|
|
270
265
|
| 'quiverai/arrow-2'
|
|
271
266
|
| 'quiverai/arrow-2-telos'
|
|
267
|
+
| 'recursive/flint-v1.0'
|
|
272
268
|
| 'reflection/beam'
|
|
273
269
|
| 'reflection/beam-free'
|
|
274
270
|
| 'sakana/fugu-max'
|
|
@@ -291,7 +287,6 @@ export type GatewayModelId =
|
|
|
291
287
|
| 'spacexai/grok-4.5'
|
|
292
288
|
| 'spacexai/grok-4.6'
|
|
293
289
|
| 'spacexai/grok-4.7'
|
|
294
|
-
| 'spacexai/grok-build-0.1'
|
|
295
290
|
| 'stealth/glyph-cluster'
|
|
296
291
|
| 'stepfun/step-3.7-flash'
|
|
297
292
|
| 'stepfun/step-5-preview'
|
|
@@ -300,6 +295,7 @@ export type GatewayModelId =
|
|
|
300
295
|
| 'tencent/hy-mt2-pro'
|
|
301
296
|
| 'tencent/hy3'
|
|
302
297
|
| 'tencent/hy4'
|
|
298
|
+
| 'tencent/hy4-flash'
|
|
303
299
|
| 'tencent/hy4-preview'
|
|
304
300
|
| 'thinkingmachines/inkling'
|
|
305
301
|
| 'thinkingmachines/inkling-2-small'
|
|
@@ -14,6 +14,7 @@ export type GatewayVideoModelId =
|
|
|
14
14
|
| 'bytedance/seedance-2.0-fast'
|
|
15
15
|
| 'bytedance/seedance-2.0-mini'
|
|
16
16
|
| 'bytedance/seedance-2.5'
|
|
17
|
+
| 'bytedance/seedance-2.5-flash'
|
|
17
18
|
| 'bytedance/seedance-v1.0-pro'
|
|
18
19
|
| 'bytedance/seedance-v1.0-pro-fast'
|
|
19
20
|
| 'google/veo-3.1-fast-generate-001'
|