@ai-sdk/gateway 0.0.0-70e0935a-20260114150030 → 0.0.0-98261322-20260122142521
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 +49 -4
- package/dist/index.d.mts +20 -10
- package/dist/index.d.ts +20 -10
- package/dist/index.js +62 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -25
- package/dist/index.mjs.map +1 -1
- package/docs/00-ai-gateway.mdx +625 -0
- package/package.json +12 -5
- package/src/errors/as-gateway-error.ts +33 -0
- package/src/errors/create-gateway-error.test.ts +590 -0
- package/src/errors/create-gateway-error.ts +132 -0
- package/src/errors/extract-api-call-response.test.ts +270 -0
- package/src/errors/extract-api-call-response.ts +15 -0
- package/src/errors/gateway-authentication-error.ts +84 -0
- package/src/errors/gateway-error-types.test.ts +278 -0
- package/src/errors/gateway-error.ts +47 -0
- package/src/errors/gateway-internal-server-error.ts +33 -0
- package/src/errors/gateway-invalid-request-error.ts +33 -0
- package/src/errors/gateway-model-not-found-error.ts +47 -0
- package/src/errors/gateway-rate-limit-error.ts +33 -0
- package/src/errors/gateway-response-error.ts +42 -0
- package/src/errors/index.ts +16 -0
- package/src/errors/parse-auth-method.test.ts +136 -0
- package/src/errors/parse-auth-method.ts +23 -0
- package/src/gateway-config.ts +7 -0
- package/src/gateway-embedding-model-settings.ts +22 -0
- package/src/gateway-embedding-model.test.ts +213 -0
- package/src/gateway-embedding-model.ts +109 -0
- package/src/gateway-fetch-metadata.test.ts +774 -0
- package/src/gateway-fetch-metadata.ts +127 -0
- package/src/gateway-image-model-settings.ts +12 -0
- package/src/gateway-image-model.test.ts +823 -0
- package/src/gateway-image-model.ts +145 -0
- package/src/gateway-language-model-settings.ts +159 -0
- package/src/gateway-language-model.test.ts +1485 -0
- package/src/gateway-language-model.ts +212 -0
- package/src/gateway-model-entry.ts +58 -0
- package/src/gateway-provider-options.ts +66 -0
- package/src/gateway-provider.test.ts +1210 -0
- package/src/gateway-provider.ts +284 -0
- package/src/gateway-tools.ts +15 -0
- package/src/index.ts +27 -0
- package/src/tool/perplexity-search.ts +294 -0
- package/src/vercel-environment.test.ts +65 -0
- package/src/vercel-environment.ts +6 -0
- package/src/version.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,57 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-98261322-20260122142521
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- 080559b: chore: add docs to package dist
|
|
8
|
+
|
|
9
|
+
## 3.0.20
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8dc54db: chore: add src folders to package bundle
|
|
14
|
+
|
|
15
|
+
## 3.0.19
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- c60fdd8: Inline fullMessage variable in GatewayError constructor
|
|
20
|
+
|
|
21
|
+
## 3.0.18
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 7af4eb4: chore(provider/gateway): update gateway model settings files
|
|
26
|
+
|
|
27
|
+
## 3.0.17
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 66d78d5: chore(provider/gateway): update gateway model settings files
|
|
32
|
+
|
|
33
|
+
## 3.0.16
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [5c090e7]
|
|
38
|
+
- @ai-sdk/provider@3.0.4
|
|
39
|
+
- @ai-sdk/provider-utils@4.0.8
|
|
40
|
+
|
|
41
|
+
## 3.0.15
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [46f46e4]
|
|
46
|
+
- @ai-sdk/provider-utils@4.0.7
|
|
47
|
+
|
|
48
|
+
## 3.0.14
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [1b11dcb]
|
|
53
|
+
- @ai-sdk/provider-utils@4.0.6
|
|
54
|
+
- @ai-sdk/provider@3.0.3
|
|
10
55
|
|
|
11
56
|
## 3.0.13
|
|
12
57
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-image-preview' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | '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/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'stealth/sonoma-dusk-alpha' | 'stealth/sonoma-sky-alpha' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2
|
|
5
|
+
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-image-preview' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | '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/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'stealth/sonoma-dusk-alpha' | 'stealth/sonoma-sky-alpha' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
6
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
|
@@ -64,7 +64,7 @@ interface GatewayCreditsResponse {
|
|
|
64
64
|
|
|
65
65
|
type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
|
|
66
66
|
|
|
67
|
-
type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | (string & {});
|
|
67
|
+
type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | (string & {});
|
|
68
68
|
|
|
69
69
|
interface PerplexitySearchConfig {
|
|
70
70
|
/**
|
|
@@ -286,10 +286,12 @@ declare abstract class GatewayError extends Error {
|
|
|
286
286
|
abstract readonly type: string;
|
|
287
287
|
readonly statusCode: number;
|
|
288
288
|
readonly cause?: unknown;
|
|
289
|
-
|
|
289
|
+
readonly generationId?: string;
|
|
290
|
+
constructor({ message, statusCode, cause, generationId, }: {
|
|
290
291
|
message: string;
|
|
291
292
|
statusCode?: number;
|
|
292
293
|
cause?: unknown;
|
|
294
|
+
generationId?: string;
|
|
293
295
|
});
|
|
294
296
|
/**
|
|
295
297
|
* Checks if the given error is a Gateway Error.
|
|
@@ -307,6 +309,7 @@ declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
307
309
|
param?: unknown;
|
|
308
310
|
code?: string | number | null | undefined;
|
|
309
311
|
};
|
|
312
|
+
generationId?: string | null | undefined;
|
|
310
313
|
}>;
|
|
311
314
|
type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
|
|
312
315
|
|
|
@@ -318,21 +321,23 @@ declare class GatewayAuthenticationError extends GatewayError {
|
|
|
318
321
|
private readonly [symbol$5];
|
|
319
322
|
readonly name = "GatewayAuthenticationError";
|
|
320
323
|
readonly type = "authentication_error";
|
|
321
|
-
constructor({ message, statusCode, cause, }?: {
|
|
324
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
322
325
|
message?: string;
|
|
323
326
|
statusCode?: number;
|
|
324
327
|
cause?: unknown;
|
|
328
|
+
generationId?: string;
|
|
325
329
|
});
|
|
326
330
|
static isInstance(error: unknown): error is GatewayAuthenticationError;
|
|
327
331
|
/**
|
|
328
332
|
* Creates a contextual error message when authentication fails
|
|
329
333
|
*/
|
|
330
|
-
static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, }: {
|
|
334
|
+
static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, generationId, }: {
|
|
331
335
|
apiKeyProvided: boolean;
|
|
332
336
|
oidcTokenProvided: boolean;
|
|
333
337
|
message?: string;
|
|
334
338
|
statusCode?: number;
|
|
335
339
|
cause?: unknown;
|
|
340
|
+
generationId?: string;
|
|
336
341
|
}): GatewayAuthenticationError;
|
|
337
342
|
}
|
|
338
343
|
|
|
@@ -344,10 +349,11 @@ declare class GatewayInternalServerError extends GatewayError {
|
|
|
344
349
|
private readonly [symbol$4];
|
|
345
350
|
readonly name = "GatewayInternalServerError";
|
|
346
351
|
readonly type = "internal_server_error";
|
|
347
|
-
constructor({ message, statusCode, cause, }?: {
|
|
352
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
348
353
|
message?: string;
|
|
349
354
|
statusCode?: number;
|
|
350
355
|
cause?: unknown;
|
|
356
|
+
generationId?: string;
|
|
351
357
|
});
|
|
352
358
|
static isInstance(error: unknown): error is GatewayInternalServerError;
|
|
353
359
|
}
|
|
@@ -360,10 +366,11 @@ declare class GatewayInvalidRequestError extends GatewayError {
|
|
|
360
366
|
private readonly [symbol$3];
|
|
361
367
|
readonly name = "GatewayInvalidRequestError";
|
|
362
368
|
readonly type = "invalid_request_error";
|
|
363
|
-
constructor({ message, statusCode, cause, }?: {
|
|
369
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
364
370
|
message?: string;
|
|
365
371
|
statusCode?: number;
|
|
366
372
|
cause?: unknown;
|
|
373
|
+
generationId?: string;
|
|
367
374
|
});
|
|
368
375
|
static isInstance(error: unknown): error is GatewayInvalidRequestError;
|
|
369
376
|
}
|
|
@@ -377,11 +384,12 @@ declare class GatewayModelNotFoundError extends GatewayError {
|
|
|
377
384
|
readonly name = "GatewayModelNotFoundError";
|
|
378
385
|
readonly type = "model_not_found";
|
|
379
386
|
readonly modelId?: string;
|
|
380
|
-
constructor({ message, statusCode, modelId, cause, }?: {
|
|
387
|
+
constructor({ message, statusCode, modelId, cause, generationId, }?: {
|
|
381
388
|
message?: string;
|
|
382
389
|
statusCode?: number;
|
|
383
390
|
modelId?: string;
|
|
384
391
|
cause?: unknown;
|
|
392
|
+
generationId?: string;
|
|
385
393
|
});
|
|
386
394
|
static isInstance(error: unknown): error is GatewayModelNotFoundError;
|
|
387
395
|
}
|
|
@@ -394,10 +402,11 @@ declare class GatewayRateLimitError extends GatewayError {
|
|
|
394
402
|
private readonly [symbol$1];
|
|
395
403
|
readonly name = "GatewayRateLimitError";
|
|
396
404
|
readonly type = "rate_limit_exceeded";
|
|
397
|
-
constructor({ message, statusCode, cause, }?: {
|
|
405
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
398
406
|
message?: string;
|
|
399
407
|
statusCode?: number;
|
|
400
408
|
cause?: unknown;
|
|
409
|
+
generationId?: string;
|
|
401
410
|
});
|
|
402
411
|
static isInstance(error: unknown): error is GatewayRateLimitError;
|
|
403
412
|
}
|
|
@@ -412,12 +421,13 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
412
421
|
readonly type = "response_error";
|
|
413
422
|
readonly response?: unknown;
|
|
414
423
|
readonly validationError?: TypeValidationError;
|
|
415
|
-
constructor({ message, statusCode, response, validationError, cause, }?: {
|
|
424
|
+
constructor({ message, statusCode, response, validationError, cause, generationId, }?: {
|
|
416
425
|
message?: string;
|
|
417
426
|
statusCode?: number;
|
|
418
427
|
response?: unknown;
|
|
419
428
|
validationError?: TypeValidationError;
|
|
420
429
|
cause?: unknown;
|
|
430
|
+
generationId?: string;
|
|
421
431
|
});
|
|
422
432
|
static isInstance(error: unknown): error is GatewayResponseError;
|
|
423
433
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-image-preview' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | '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/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'stealth/sonoma-dusk-alpha' | 'stealth/sonoma-sky-alpha' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2
|
|
5
|
+
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-image-preview' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | '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/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'stealth/sonoma-dusk-alpha' | 'stealth/sonoma-sky-alpha' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
6
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
|
@@ -64,7 +64,7 @@ interface GatewayCreditsResponse {
|
|
|
64
64
|
|
|
65
65
|
type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
|
|
66
66
|
|
|
67
|
-
type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | (string & {});
|
|
67
|
+
type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | (string & {});
|
|
68
68
|
|
|
69
69
|
interface PerplexitySearchConfig {
|
|
70
70
|
/**
|
|
@@ -286,10 +286,12 @@ declare abstract class GatewayError extends Error {
|
|
|
286
286
|
abstract readonly type: string;
|
|
287
287
|
readonly statusCode: number;
|
|
288
288
|
readonly cause?: unknown;
|
|
289
|
-
|
|
289
|
+
readonly generationId?: string;
|
|
290
|
+
constructor({ message, statusCode, cause, generationId, }: {
|
|
290
291
|
message: string;
|
|
291
292
|
statusCode?: number;
|
|
292
293
|
cause?: unknown;
|
|
294
|
+
generationId?: string;
|
|
293
295
|
});
|
|
294
296
|
/**
|
|
295
297
|
* Checks if the given error is a Gateway Error.
|
|
@@ -307,6 +309,7 @@ declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
307
309
|
param?: unknown;
|
|
308
310
|
code?: string | number | null | undefined;
|
|
309
311
|
};
|
|
312
|
+
generationId?: string | null | undefined;
|
|
310
313
|
}>;
|
|
311
314
|
type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
|
|
312
315
|
|
|
@@ -318,21 +321,23 @@ declare class GatewayAuthenticationError extends GatewayError {
|
|
|
318
321
|
private readonly [symbol$5];
|
|
319
322
|
readonly name = "GatewayAuthenticationError";
|
|
320
323
|
readonly type = "authentication_error";
|
|
321
|
-
constructor({ message, statusCode, cause, }?: {
|
|
324
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
322
325
|
message?: string;
|
|
323
326
|
statusCode?: number;
|
|
324
327
|
cause?: unknown;
|
|
328
|
+
generationId?: string;
|
|
325
329
|
});
|
|
326
330
|
static isInstance(error: unknown): error is GatewayAuthenticationError;
|
|
327
331
|
/**
|
|
328
332
|
* Creates a contextual error message when authentication fails
|
|
329
333
|
*/
|
|
330
|
-
static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, }: {
|
|
334
|
+
static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, generationId, }: {
|
|
331
335
|
apiKeyProvided: boolean;
|
|
332
336
|
oidcTokenProvided: boolean;
|
|
333
337
|
message?: string;
|
|
334
338
|
statusCode?: number;
|
|
335
339
|
cause?: unknown;
|
|
340
|
+
generationId?: string;
|
|
336
341
|
}): GatewayAuthenticationError;
|
|
337
342
|
}
|
|
338
343
|
|
|
@@ -344,10 +349,11 @@ declare class GatewayInternalServerError extends GatewayError {
|
|
|
344
349
|
private readonly [symbol$4];
|
|
345
350
|
readonly name = "GatewayInternalServerError";
|
|
346
351
|
readonly type = "internal_server_error";
|
|
347
|
-
constructor({ message, statusCode, cause, }?: {
|
|
352
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
348
353
|
message?: string;
|
|
349
354
|
statusCode?: number;
|
|
350
355
|
cause?: unknown;
|
|
356
|
+
generationId?: string;
|
|
351
357
|
});
|
|
352
358
|
static isInstance(error: unknown): error is GatewayInternalServerError;
|
|
353
359
|
}
|
|
@@ -360,10 +366,11 @@ declare class GatewayInvalidRequestError extends GatewayError {
|
|
|
360
366
|
private readonly [symbol$3];
|
|
361
367
|
readonly name = "GatewayInvalidRequestError";
|
|
362
368
|
readonly type = "invalid_request_error";
|
|
363
|
-
constructor({ message, statusCode, cause, }?: {
|
|
369
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
364
370
|
message?: string;
|
|
365
371
|
statusCode?: number;
|
|
366
372
|
cause?: unknown;
|
|
373
|
+
generationId?: string;
|
|
367
374
|
});
|
|
368
375
|
static isInstance(error: unknown): error is GatewayInvalidRequestError;
|
|
369
376
|
}
|
|
@@ -377,11 +384,12 @@ declare class GatewayModelNotFoundError extends GatewayError {
|
|
|
377
384
|
readonly name = "GatewayModelNotFoundError";
|
|
378
385
|
readonly type = "model_not_found";
|
|
379
386
|
readonly modelId?: string;
|
|
380
|
-
constructor({ message, statusCode, modelId, cause, }?: {
|
|
387
|
+
constructor({ message, statusCode, modelId, cause, generationId, }?: {
|
|
381
388
|
message?: string;
|
|
382
389
|
statusCode?: number;
|
|
383
390
|
modelId?: string;
|
|
384
391
|
cause?: unknown;
|
|
392
|
+
generationId?: string;
|
|
385
393
|
});
|
|
386
394
|
static isInstance(error: unknown): error is GatewayModelNotFoundError;
|
|
387
395
|
}
|
|
@@ -394,10 +402,11 @@ declare class GatewayRateLimitError extends GatewayError {
|
|
|
394
402
|
private readonly [symbol$1];
|
|
395
403
|
readonly name = "GatewayRateLimitError";
|
|
396
404
|
readonly type = "rate_limit_exceeded";
|
|
397
|
-
constructor({ message, statusCode, cause, }?: {
|
|
405
|
+
constructor({ message, statusCode, cause, generationId, }?: {
|
|
398
406
|
message?: string;
|
|
399
407
|
statusCode?: number;
|
|
400
408
|
cause?: unknown;
|
|
409
|
+
generationId?: string;
|
|
401
410
|
});
|
|
402
411
|
static isInstance(error: unknown): error is GatewayRateLimitError;
|
|
403
412
|
}
|
|
@@ -412,12 +421,13 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
412
421
|
readonly type = "response_error";
|
|
413
422
|
readonly response?: unknown;
|
|
414
423
|
readonly validationError?: TypeValidationError;
|
|
415
|
-
constructor({ message, statusCode, response, validationError, cause, }?: {
|
|
424
|
+
constructor({ message, statusCode, response, validationError, cause, generationId, }?: {
|
|
416
425
|
message?: string;
|
|
417
426
|
statusCode?: number;
|
|
418
427
|
response?: unknown;
|
|
419
428
|
validationError?: TypeValidationError;
|
|
420
429
|
cause?: unknown;
|
|
430
|
+
generationId?: string;
|
|
421
431
|
});
|
|
422
432
|
static isInstance(error: unknown): error is GatewayResponseError;
|
|
423
433
|
}
|
package/dist/index.js
CHANGED
|
@@ -50,12 +50,14 @@ var GatewayError = class _GatewayError extends (_b = Error, _a = symbol, _b) {
|
|
|
50
50
|
constructor({
|
|
51
51
|
message,
|
|
52
52
|
statusCode = 500,
|
|
53
|
-
cause
|
|
53
|
+
cause,
|
|
54
|
+
generationId
|
|
54
55
|
}) {
|
|
55
|
-
super(message);
|
|
56
|
+
super(generationId ? `${message} [${generationId}]` : message);
|
|
56
57
|
this[_a] = true;
|
|
57
58
|
this.statusCode = statusCode;
|
|
58
59
|
this.cause = cause;
|
|
60
|
+
this.generationId = generationId;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Checks if the given error is a Gateway Error.
|
|
@@ -79,9 +81,10 @@ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2
|
|
|
79
81
|
constructor({
|
|
80
82
|
message = "Authentication failed",
|
|
81
83
|
statusCode = 401,
|
|
82
|
-
cause
|
|
84
|
+
cause,
|
|
85
|
+
generationId
|
|
83
86
|
} = {}) {
|
|
84
|
-
super({ message, statusCode, cause });
|
|
87
|
+
super({ message, statusCode, cause, generationId });
|
|
85
88
|
this[_a2] = true;
|
|
86
89
|
// used in isInstance
|
|
87
90
|
this.name = name;
|
|
@@ -98,7 +101,8 @@ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2
|
|
|
98
101
|
oidcTokenProvided,
|
|
99
102
|
message = "Authentication failed",
|
|
100
103
|
statusCode = 401,
|
|
101
|
-
cause
|
|
104
|
+
cause,
|
|
105
|
+
generationId
|
|
102
106
|
}) {
|
|
103
107
|
let contextualMessage;
|
|
104
108
|
if (apiKeyProvided) {
|
|
@@ -126,7 +130,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
126
130
|
return new _GatewayAuthenticationError({
|
|
127
131
|
message: contextualMessage,
|
|
128
132
|
statusCode,
|
|
129
|
-
cause
|
|
133
|
+
cause,
|
|
134
|
+
generationId
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
};
|
|
@@ -140,9 +145,10 @@ var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a3 = symbol
|
|
|
140
145
|
constructor({
|
|
141
146
|
message = "Invalid request",
|
|
142
147
|
statusCode = 400,
|
|
143
|
-
cause
|
|
148
|
+
cause,
|
|
149
|
+
generationId
|
|
144
150
|
} = {}) {
|
|
145
|
-
super({ message, statusCode, cause });
|
|
151
|
+
super({ message, statusCode, cause, generationId });
|
|
146
152
|
this[_a3] = true;
|
|
147
153
|
// used in isInstance
|
|
148
154
|
this.name = name2;
|
|
@@ -162,9 +168,10 @@ var GatewayRateLimitError = class extends (_b4 = GatewayError, _a4 = symbol4, _b
|
|
|
162
168
|
constructor({
|
|
163
169
|
message = "Rate limit exceeded",
|
|
164
170
|
statusCode = 429,
|
|
165
|
-
cause
|
|
171
|
+
cause,
|
|
172
|
+
generationId
|
|
166
173
|
} = {}) {
|
|
167
|
-
super({ message, statusCode, cause });
|
|
174
|
+
super({ message, statusCode, cause, generationId });
|
|
168
175
|
this[_a4] = true;
|
|
169
176
|
// used in isInstance
|
|
170
177
|
this.name = name3;
|
|
@@ -194,9 +201,10 @@ var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a5 = symbol5
|
|
|
194
201
|
message = "Model not found",
|
|
195
202
|
statusCode = 404,
|
|
196
203
|
modelId,
|
|
197
|
-
cause
|
|
204
|
+
cause,
|
|
205
|
+
generationId
|
|
198
206
|
} = {}) {
|
|
199
|
-
super({ message, statusCode, cause });
|
|
207
|
+
super({ message, statusCode, cause, generationId });
|
|
200
208
|
this[_a5] = true;
|
|
201
209
|
// used in isInstance
|
|
202
210
|
this.name = name4;
|
|
@@ -217,9 +225,10 @@ var GatewayInternalServerError = class extends (_b6 = GatewayError, _a6 = symbol
|
|
|
217
225
|
constructor({
|
|
218
226
|
message = "Internal server error",
|
|
219
227
|
statusCode = 500,
|
|
220
|
-
cause
|
|
228
|
+
cause,
|
|
229
|
+
generationId
|
|
221
230
|
} = {}) {
|
|
222
|
-
super({ message, statusCode, cause });
|
|
231
|
+
super({ message, statusCode, cause, generationId });
|
|
223
232
|
this[_a6] = true;
|
|
224
233
|
// used in isInstance
|
|
225
234
|
this.name = name5;
|
|
@@ -241,9 +250,10 @@ var GatewayResponseError = class extends (_b7 = GatewayError, _a7 = symbol7, _b7
|
|
|
241
250
|
statusCode = 502,
|
|
242
251
|
response,
|
|
243
252
|
validationError,
|
|
244
|
-
cause
|
|
253
|
+
cause,
|
|
254
|
+
generationId
|
|
245
255
|
} = {}) {
|
|
246
|
-
super({ message, statusCode, cause });
|
|
256
|
+
super({ message, statusCode, cause, generationId });
|
|
247
257
|
this[_a7] = true;
|
|
248
258
|
// used in isInstance
|
|
249
259
|
this.name = name6;
|
|
@@ -265,34 +275,49 @@ async function createGatewayErrorFromResponse({
|
|
|
265
275
|
cause,
|
|
266
276
|
authMethod
|
|
267
277
|
}) {
|
|
278
|
+
var _a8;
|
|
268
279
|
const parseResult = await (0, import_provider_utils2.safeValidateTypes)({
|
|
269
280
|
value: response,
|
|
270
281
|
schema: gatewayErrorResponseSchema
|
|
271
282
|
});
|
|
272
283
|
if (!parseResult.success) {
|
|
284
|
+
const rawGenerationId = typeof response === "object" && response !== null && "generationId" in response ? response.generationId : void 0;
|
|
273
285
|
return new GatewayResponseError({
|
|
274
286
|
message: `Invalid error response format: ${defaultMessage}`,
|
|
275
287
|
statusCode,
|
|
276
288
|
response,
|
|
277
289
|
validationError: parseResult.error,
|
|
278
|
-
cause
|
|
290
|
+
cause,
|
|
291
|
+
generationId: rawGenerationId
|
|
279
292
|
});
|
|
280
293
|
}
|
|
281
294
|
const validatedResponse = parseResult.value;
|
|
282
295
|
const errorType = validatedResponse.error.type;
|
|
283
296
|
const message = validatedResponse.error.message;
|
|
297
|
+
const generationId = (_a8 = validatedResponse.generationId) != null ? _a8 : void 0;
|
|
284
298
|
switch (errorType) {
|
|
285
299
|
case "authentication_error":
|
|
286
300
|
return GatewayAuthenticationError.createContextualError({
|
|
287
301
|
apiKeyProvided: authMethod === "api-key",
|
|
288
302
|
oidcTokenProvided: authMethod === "oidc",
|
|
289
303
|
statusCode,
|
|
290
|
-
cause
|
|
304
|
+
cause,
|
|
305
|
+
generationId
|
|
291
306
|
});
|
|
292
307
|
case "invalid_request_error":
|
|
293
|
-
return new GatewayInvalidRequestError({
|
|
308
|
+
return new GatewayInvalidRequestError({
|
|
309
|
+
message,
|
|
310
|
+
statusCode,
|
|
311
|
+
cause,
|
|
312
|
+
generationId
|
|
313
|
+
});
|
|
294
314
|
case "rate_limit_exceeded":
|
|
295
|
-
return new GatewayRateLimitError({
|
|
315
|
+
return new GatewayRateLimitError({
|
|
316
|
+
message,
|
|
317
|
+
statusCode,
|
|
318
|
+
cause,
|
|
319
|
+
generationId
|
|
320
|
+
});
|
|
296
321
|
case "model_not_found": {
|
|
297
322
|
const modelResult = await (0, import_provider_utils2.safeValidateTypes)({
|
|
298
323
|
value: validatedResponse.error.param,
|
|
@@ -302,13 +327,24 @@ async function createGatewayErrorFromResponse({
|
|
|
302
327
|
message,
|
|
303
328
|
statusCode,
|
|
304
329
|
modelId: modelResult.success ? modelResult.value.modelId : void 0,
|
|
305
|
-
cause
|
|
330
|
+
cause,
|
|
331
|
+
generationId
|
|
306
332
|
});
|
|
307
333
|
}
|
|
308
334
|
case "internal_server_error":
|
|
309
|
-
return new GatewayInternalServerError({
|
|
335
|
+
return new GatewayInternalServerError({
|
|
336
|
+
message,
|
|
337
|
+
statusCode,
|
|
338
|
+
cause,
|
|
339
|
+
generationId
|
|
340
|
+
});
|
|
310
341
|
default:
|
|
311
|
-
return new GatewayInternalServerError({
|
|
342
|
+
return new GatewayInternalServerError({
|
|
343
|
+
message,
|
|
344
|
+
statusCode,
|
|
345
|
+
cause,
|
|
346
|
+
generationId
|
|
347
|
+
});
|
|
312
348
|
}
|
|
313
349
|
}
|
|
314
350
|
var gatewayErrorResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
@@ -319,7 +355,8 @@ var gatewayErrorResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
319
355
|
type: import_v42.z.string().nullish(),
|
|
320
356
|
param: import_v42.z.unknown().nullish(),
|
|
321
357
|
code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
|
|
322
|
-
})
|
|
358
|
+
}),
|
|
359
|
+
generationId: import_v42.z.string().nullish()
|
|
323
360
|
})
|
|
324
361
|
)
|
|
325
362
|
);
|
|
@@ -917,7 +954,7 @@ async function getVercelRequestId() {
|
|
|
917
954
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
918
955
|
|
|
919
956
|
// src/version.ts
|
|
920
|
-
var VERSION = true ? "0.0.0-
|
|
957
|
+
var VERSION = true ? "0.0.0-98261322-20260122142521" : "0.0.0-test";
|
|
921
958
|
|
|
922
959
|
// src/gateway-provider.ts
|
|
923
960
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|