@ai-sdk/gateway 1.0.0-alpha.10

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 ADDED
@@ -0,0 +1,47 @@
1
+ # @ai-sdk/gateway
2
+
3
+ ## 1.0.0-alpha.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [c4df419]
8
+ - @ai-sdk/provider@2.0.0-alpha.10
9
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
10
+
11
+ ## 1.0.0-alpha.9
12
+
13
+ ### Patch Changes
14
+
15
+ - 26b6dd0: feat (providers/gateway): include deployment and request id
16
+ - Updated dependencies [811dff3]
17
+ - @ai-sdk/provider@2.0.0-alpha.9
18
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
19
+
20
+ ## 1.0.0-alpha.8
21
+
22
+ ### Patch Changes
23
+
24
+ - 3cbcbb7: feat (providers/gateway): share common gateway error transform logic
25
+ - 989ac75: chore (providers/gateway): update chat model ids
26
+ - 7742ba3: feat (providers/gateway): add gateway error types with error detail
27
+ - Updated dependencies [4fef487]
28
+ - Updated dependencies [9222aeb]
29
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
30
+ - @ai-sdk/provider@2.0.0-alpha.8
31
+
32
+ ## 1.0.0-alpha.7
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [5c56081]
37
+ - @ai-sdk/provider@2.0.0-alpha.7
38
+ - @ai-sdk/provider-utils@3.0.0-alpha.7
39
+
40
+ ## 1.0.0-alpha.6
41
+
42
+ ### Patch Changes
43
+
44
+ - 6c2c708: feat (providers/gateway): initial gateway provider
45
+ - Updated dependencies [0d2c085]
46
+ - @ai-sdk/provider@2.0.0-alpha.6
47
+ - @ai-sdk/provider-utils@3.0.0-alpha.6
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # AI SDK - Gateway Provider
2
+
3
+ The Gateway provider for the [AI SDK](https://ai-sdk.dev/docs) allows the use of a wide variety of AI models and providers.
4
+
5
+ ## Setup
6
+
7
+ The Gateway provider is available in the `@ai-sdk/gateway` module. You can install it with
8
+
9
+ ```bash
10
+ npm i @ai-sdk/gateway
11
+ ```
12
+
13
+ ## Provider Instance
14
+
15
+ You can import the default provider instance `gateway` from `@ai-sdk/gateway`:
16
+
17
+ ```ts
18
+ import { gateway } from '@ai-sdk/gateway';
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ts
24
+ import { gateway } from '@ai-sdk/gateway';
25
+ import { generateText } from 'ai';
26
+
27
+ const { text } = await generateText({
28
+ model: gateway('xai/grok-3-beta'),
29
+ prompt:
30
+ 'Tell me about the history of the San Francisco Mission-style burrito.',
31
+ });
32
+ ```
33
+
34
+ ## Documentation
35
+
36
+ Please check out the [AI SDK documentation](https://ai-sdk.dev/docs) for more information.
@@ -0,0 +1,225 @@
1
+ import { LanguageModelV2, ProviderV2 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { z, ZodError } from 'zod';
4
+
5
+ type GatewayModelId = 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-3.7-sonnet-reasoning' | 'anthropic/claude-4-opus-20250514' | 'anthropic/claude-4-sonnet-20250514' | 'anthropic/claude-v3-haiku' | 'anthropic/claude-v3-opus' | 'anthropic/claude-v3.5-sonnet' | 'bedrock/amazon.nova-lite-v1:0' | 'bedrock/amazon.nova-micro-v1:0' | 'bedrock/amazon.nova-pro-v1:0' | 'bedrock/claude-3-5-haiku-20241022' | 'bedrock/claude-3-5-sonnet-20240620-v1' | 'bedrock/claude-3-5-sonnet-20241022-v2' | 'bedrock/claude-3-7-sonnet-20250219' | 'bedrock/claude-3-haiku-20240307-v1' | 'bedrock/claude-4-opus-20250514-v1' | 'bedrock/claude-4-sonnet-20250514-v1' | 'bedrock/deepseek.r1-v1' | 'bedrock/meta.llama3-1-70b-instruct-v1' | 'bedrock/meta.llama3-1-8b-instruct-v1' | 'bedrock/meta.llama3-2-11b-instruct-v1' | 'bedrock/meta.llama3-2-1b-instruct-v1' | 'bedrock/meta.llama3-2-3b-instruct-v1' | 'bedrock/meta.llama3-2-90b-instruct-v1' | 'bedrock/meta.llama3-3-70b-instruct-v1' | 'bedrock/meta.llama4-maverick-17b-instruct-v1' | 'bedrock/meta.llama4-scout-17b-instruct-v1' | 'cerebras/deepseek-r1-distill-llama-70b' | 'cerebras/llama-3.3-70b' | 'cerebras/llama-4-scout-17b-16e-instruct' | 'cerebras/llama3.1-8b' | 'cerebras/qwen-3-32b' | 'cohere/command-a' | 'cohere/command-r' | 'cohere/command-r-plus' | 'deepinfra/llama-4-maverick-17b-128e-instruct-fp8' | 'deepinfra/llama-4-scout-17b-16e-instruct' | 'deepinfra/qwen3-14b' | 'deepinfra/qwen3-235b-a22b' | 'deepinfra/qwen3-30b-a3b' | 'deepinfra/qwen3-32b' | 'deepseek/deepseek-r1-0528' | 'fireworks/deepseek-r1' | 'fireworks/deepseek-v3' | 'fireworks/mixtral-8x22b-instruct' | 'fireworks/qwen3-235b-a22b' | 'fireworks/qwq-32b' | 'groq/deepseek-r1-distill-llama-70b' | 'groq/gemma2-9b-it' | 'groq/llama-3-70b-instruct' | 'groq/llama-3-8b-instruct' | 'groq/llama-3.1-8b' | 'groq/llama-3.3-70b-versatile' | 'groq/llama-4-scout-17b-16e-instruct' | 'groq/mistral-saba-24b' | 'groq/qwen-qwq-32b' | 'inception/mercury-coder-small' | 'mistral/codestral-2501' | 'mistral/ministral-3b-latest' | 'mistral/ministral-8b-latest' | 'mistral/mistral-large' | 'mistral/mistral-small' | 'mistral/mistral-small-2503' | 'mistral/pixtral-12b-2409' | 'mistral/pixtral-large-latest' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/o3' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'vertex/claude-3-5-haiku-20241022' | 'vertex/claude-3-5-sonnet-20240620' | 'vertex/claude-3-5-sonnet-v2-20241022' | 'vertex/claude-3-7-sonnet-20250219' | 'vertex/claude-3-haiku-20240307' | 'vertex/claude-3-opus-20240229' | 'vertex/claude-4-opus-20250514' | 'vertex/claude-4-sonnet-20250514' | 'vertex/gemini-2.0-flash-001' | 'vertex/gemini-2.0-flash-lite-001' | 'vertex/llama-4-maverick-17b-128e-instruct-maas' | 'vertex/llama-4-scout-17b-16e-instruct-maas' | 'xai/grok-2-1212' | 'xai/grok-2-vision-1212' | 'xai/grok-3-beta' | 'xai/grok-3-fast-beta' | 'xai/grok-3-mini-beta' | 'xai/grok-3-mini-fast-beta' | (string & {});
6
+
7
+ interface GatewayLanguageModelEntry {
8
+ /**
9
+ * The model id used by the remote provider in model settings and for specifying the
10
+ * intended model for text generation.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The display name of the model for presentation in user-facing contexts.
15
+ */
16
+ name: string;
17
+ /**
18
+ * Additional AI SDK language model specifications for the model.
19
+ */
20
+ specification: GatewayLanguageModelSpecification;
21
+ }
22
+ type GatewayLanguageModelSpecification = Pick<LanguageModelV2, 'specificationVersion' | 'provider' | 'modelId'>;
23
+
24
+ interface GatewayFetchMetadataResponse {
25
+ models: GatewayLanguageModelEntry[];
26
+ }
27
+
28
+ interface GatewayProvider extends ProviderV2 {
29
+ (modelId: GatewayModelId): LanguageModelV2;
30
+ /**
31
+ Creates a model for text generation.
32
+ */
33
+ languageModel(modelId: GatewayModelId): LanguageModelV2;
34
+ /**
35
+ Returns available providers and models for use with the remote provider.
36
+ */
37
+ getAvailableModels(): Promise<GatewayFetchMetadataResponse>;
38
+ }
39
+ interface GatewayProviderSettings {
40
+ /**
41
+ The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.
42
+ */
43
+ baseURL?: string;
44
+ /**
45
+ API key that is being sent using the `Authorization` header.
46
+ */
47
+ apiKey?: string;
48
+ /**
49
+ Custom headers to include in the requests.
50
+ */
51
+ headers?: Record<string, string>;
52
+ /**
53
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
54
+ or to provide a custom fetch implementation for e.g. testing.
55
+ */
56
+ fetch?: FetchFunction;
57
+ /**
58
+ How frequently to refresh the metadata cache in milliseconds.
59
+ */
60
+ metadataCacheRefreshMillis?: number;
61
+ }
62
+ /**
63
+ Create a remote provider instance.
64
+ */
65
+ declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
66
+ declare const gateway: GatewayProvider;
67
+
68
+ declare const symbol$6: unique symbol;
69
+ declare abstract class GatewayError extends Error {
70
+ private readonly [symbol$6];
71
+ abstract readonly name: string;
72
+ abstract readonly type: string;
73
+ readonly statusCode: number;
74
+ readonly cause?: unknown;
75
+ constructor({ message, statusCode, cause, }: {
76
+ message: string;
77
+ statusCode?: number;
78
+ cause?: unknown;
79
+ });
80
+ /**
81
+ * Checks if the given error is a Gateway Error.
82
+ * @param {unknown} error - The error to check.
83
+ * @returns {boolean} True if the error is a Gateway Error, false otherwise.
84
+ */
85
+ static isInstance(error: unknown): error is GatewayError;
86
+ static hasMarker(error: unknown): error is GatewayError;
87
+ }
88
+
89
+ declare const gatewayErrorResponseSchema: z.ZodObject<{
90
+ error: z.ZodObject<{
91
+ message: z.ZodString;
92
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
+ param: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
94
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
95
+ }, "strip", z.ZodTypeAny, {
96
+ message: string;
97
+ code?: string | number | null | undefined;
98
+ type?: string | null | undefined;
99
+ param?: unknown;
100
+ }, {
101
+ message: string;
102
+ code?: string | number | null | undefined;
103
+ type?: string | null | undefined;
104
+ param?: unknown;
105
+ }>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ error: {
108
+ message: string;
109
+ code?: string | number | null | undefined;
110
+ type?: string | null | undefined;
111
+ param?: unknown;
112
+ };
113
+ }, {
114
+ error: {
115
+ message: string;
116
+ code?: string | number | null | undefined;
117
+ type?: string | null | undefined;
118
+ param?: unknown;
119
+ };
120
+ }>;
121
+ type GatewayErrorResponse = z.infer<typeof gatewayErrorResponseSchema>;
122
+
123
+ declare const symbol$5: unique symbol;
124
+ /**
125
+ * Authentication failed - invalid API key or OIDC token
126
+ */
127
+ declare class GatewayAuthenticationError extends GatewayError {
128
+ private readonly [symbol$5];
129
+ readonly name = "GatewayAuthenticationError";
130
+ readonly type = "authentication_error";
131
+ constructor({ message, statusCode, cause, }?: {
132
+ message?: string;
133
+ statusCode?: number;
134
+ cause?: unknown;
135
+ });
136
+ static isInstance(error: unknown): error is GatewayAuthenticationError;
137
+ }
138
+
139
+ declare const symbol$4: unique symbol;
140
+ /**
141
+ * Internal server error from the Gateway
142
+ */
143
+ declare class GatewayInternalServerError extends GatewayError {
144
+ private readonly [symbol$4];
145
+ readonly name = "GatewayInternalServerError";
146
+ readonly type = "internal_server_error";
147
+ constructor({ message, statusCode, cause, }?: {
148
+ message?: string;
149
+ statusCode?: number;
150
+ cause?: unknown;
151
+ });
152
+ static isInstance(error: unknown): error is GatewayInternalServerError;
153
+ }
154
+
155
+ declare const symbol$3: unique symbol;
156
+ /**
157
+ * Invalid request - missing headers, malformed data, etc.
158
+ */
159
+ declare class GatewayInvalidRequestError extends GatewayError {
160
+ private readonly [symbol$3];
161
+ readonly name = "GatewayInvalidRequestError";
162
+ readonly type = "invalid_request_error";
163
+ constructor({ message, statusCode, cause, }?: {
164
+ message?: string;
165
+ statusCode?: number;
166
+ cause?: unknown;
167
+ });
168
+ static isInstance(error: unknown): error is GatewayInvalidRequestError;
169
+ }
170
+
171
+ declare const symbol$2: unique symbol;
172
+ /**
173
+ * Model not found or not available
174
+ */
175
+ declare class GatewayModelNotFoundError extends GatewayError {
176
+ private readonly [symbol$2];
177
+ readonly name = "GatewayModelNotFoundError";
178
+ readonly type = "model_not_found";
179
+ readonly modelId?: string;
180
+ constructor({ message, statusCode, modelId, cause, }?: {
181
+ message?: string;
182
+ statusCode?: number;
183
+ modelId?: string;
184
+ cause?: unknown;
185
+ });
186
+ static isInstance(error: unknown): error is GatewayModelNotFoundError;
187
+ }
188
+
189
+ declare const symbol$1: unique symbol;
190
+ /**
191
+ * Rate limit exceeded.
192
+ */
193
+ declare class GatewayRateLimitError extends GatewayError {
194
+ private readonly [symbol$1];
195
+ readonly name = "GatewayRateLimitError";
196
+ readonly type = "rate_limit_exceeded";
197
+ constructor({ message, statusCode, cause, }?: {
198
+ message?: string;
199
+ statusCode?: number;
200
+ cause?: unknown;
201
+ });
202
+ static isInstance(error: unknown): error is GatewayRateLimitError;
203
+ }
204
+
205
+ declare const symbol: unique symbol;
206
+ /**
207
+ * Gateway response parsing error
208
+ */
209
+ declare class GatewayResponseError extends GatewayError {
210
+ private readonly [symbol];
211
+ readonly name = "GatewayResponseError";
212
+ readonly type = "response_error";
213
+ readonly response?: unknown;
214
+ readonly validationError?: ZodError;
215
+ constructor({ message, statusCode, response, validationError, cause, }?: {
216
+ message?: string;
217
+ statusCode?: number;
218
+ response?: unknown;
219
+ validationError?: ZodError;
220
+ cause?: unknown;
221
+ });
222
+ static isInstance(error: unknown): error is GatewayResponseError;
223
+ }
224
+
225
+ export { GatewayAuthenticationError, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, createGatewayProvider, gateway };
@@ -0,0 +1,225 @@
1
+ import { LanguageModelV2, ProviderV2 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { z, ZodError } from 'zod';
4
+
5
+ type GatewayModelId = 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-3.7-sonnet-reasoning' | 'anthropic/claude-4-opus-20250514' | 'anthropic/claude-4-sonnet-20250514' | 'anthropic/claude-v3-haiku' | 'anthropic/claude-v3-opus' | 'anthropic/claude-v3.5-sonnet' | 'bedrock/amazon.nova-lite-v1:0' | 'bedrock/amazon.nova-micro-v1:0' | 'bedrock/amazon.nova-pro-v1:0' | 'bedrock/claude-3-5-haiku-20241022' | 'bedrock/claude-3-5-sonnet-20240620-v1' | 'bedrock/claude-3-5-sonnet-20241022-v2' | 'bedrock/claude-3-7-sonnet-20250219' | 'bedrock/claude-3-haiku-20240307-v1' | 'bedrock/claude-4-opus-20250514-v1' | 'bedrock/claude-4-sonnet-20250514-v1' | 'bedrock/deepseek.r1-v1' | 'bedrock/meta.llama3-1-70b-instruct-v1' | 'bedrock/meta.llama3-1-8b-instruct-v1' | 'bedrock/meta.llama3-2-11b-instruct-v1' | 'bedrock/meta.llama3-2-1b-instruct-v1' | 'bedrock/meta.llama3-2-3b-instruct-v1' | 'bedrock/meta.llama3-2-90b-instruct-v1' | 'bedrock/meta.llama3-3-70b-instruct-v1' | 'bedrock/meta.llama4-maverick-17b-instruct-v1' | 'bedrock/meta.llama4-scout-17b-instruct-v1' | 'cerebras/deepseek-r1-distill-llama-70b' | 'cerebras/llama-3.3-70b' | 'cerebras/llama-4-scout-17b-16e-instruct' | 'cerebras/llama3.1-8b' | 'cerebras/qwen-3-32b' | 'cohere/command-a' | 'cohere/command-r' | 'cohere/command-r-plus' | 'deepinfra/llama-4-maverick-17b-128e-instruct-fp8' | 'deepinfra/llama-4-scout-17b-16e-instruct' | 'deepinfra/qwen3-14b' | 'deepinfra/qwen3-235b-a22b' | 'deepinfra/qwen3-30b-a3b' | 'deepinfra/qwen3-32b' | 'deepseek/deepseek-r1-0528' | 'fireworks/deepseek-r1' | 'fireworks/deepseek-v3' | 'fireworks/mixtral-8x22b-instruct' | 'fireworks/qwen3-235b-a22b' | 'fireworks/qwq-32b' | 'groq/deepseek-r1-distill-llama-70b' | 'groq/gemma2-9b-it' | 'groq/llama-3-70b-instruct' | 'groq/llama-3-8b-instruct' | 'groq/llama-3.1-8b' | 'groq/llama-3.3-70b-versatile' | 'groq/llama-4-scout-17b-16e-instruct' | 'groq/mistral-saba-24b' | 'groq/qwen-qwq-32b' | 'inception/mercury-coder-small' | 'mistral/codestral-2501' | 'mistral/ministral-3b-latest' | 'mistral/ministral-8b-latest' | 'mistral/mistral-large' | 'mistral/mistral-small' | 'mistral/mistral-small-2503' | 'mistral/pixtral-12b-2409' | 'mistral/pixtral-large-latest' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/o3' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'vertex/claude-3-5-haiku-20241022' | 'vertex/claude-3-5-sonnet-20240620' | 'vertex/claude-3-5-sonnet-v2-20241022' | 'vertex/claude-3-7-sonnet-20250219' | 'vertex/claude-3-haiku-20240307' | 'vertex/claude-3-opus-20240229' | 'vertex/claude-4-opus-20250514' | 'vertex/claude-4-sonnet-20250514' | 'vertex/gemini-2.0-flash-001' | 'vertex/gemini-2.0-flash-lite-001' | 'vertex/llama-4-maverick-17b-128e-instruct-maas' | 'vertex/llama-4-scout-17b-16e-instruct-maas' | 'xai/grok-2-1212' | 'xai/grok-2-vision-1212' | 'xai/grok-3-beta' | 'xai/grok-3-fast-beta' | 'xai/grok-3-mini-beta' | 'xai/grok-3-mini-fast-beta' | (string & {});
6
+
7
+ interface GatewayLanguageModelEntry {
8
+ /**
9
+ * The model id used by the remote provider in model settings and for specifying the
10
+ * intended model for text generation.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The display name of the model for presentation in user-facing contexts.
15
+ */
16
+ name: string;
17
+ /**
18
+ * Additional AI SDK language model specifications for the model.
19
+ */
20
+ specification: GatewayLanguageModelSpecification;
21
+ }
22
+ type GatewayLanguageModelSpecification = Pick<LanguageModelV2, 'specificationVersion' | 'provider' | 'modelId'>;
23
+
24
+ interface GatewayFetchMetadataResponse {
25
+ models: GatewayLanguageModelEntry[];
26
+ }
27
+
28
+ interface GatewayProvider extends ProviderV2 {
29
+ (modelId: GatewayModelId): LanguageModelV2;
30
+ /**
31
+ Creates a model for text generation.
32
+ */
33
+ languageModel(modelId: GatewayModelId): LanguageModelV2;
34
+ /**
35
+ Returns available providers and models for use with the remote provider.
36
+ */
37
+ getAvailableModels(): Promise<GatewayFetchMetadataResponse>;
38
+ }
39
+ interface GatewayProviderSettings {
40
+ /**
41
+ The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.
42
+ */
43
+ baseURL?: string;
44
+ /**
45
+ API key that is being sent using the `Authorization` header.
46
+ */
47
+ apiKey?: string;
48
+ /**
49
+ Custom headers to include in the requests.
50
+ */
51
+ headers?: Record<string, string>;
52
+ /**
53
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
54
+ or to provide a custom fetch implementation for e.g. testing.
55
+ */
56
+ fetch?: FetchFunction;
57
+ /**
58
+ How frequently to refresh the metadata cache in milliseconds.
59
+ */
60
+ metadataCacheRefreshMillis?: number;
61
+ }
62
+ /**
63
+ Create a remote provider instance.
64
+ */
65
+ declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
66
+ declare const gateway: GatewayProvider;
67
+
68
+ declare const symbol$6: unique symbol;
69
+ declare abstract class GatewayError extends Error {
70
+ private readonly [symbol$6];
71
+ abstract readonly name: string;
72
+ abstract readonly type: string;
73
+ readonly statusCode: number;
74
+ readonly cause?: unknown;
75
+ constructor({ message, statusCode, cause, }: {
76
+ message: string;
77
+ statusCode?: number;
78
+ cause?: unknown;
79
+ });
80
+ /**
81
+ * Checks if the given error is a Gateway Error.
82
+ * @param {unknown} error - The error to check.
83
+ * @returns {boolean} True if the error is a Gateway Error, false otherwise.
84
+ */
85
+ static isInstance(error: unknown): error is GatewayError;
86
+ static hasMarker(error: unknown): error is GatewayError;
87
+ }
88
+
89
+ declare const gatewayErrorResponseSchema: z.ZodObject<{
90
+ error: z.ZodObject<{
91
+ message: z.ZodString;
92
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
+ param: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
94
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
95
+ }, "strip", z.ZodTypeAny, {
96
+ message: string;
97
+ code?: string | number | null | undefined;
98
+ type?: string | null | undefined;
99
+ param?: unknown;
100
+ }, {
101
+ message: string;
102
+ code?: string | number | null | undefined;
103
+ type?: string | null | undefined;
104
+ param?: unknown;
105
+ }>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ error: {
108
+ message: string;
109
+ code?: string | number | null | undefined;
110
+ type?: string | null | undefined;
111
+ param?: unknown;
112
+ };
113
+ }, {
114
+ error: {
115
+ message: string;
116
+ code?: string | number | null | undefined;
117
+ type?: string | null | undefined;
118
+ param?: unknown;
119
+ };
120
+ }>;
121
+ type GatewayErrorResponse = z.infer<typeof gatewayErrorResponseSchema>;
122
+
123
+ declare const symbol$5: unique symbol;
124
+ /**
125
+ * Authentication failed - invalid API key or OIDC token
126
+ */
127
+ declare class GatewayAuthenticationError extends GatewayError {
128
+ private readonly [symbol$5];
129
+ readonly name = "GatewayAuthenticationError";
130
+ readonly type = "authentication_error";
131
+ constructor({ message, statusCode, cause, }?: {
132
+ message?: string;
133
+ statusCode?: number;
134
+ cause?: unknown;
135
+ });
136
+ static isInstance(error: unknown): error is GatewayAuthenticationError;
137
+ }
138
+
139
+ declare const symbol$4: unique symbol;
140
+ /**
141
+ * Internal server error from the Gateway
142
+ */
143
+ declare class GatewayInternalServerError extends GatewayError {
144
+ private readonly [symbol$4];
145
+ readonly name = "GatewayInternalServerError";
146
+ readonly type = "internal_server_error";
147
+ constructor({ message, statusCode, cause, }?: {
148
+ message?: string;
149
+ statusCode?: number;
150
+ cause?: unknown;
151
+ });
152
+ static isInstance(error: unknown): error is GatewayInternalServerError;
153
+ }
154
+
155
+ declare const symbol$3: unique symbol;
156
+ /**
157
+ * Invalid request - missing headers, malformed data, etc.
158
+ */
159
+ declare class GatewayInvalidRequestError extends GatewayError {
160
+ private readonly [symbol$3];
161
+ readonly name = "GatewayInvalidRequestError";
162
+ readonly type = "invalid_request_error";
163
+ constructor({ message, statusCode, cause, }?: {
164
+ message?: string;
165
+ statusCode?: number;
166
+ cause?: unknown;
167
+ });
168
+ static isInstance(error: unknown): error is GatewayInvalidRequestError;
169
+ }
170
+
171
+ declare const symbol$2: unique symbol;
172
+ /**
173
+ * Model not found or not available
174
+ */
175
+ declare class GatewayModelNotFoundError extends GatewayError {
176
+ private readonly [symbol$2];
177
+ readonly name = "GatewayModelNotFoundError";
178
+ readonly type = "model_not_found";
179
+ readonly modelId?: string;
180
+ constructor({ message, statusCode, modelId, cause, }?: {
181
+ message?: string;
182
+ statusCode?: number;
183
+ modelId?: string;
184
+ cause?: unknown;
185
+ });
186
+ static isInstance(error: unknown): error is GatewayModelNotFoundError;
187
+ }
188
+
189
+ declare const symbol$1: unique symbol;
190
+ /**
191
+ * Rate limit exceeded.
192
+ */
193
+ declare class GatewayRateLimitError extends GatewayError {
194
+ private readonly [symbol$1];
195
+ readonly name = "GatewayRateLimitError";
196
+ readonly type = "rate_limit_exceeded";
197
+ constructor({ message, statusCode, cause, }?: {
198
+ message?: string;
199
+ statusCode?: number;
200
+ cause?: unknown;
201
+ });
202
+ static isInstance(error: unknown): error is GatewayRateLimitError;
203
+ }
204
+
205
+ declare const symbol: unique symbol;
206
+ /**
207
+ * Gateway response parsing error
208
+ */
209
+ declare class GatewayResponseError extends GatewayError {
210
+ private readonly [symbol];
211
+ readonly name = "GatewayResponseError";
212
+ readonly type = "response_error";
213
+ readonly response?: unknown;
214
+ readonly validationError?: ZodError;
215
+ constructor({ message, statusCode, response, validationError, cause, }?: {
216
+ message?: string;
217
+ statusCode?: number;
218
+ response?: unknown;
219
+ validationError?: ZodError;
220
+ cause?: unknown;
221
+ });
222
+ static isInstance(error: unknown): error is GatewayResponseError;
223
+ }
224
+
225
+ export { GatewayAuthenticationError, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, createGatewayProvider, gateway };