@ai-sdk/gateway 2.0.22 → 3.0.0
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 +689 -98
- package/dist/index.d.mts +18 -13
- package/dist/index.d.ts +18 -13
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { FetchFunction,
|
|
3
|
+
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
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-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' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-exp-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-pro-preview' | 'google/gemini-3-pro-image' | 'google/gemini-3-flash' | 'inception/mercury-coder-small' | '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' | 'mistral/codestral' | 'mistral/devstral-small' | 'mistral/magistral-medium' | 'mistral/magistral-medium-2506' | 'mistral/magistral-small' | 'mistral/magistral-small-2506' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large' | 'mistral/mistral-medium' | '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' | '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-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat-latest' | '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/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' | '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-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-code-fast-1' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | (string & {});
|
|
6
6
|
|
|
@@ -50,7 +50,7 @@ interface GatewayLanguageModelEntry {
|
|
|
50
50
|
*/
|
|
51
51
|
modelType?: 'language' | 'embedding' | 'image' | null;
|
|
52
52
|
}
|
|
53
|
-
type GatewayLanguageModelSpecification = Pick<
|
|
53
|
+
type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
|
|
54
54
|
|
|
55
55
|
interface GatewayFetchMetadataResponse {
|
|
56
56
|
models: GatewayLanguageModelEntry[];
|
|
@@ -64,14 +64,14 @@ interface GatewayCreditsResponse {
|
|
|
64
64
|
|
|
65
65
|
type GatewayEmbeddingModelId = '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-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | 'voyage/voyage-code-2' | (string & {});
|
|
66
66
|
|
|
67
|
-
type GatewayImageModelId = 'google/imagen-4.0-generate' | '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' | (string & {});
|
|
67
|
+
type GatewayImageModelId = 'google/imagen-4.0-generate' | 'google/imagen-4.0-ultra-generate' | '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' | (string & {});
|
|
68
68
|
|
|
69
|
-
interface GatewayProvider extends
|
|
70
|
-
(modelId: GatewayModelId):
|
|
69
|
+
interface GatewayProvider extends ProviderV3 {
|
|
70
|
+
(modelId: GatewayModelId): LanguageModelV3;
|
|
71
71
|
/**
|
|
72
72
|
Creates a model for text generation.
|
|
73
73
|
*/
|
|
74
|
-
languageModel(modelId: GatewayModelId):
|
|
74
|
+
languageModel(modelId: GatewayModelId): LanguageModelV3;
|
|
75
75
|
/**
|
|
76
76
|
Returns available providers and models for use with the remote provider.
|
|
77
77
|
*/
|
|
@@ -83,11 +83,15 @@ interface GatewayProvider extends ProviderV2 {
|
|
|
83
83
|
/**
|
|
84
84
|
Creates a model for generating text embeddings.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `embeddingModel` instead.
|
|
89
|
+
*/
|
|
90
|
+
textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
87
91
|
/**
|
|
88
92
|
Creates a model for generating images.
|
|
89
93
|
*/
|
|
90
|
-
imageModel(modelId: GatewayImageModelId):
|
|
94
|
+
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
91
95
|
}
|
|
92
96
|
interface GatewayProviderSettings {
|
|
93
97
|
/**
|
|
@@ -118,15 +122,16 @@ Create a remote provider instance.
|
|
|
118
122
|
declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
|
|
119
123
|
declare const gateway: GatewayProvider;
|
|
120
124
|
|
|
121
|
-
declare const gatewayProviderOptions: _ai_sdk_provider_utils.
|
|
125
|
+
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
122
126
|
only?: string[] | undefined;
|
|
123
127
|
order?: string[] | undefined;
|
|
124
128
|
user?: string | undefined;
|
|
125
129
|
tags?: string[] | undefined;
|
|
126
130
|
models?: string[] | undefined;
|
|
127
131
|
byok?: Record<string, Record<string, unknown>[]> | undefined;
|
|
132
|
+
zeroDataRetention?: boolean | undefined;
|
|
128
133
|
}>;
|
|
129
|
-
type GatewayProviderOptions =
|
|
134
|
+
type GatewayProviderOptions = InferSchema<typeof gatewayProviderOptions>;
|
|
130
135
|
|
|
131
136
|
declare const symbol$6: unique symbol;
|
|
132
137
|
declare abstract class GatewayError extends Error {
|
|
@@ -149,7 +154,7 @@ declare abstract class GatewayError extends Error {
|
|
|
149
154
|
static hasMarker(error: unknown): error is GatewayError;
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.
|
|
157
|
+
declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
153
158
|
error: {
|
|
154
159
|
message: string;
|
|
155
160
|
type?: string | null | undefined;
|
|
@@ -157,7 +162,7 @@ declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
157
162
|
code?: string | number | null | undefined;
|
|
158
163
|
};
|
|
159
164
|
}>;
|
|
160
|
-
type GatewayErrorResponse =
|
|
165
|
+
type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
|
|
161
166
|
|
|
162
167
|
declare const symbol$5: unique symbol;
|
|
163
168
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { FetchFunction,
|
|
3
|
+
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
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-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' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-exp-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-pro-preview' | 'google/gemini-3-pro-image' | 'google/gemini-3-flash' | 'inception/mercury-coder-small' | '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' | 'mistral/codestral' | 'mistral/devstral-small' | 'mistral/magistral-medium' | 'mistral/magistral-medium-2506' | 'mistral/magistral-small' | 'mistral/magistral-small-2506' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large' | 'mistral/mistral-medium' | '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' | '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-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat-latest' | '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/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' | '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-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-code-fast-1' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | (string & {});
|
|
6
6
|
|
|
@@ -50,7 +50,7 @@ interface GatewayLanguageModelEntry {
|
|
|
50
50
|
*/
|
|
51
51
|
modelType?: 'language' | 'embedding' | 'image' | null;
|
|
52
52
|
}
|
|
53
|
-
type GatewayLanguageModelSpecification = Pick<
|
|
53
|
+
type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
|
|
54
54
|
|
|
55
55
|
interface GatewayFetchMetadataResponse {
|
|
56
56
|
models: GatewayLanguageModelEntry[];
|
|
@@ -64,14 +64,14 @@ interface GatewayCreditsResponse {
|
|
|
64
64
|
|
|
65
65
|
type GatewayEmbeddingModelId = '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-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | 'voyage/voyage-code-2' | (string & {});
|
|
66
66
|
|
|
67
|
-
type GatewayImageModelId = 'google/imagen-4.0-generate' | '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' | (string & {});
|
|
67
|
+
type GatewayImageModelId = 'google/imagen-4.0-generate' | 'google/imagen-4.0-ultra-generate' | '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' | (string & {});
|
|
68
68
|
|
|
69
|
-
interface GatewayProvider extends
|
|
70
|
-
(modelId: GatewayModelId):
|
|
69
|
+
interface GatewayProvider extends ProviderV3 {
|
|
70
|
+
(modelId: GatewayModelId): LanguageModelV3;
|
|
71
71
|
/**
|
|
72
72
|
Creates a model for text generation.
|
|
73
73
|
*/
|
|
74
|
-
languageModel(modelId: GatewayModelId):
|
|
74
|
+
languageModel(modelId: GatewayModelId): LanguageModelV3;
|
|
75
75
|
/**
|
|
76
76
|
Returns available providers and models for use with the remote provider.
|
|
77
77
|
*/
|
|
@@ -83,11 +83,15 @@ interface GatewayProvider extends ProviderV2 {
|
|
|
83
83
|
/**
|
|
84
84
|
Creates a model for generating text embeddings.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `embeddingModel` instead.
|
|
89
|
+
*/
|
|
90
|
+
textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
87
91
|
/**
|
|
88
92
|
Creates a model for generating images.
|
|
89
93
|
*/
|
|
90
|
-
imageModel(modelId: GatewayImageModelId):
|
|
94
|
+
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
91
95
|
}
|
|
92
96
|
interface GatewayProviderSettings {
|
|
93
97
|
/**
|
|
@@ -118,15 +122,16 @@ Create a remote provider instance.
|
|
|
118
122
|
declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
|
|
119
123
|
declare const gateway: GatewayProvider;
|
|
120
124
|
|
|
121
|
-
declare const gatewayProviderOptions: _ai_sdk_provider_utils.
|
|
125
|
+
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
122
126
|
only?: string[] | undefined;
|
|
123
127
|
order?: string[] | undefined;
|
|
124
128
|
user?: string | undefined;
|
|
125
129
|
tags?: string[] | undefined;
|
|
126
130
|
models?: string[] | undefined;
|
|
127
131
|
byok?: Record<string, Record<string, unknown>[]> | undefined;
|
|
132
|
+
zeroDataRetention?: boolean | undefined;
|
|
128
133
|
}>;
|
|
129
|
-
type GatewayProviderOptions =
|
|
134
|
+
type GatewayProviderOptions = InferSchema<typeof gatewayProviderOptions>;
|
|
130
135
|
|
|
131
136
|
declare const symbol$6: unique symbol;
|
|
132
137
|
declare abstract class GatewayError extends Error {
|
|
@@ -149,7 +154,7 @@ declare abstract class GatewayError extends Error {
|
|
|
149
154
|
static hasMarker(error: unknown): error is GatewayError;
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.
|
|
157
|
+
declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
153
158
|
error: {
|
|
154
159
|
message: string;
|
|
155
160
|
type?: string | null | undefined;
|
|
@@ -157,7 +162,7 @@ declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
157
162
|
code?: string | number | null | undefined;
|
|
158
163
|
};
|
|
159
164
|
}>;
|
|
160
|
-
type GatewayErrorResponse =
|
|
165
|
+
type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
|
|
161
166
|
|
|
162
167
|
declare const symbol$5: unique symbol;
|
|
163
168
|
/**
|
package/dist/index.js
CHANGED
|
@@ -181,7 +181,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
181
181
|
var name4 = "GatewayModelNotFoundError";
|
|
182
182
|
var marker5 = `vercel.ai.gateway.error.${name4}`;
|
|
183
183
|
var symbol5 = Symbol.for(marker5);
|
|
184
|
-
var modelNotFoundParamSchema = (0, import_provider_utils.
|
|
184
|
+
var modelNotFoundParamSchema = (0, import_provider_utils.lazySchema)(
|
|
185
185
|
() => (0, import_provider_utils.zodSchema)(
|
|
186
186
|
import_v4.z.object({
|
|
187
187
|
modelId: import_v4.z.string()
|
|
@@ -311,7 +311,7 @@ async function createGatewayErrorFromResponse({
|
|
|
311
311
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
var gatewayErrorResponseSchema = (0, import_provider_utils2.
|
|
314
|
+
var gatewayErrorResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
315
315
|
() => (0, import_provider_utils2.zodSchema)(
|
|
316
316
|
import_v42.z.object({
|
|
317
317
|
error: import_v42.z.object({
|
|
@@ -374,7 +374,7 @@ async function parseAuthMethod(headers) {
|
|
|
374
374
|
});
|
|
375
375
|
return result.success ? result.value : void 0;
|
|
376
376
|
}
|
|
377
|
-
var gatewayAuthMethodSchema = (0, import_provider_utils3.
|
|
377
|
+
var gatewayAuthMethodSchema = (0, import_provider_utils3.lazySchema)(
|
|
378
378
|
() => (0, import_provider_utils3.zodSchema)(import_v43.z.union([import_v43.z.literal("api-key"), import_v43.z.literal("oidc")]))
|
|
379
379
|
);
|
|
380
380
|
|
|
@@ -425,7 +425,7 @@ var GatewayFetchMetadata = class {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
|
-
var gatewayAvailableModelsResponseSchema = (0, import_provider_utils4.
|
|
428
|
+
var gatewayAvailableModelsResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
429
429
|
() => (0, import_provider_utils4.zodSchema)(
|
|
430
430
|
import_v44.z.object({
|
|
431
431
|
models: import_v44.z.array(
|
|
@@ -447,7 +447,7 @@ var gatewayAvailableModelsResponseSchema = (0, import_provider_utils4.lazyValida
|
|
|
447
447
|
})
|
|
448
448
|
).nullish(),
|
|
449
449
|
specification: import_v44.z.object({
|
|
450
|
-
specificationVersion: import_v44.z.literal("
|
|
450
|
+
specificationVersion: import_v44.z.literal("v3"),
|
|
451
451
|
provider: import_v44.z.string(),
|
|
452
452
|
modelId: import_v44.z.string()
|
|
453
453
|
}),
|
|
@@ -457,7 +457,7 @@ var gatewayAvailableModelsResponseSchema = (0, import_provider_utils4.lazyValida
|
|
|
457
457
|
})
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
|
-
var gatewayCreditsResponseSchema = (0, import_provider_utils4.
|
|
460
|
+
var gatewayCreditsResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
461
461
|
() => (0, import_provider_utils4.zodSchema)(
|
|
462
462
|
import_v44.z.object({
|
|
463
463
|
balance: import_v44.z.string(),
|
|
@@ -476,7 +476,7 @@ var GatewayLanguageModel = class {
|
|
|
476
476
|
constructor(modelId, config) {
|
|
477
477
|
this.modelId = modelId;
|
|
478
478
|
this.config = config;
|
|
479
|
-
this.specificationVersion = "
|
|
479
|
+
this.specificationVersion = "v3";
|
|
480
480
|
this.supportedUrls = { "*/*": [/.*/] };
|
|
481
481
|
}
|
|
482
482
|
get provider() {
|
|
@@ -625,7 +625,7 @@ var GatewayEmbeddingModel = class {
|
|
|
625
625
|
constructor(modelId, config) {
|
|
626
626
|
this.modelId = modelId;
|
|
627
627
|
this.config = config;
|
|
628
|
-
this.specificationVersion = "
|
|
628
|
+
this.specificationVersion = "v3";
|
|
629
629
|
this.maxEmbeddingsPerCall = 2048;
|
|
630
630
|
this.supportsParallelCalls = true;
|
|
631
631
|
}
|
|
@@ -654,7 +654,7 @@ var GatewayEmbeddingModel = class {
|
|
|
654
654
|
await (0, import_provider_utils6.resolve)(this.config.o11yHeaders)
|
|
655
655
|
),
|
|
656
656
|
body: {
|
|
657
|
-
|
|
657
|
+
values,
|
|
658
658
|
...providerOptions ? { providerOptions } : {}
|
|
659
659
|
},
|
|
660
660
|
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
@@ -671,7 +671,8 @@ var GatewayEmbeddingModel = class {
|
|
|
671
671
|
embeddings: responseBody.embeddings,
|
|
672
672
|
usage: (_a8 = responseBody.usage) != null ? _a8 : void 0,
|
|
673
673
|
providerMetadata: responseBody.providerMetadata,
|
|
674
|
-
response: { headers: responseHeaders, body: rawValue }
|
|
674
|
+
response: { headers: responseHeaders, body: rawValue },
|
|
675
|
+
warnings: []
|
|
675
676
|
};
|
|
676
677
|
} catch (error) {
|
|
677
678
|
throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
@@ -687,7 +688,7 @@ var GatewayEmbeddingModel = class {
|
|
|
687
688
|
};
|
|
688
689
|
}
|
|
689
690
|
};
|
|
690
|
-
var gatewayEmbeddingResponseSchema = (0, import_provider_utils6.
|
|
691
|
+
var gatewayEmbeddingResponseSchema = (0, import_provider_utils6.lazySchema)(
|
|
691
692
|
() => (0, import_provider_utils6.zodSchema)(
|
|
692
693
|
import_v46.z.object({
|
|
693
694
|
embeddings: import_v46.z.array(import_v46.z.array(import_v46.z.number())),
|
|
@@ -704,7 +705,7 @@ var GatewayImageModel = class {
|
|
|
704
705
|
constructor(modelId, config) {
|
|
705
706
|
this.modelId = modelId;
|
|
706
707
|
this.config = config;
|
|
707
|
-
this.specificationVersion = "
|
|
708
|
+
this.specificationVersion = "v3";
|
|
708
709
|
// Set a very large number to prevent client-side splitting of requests
|
|
709
710
|
this.maxImagesPerCall = Number.MAX_SAFE_INTEGER;
|
|
710
711
|
}
|
|
@@ -806,7 +807,7 @@ async function getVercelRequestId() {
|
|
|
806
807
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
807
808
|
|
|
808
809
|
// src/version.ts
|
|
809
|
-
var VERSION = true ? "
|
|
810
|
+
var VERSION = true ? "3.0.0" : "0.0.0-test";
|
|
810
811
|
|
|
811
812
|
// src/gateway-provider.ts
|
|
812
813
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -816,7 +817,7 @@ function createGatewayProvider(options = {}) {
|
|
|
816
817
|
let metadataCache = null;
|
|
817
818
|
const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
|
|
818
819
|
let lastFetchTime = 0;
|
|
819
|
-
const baseURL = (_b8 = (0, import_provider_utils8.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/
|
|
820
|
+
const baseURL = (_b8 = (0, import_provider_utils8.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
820
821
|
const getHeaders = async () => {
|
|
821
822
|
const auth = await getGatewayAuthToken(options);
|
|
822
823
|
if (auth) {
|
|
@@ -909,6 +910,7 @@ function createGatewayProvider(options = {}) {
|
|
|
909
910
|
}
|
|
910
911
|
return createLanguageModel(modelId);
|
|
911
912
|
};
|
|
913
|
+
provider.specificationVersion = "v3";
|
|
912
914
|
provider.getAvailableModels = getAvailableModels;
|
|
913
915
|
provider.getCredits = getCredits;
|
|
914
916
|
provider.imageModel = (modelId) => {
|
|
@@ -921,7 +923,7 @@ function createGatewayProvider(options = {}) {
|
|
|
921
923
|
});
|
|
922
924
|
};
|
|
923
925
|
provider.languageModel = createLanguageModel;
|
|
924
|
-
|
|
926
|
+
const createEmbeddingModel = (modelId) => {
|
|
925
927
|
return new GatewayEmbeddingModel(modelId, {
|
|
926
928
|
provider: "gateway",
|
|
927
929
|
baseURL,
|
|
@@ -930,6 +932,8 @@ function createGatewayProvider(options = {}) {
|
|
|
930
932
|
o11yHeaders: createO11yHeaders()
|
|
931
933
|
});
|
|
932
934
|
};
|
|
935
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
936
|
+
provider.textEmbeddingModel = createEmbeddingModel;
|
|
933
937
|
return provider;
|
|
934
938
|
}
|
|
935
939
|
var gateway = createGatewayProvider();
|