@ai-sdk/gateway 4.0.146 → 4.0.148

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "4.0.146",
4
+ "version": "4.0.148",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "sideEffects": false,
@@ -30,8 +30,8 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@ai-sdk/provider": "4.0.38",
34
- "@ai-sdk/provider-utils": "5.0.81",
33
+ "@ai-sdk/provider": "4.0.39",
34
+ "@ai-sdk/provider-utils": "5.0.82",
35
35
  "@vercel/oidc": "3.2.0"
36
36
  },
37
37
  "devDependencies": {
@@ -14,6 +14,10 @@ import {
14
14
  GatewayForbiddenError,
15
15
  forbiddenParamSchema,
16
16
  } from './gateway-forbidden-error';
17
+ import {
18
+ GatewayAccessPolicyDeniedError,
19
+ accessPolicyDeniedParamSchema,
20
+ } from './gateway-access-policy-denied-error';
17
21
  import { GatewayResponseError } from './gateway-response-error';
18
22
  import {
19
23
  lazySchema,
@@ -138,6 +142,23 @@ export async function createGatewayErrorFromResponse({
138
142
  ruleId: ruleResult.success ? ruleResult.value.ruleId : undefined,
139
143
  });
140
144
  }
145
+ case 'access_policy_denied': {
146
+ const paramResult = await safeValidateTypes({
147
+ value: validatedResponse.error.param,
148
+ schema: accessPolicyDeniedParamSchema,
149
+ });
150
+ const param = paramResult.success ? paramResult.value : undefined;
151
+
152
+ return new GatewayAccessPolicyDeniedError({
153
+ message,
154
+ statusCode,
155
+ cause,
156
+ generationId,
157
+ policyIds: param?.policyIds,
158
+ removedModels: param?.removedModels,
159
+ removedProviders: param?.removedProviders,
160
+ });
161
+ }
141
162
  default:
142
163
  return new GatewayInternalServerError({
143
164
  message,
@@ -0,0 +1,72 @@
1
+ import { z } from '../zod';
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
+ }
@@ -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'
@@ -254,6 +251,10 @@ export type GatewayModelId =
254
251
  | 'openai/gpt-6.1-sol-fast'
255
252
  | 'openai/gpt-6.1-terra'
256
253
  | 'openai/gpt-6.1-terra-fast'
254
+ | 'openai/gpt-6.2-astra'
255
+ | 'openai/gpt-6.2-astra-fast'
256
+ | 'openai/gpt-6.2-sol'
257
+ | 'openai/gpt-6.2-sol-fast'
257
258
  | 'openai/gpt-oss-120b'
258
259
  | 'openai/gpt-oss-20b'
259
260
  | 'openai/gpt-oss-safeguard-120b'
@@ -300,6 +301,7 @@ export type GatewayModelId =
300
301
  | 'tencent/hy-mt2-pro'
301
302
  | 'tencent/hy3'
302
303
  | 'tencent/hy4'
304
+ | 'tencent/hy4-flash'
303
305
  | 'tencent/hy4-preview'
304
306
  | 'thinkingmachines/inkling'
305
307
  | 'thinkingmachines/inkling-2-small'
package/src/index.ts CHANGED
@@ -60,6 +60,7 @@ export type {
60
60
  } from './gateway-provider-options';
61
61
  export {
62
62
  GatewayError,
63
+ GatewayAccessPolicyDeniedError,
63
64
  GatewayAuthenticationError,
64
65
  GatewayFailedDependencyError,
65
66
  GatewayForbiddenError,