@ai-sdk/gateway 0.0.0-02dba89b-20251009204516 → 0.0.0-64aae7dd-20260114144918
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 +832 -167
- package/dist/index.d.mts +187 -26
- package/dist/index.d.ts +187 -26
- package/dist/index.js +399 -157
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +390 -125
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
2
|
+
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
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-coder' | '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.7-sonnet' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-sonnet-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' | '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' | (string & {});
|
|
6
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
|
@@ -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[];
|
|
@@ -62,14 +62,158 @@ interface GatewayCreditsResponse {
|
|
|
62
62
|
totalUsed: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
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-
|
|
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
|
-
|
|
68
|
-
|
|
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 & {});
|
|
68
|
+
|
|
69
|
+
interface PerplexitySearchConfig {
|
|
70
|
+
/**
|
|
71
|
+
* Default maximum number of search results to return (1-20, default: 10).
|
|
72
|
+
*/
|
|
73
|
+
maxResults?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Default maximum tokens to extract per search result page (256-2048, default: 2048).
|
|
76
|
+
*/
|
|
77
|
+
maxTokensPerPage?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Default maximum total tokens across all search results (default: 25000, max: 1000000).
|
|
80
|
+
*/
|
|
81
|
+
maxTokens?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Default two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
84
|
+
* Examples: 'US', 'GB', 'FR'
|
|
85
|
+
*/
|
|
86
|
+
country?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Default list of domains to include or exclude from search results (max 20).
|
|
89
|
+
* To include: ['nature.com', 'science.org']
|
|
90
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
91
|
+
*/
|
|
92
|
+
searchDomainFilter?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Default list of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
95
|
+
* Examples: ['en', 'fr', 'de']
|
|
96
|
+
*/
|
|
97
|
+
searchLanguageFilter?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Default recency filter for results.
|
|
100
|
+
* Cannot be combined with searchAfterDate/searchBeforeDate at runtime.
|
|
101
|
+
*/
|
|
102
|
+
searchRecencyFilter?: 'day' | 'week' | 'month' | 'year';
|
|
103
|
+
}
|
|
104
|
+
interface PerplexitySearchResult {
|
|
105
|
+
/** Title of the search result */
|
|
106
|
+
title: string;
|
|
107
|
+
/** URL of the search result */
|
|
108
|
+
url: string;
|
|
109
|
+
/** Text snippet/preview of the content */
|
|
110
|
+
snippet: string;
|
|
111
|
+
/** Publication date of the content */
|
|
112
|
+
date?: string;
|
|
113
|
+
/** Last updated date of the content */
|
|
114
|
+
lastUpdated?: string;
|
|
115
|
+
}
|
|
116
|
+
interface PerplexitySearchResponse {
|
|
117
|
+
/** Array of search results */
|
|
118
|
+
results: PerplexitySearchResult[];
|
|
119
|
+
/** Unique identifier for this search request */
|
|
120
|
+
id: string;
|
|
121
|
+
}
|
|
122
|
+
interface PerplexitySearchError {
|
|
123
|
+
/** Error type */
|
|
124
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'unknown';
|
|
125
|
+
/** HTTP status code if applicable */
|
|
126
|
+
statusCode?: number;
|
|
127
|
+
/** Human-readable error message */
|
|
128
|
+
message: string;
|
|
129
|
+
}
|
|
130
|
+
interface PerplexitySearchInput {
|
|
131
|
+
/**
|
|
132
|
+
* Search query (string) or multiple queries (array of up to 5 strings).
|
|
133
|
+
* Multi-query searches return combined results from all queries.
|
|
134
|
+
*/
|
|
135
|
+
query: string | string[];
|
|
136
|
+
/**
|
|
137
|
+
* Maximum number of search results to return (1-20, default: 10).
|
|
138
|
+
*/
|
|
139
|
+
max_results?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Maximum number of tokens to extract per search result page (256-2048, default: 2048).
|
|
142
|
+
*/
|
|
143
|
+
max_tokens_per_page?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Maximum total tokens across all search results (default: 25000, max: 1000000).
|
|
146
|
+
*/
|
|
147
|
+
max_tokens?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
150
|
+
* Examples: 'US', 'GB', 'FR'
|
|
151
|
+
*/
|
|
152
|
+
country?: string;
|
|
153
|
+
/**
|
|
154
|
+
* List of domains to include or exclude from search results (max 20).
|
|
155
|
+
* To include: ['nature.com', 'science.org']
|
|
156
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
157
|
+
*/
|
|
158
|
+
search_domain_filter?: string[];
|
|
159
|
+
/**
|
|
160
|
+
* List of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
161
|
+
* Examples: ['en', 'fr', 'de']
|
|
162
|
+
*/
|
|
163
|
+
search_language_filter?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* Include only results published after this date.
|
|
166
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
|
|
167
|
+
* Cannot be used with search_recency_filter.
|
|
168
|
+
*/
|
|
169
|
+
search_after_date?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Include only results published before this date.
|
|
172
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
|
|
173
|
+
* Cannot be used with search_recency_filter.
|
|
174
|
+
*/
|
|
175
|
+
search_before_date?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Include only results last updated after this date.
|
|
178
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
|
|
179
|
+
* Cannot be used with search_recency_filter.
|
|
180
|
+
*/
|
|
181
|
+
last_updated_after_filter?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Include only results last updated before this date.
|
|
184
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
|
|
185
|
+
* Cannot be used with search_recency_filter.
|
|
186
|
+
*/
|
|
187
|
+
last_updated_before_filter?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Filter results by relative time period.
|
|
190
|
+
* Cannot be used with search_after_date or search_before_date.
|
|
191
|
+
*/
|
|
192
|
+
search_recency_filter?: 'day' | 'week' | 'month' | 'year';
|
|
193
|
+
}
|
|
194
|
+
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
195
|
+
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Gateway-specific provider-defined tools.
|
|
199
|
+
*/
|
|
200
|
+
declare const gatewayTools: {
|
|
201
|
+
/**
|
|
202
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
203
|
+
* news, research papers, and articles.
|
|
204
|
+
*
|
|
205
|
+
* Provides ranked search results with advanced filtering options including
|
|
206
|
+
* domain, language, date range, and recency filters.
|
|
207
|
+
*/
|
|
208
|
+
perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
interface GatewayProvider extends ProviderV3 {
|
|
212
|
+
(modelId: GatewayModelId): LanguageModelV3;
|
|
69
213
|
/**
|
|
70
214
|
Creates a model for text generation.
|
|
71
215
|
*/
|
|
72
|
-
languageModel(modelId: GatewayModelId):
|
|
216
|
+
languageModel(modelId: GatewayModelId): LanguageModelV3;
|
|
73
217
|
/**
|
|
74
218
|
Returns available providers and models for use with the remote provider.
|
|
75
219
|
*/
|
|
@@ -81,7 +225,19 @@ interface GatewayProvider extends ProviderV2 {
|
|
|
81
225
|
/**
|
|
82
226
|
Creates a model for generating text embeddings.
|
|
83
227
|
*/
|
|
84
|
-
|
|
228
|
+
embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated Use `embeddingModel` instead.
|
|
231
|
+
*/
|
|
232
|
+
textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
233
|
+
/**
|
|
234
|
+
Creates a model for generating images.
|
|
235
|
+
*/
|
|
236
|
+
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
237
|
+
/**
|
|
238
|
+
Gateway-specific tools executed server-side.
|
|
239
|
+
*/
|
|
240
|
+
tools: typeof gatewayTools;
|
|
85
241
|
}
|
|
86
242
|
interface GatewayProviderSettings {
|
|
87
243
|
/**
|
|
@@ -112,11 +268,16 @@ Create a remote provider instance.
|
|
|
112
268
|
declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
|
|
113
269
|
declare const gateway: GatewayProvider;
|
|
114
270
|
|
|
115
|
-
declare const gatewayProviderOptions:
|
|
116
|
-
only
|
|
117
|
-
order
|
|
118
|
-
|
|
119
|
-
|
|
271
|
+
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
272
|
+
only?: string[] | undefined;
|
|
273
|
+
order?: string[] | undefined;
|
|
274
|
+
user?: string | undefined;
|
|
275
|
+
tags?: string[] | undefined;
|
|
276
|
+
models?: string[] | undefined;
|
|
277
|
+
byok?: Record<string, Record<string, unknown>[]> | undefined;
|
|
278
|
+
zeroDataRetention?: boolean | undefined;
|
|
279
|
+
}>;
|
|
280
|
+
type GatewayProviderOptions = InferSchema<typeof gatewayProviderOptions>;
|
|
120
281
|
|
|
121
282
|
declare const symbol$6: unique symbol;
|
|
122
283
|
declare abstract class GatewayError extends Error {
|
|
@@ -139,15 +300,15 @@ declare abstract class GatewayError extends Error {
|
|
|
139
300
|
static hasMarker(error: unknown): error is GatewayError;
|
|
140
301
|
}
|
|
141
302
|
|
|
142
|
-
declare const gatewayErrorResponseSchema:
|
|
143
|
-
error:
|
|
144
|
-
message:
|
|
145
|
-
type
|
|
146
|
-
param
|
|
147
|
-
code
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
type GatewayErrorResponse =
|
|
303
|
+
declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
304
|
+
error: {
|
|
305
|
+
message: string;
|
|
306
|
+
type?: string | null | undefined;
|
|
307
|
+
param?: unknown;
|
|
308
|
+
code?: string | number | null | undefined;
|
|
309
|
+
};
|
|
310
|
+
}>;
|
|
311
|
+
type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
|
|
151
312
|
|
|
152
313
|
declare const symbol$5: unique symbol;
|
|
153
314
|
/**
|
|
@@ -250,12 +411,12 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
250
411
|
readonly name = "GatewayResponseError";
|
|
251
412
|
readonly type = "response_error";
|
|
252
413
|
readonly response?: unknown;
|
|
253
|
-
readonly validationError?:
|
|
414
|
+
readonly validationError?: TypeValidationError;
|
|
254
415
|
constructor({ message, statusCode, response, validationError, cause, }?: {
|
|
255
416
|
message?: string;
|
|
256
417
|
statusCode?: number;
|
|
257
418
|
response?: unknown;
|
|
258
|
-
validationError?:
|
|
419
|
+
validationError?: TypeValidationError;
|
|
259
420
|
cause?: unknown;
|
|
260
421
|
});
|
|
261
422
|
static isInstance(error: unknown): error is GatewayResponseError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
2
|
+
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
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-coder' | '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.7-sonnet' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-sonnet-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' | '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' | (string & {});
|
|
6
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
|
@@ -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[];
|
|
@@ -62,14 +62,158 @@ interface GatewayCreditsResponse {
|
|
|
62
62
|
totalUsed: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
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-
|
|
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
|
-
|
|
68
|
-
|
|
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 & {});
|
|
68
|
+
|
|
69
|
+
interface PerplexitySearchConfig {
|
|
70
|
+
/**
|
|
71
|
+
* Default maximum number of search results to return (1-20, default: 10).
|
|
72
|
+
*/
|
|
73
|
+
maxResults?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Default maximum tokens to extract per search result page (256-2048, default: 2048).
|
|
76
|
+
*/
|
|
77
|
+
maxTokensPerPage?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Default maximum total tokens across all search results (default: 25000, max: 1000000).
|
|
80
|
+
*/
|
|
81
|
+
maxTokens?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Default two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
84
|
+
* Examples: 'US', 'GB', 'FR'
|
|
85
|
+
*/
|
|
86
|
+
country?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Default list of domains to include or exclude from search results (max 20).
|
|
89
|
+
* To include: ['nature.com', 'science.org']
|
|
90
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
91
|
+
*/
|
|
92
|
+
searchDomainFilter?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Default list of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
95
|
+
* Examples: ['en', 'fr', 'de']
|
|
96
|
+
*/
|
|
97
|
+
searchLanguageFilter?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Default recency filter for results.
|
|
100
|
+
* Cannot be combined with searchAfterDate/searchBeforeDate at runtime.
|
|
101
|
+
*/
|
|
102
|
+
searchRecencyFilter?: 'day' | 'week' | 'month' | 'year';
|
|
103
|
+
}
|
|
104
|
+
interface PerplexitySearchResult {
|
|
105
|
+
/** Title of the search result */
|
|
106
|
+
title: string;
|
|
107
|
+
/** URL of the search result */
|
|
108
|
+
url: string;
|
|
109
|
+
/** Text snippet/preview of the content */
|
|
110
|
+
snippet: string;
|
|
111
|
+
/** Publication date of the content */
|
|
112
|
+
date?: string;
|
|
113
|
+
/** Last updated date of the content */
|
|
114
|
+
lastUpdated?: string;
|
|
115
|
+
}
|
|
116
|
+
interface PerplexitySearchResponse {
|
|
117
|
+
/** Array of search results */
|
|
118
|
+
results: PerplexitySearchResult[];
|
|
119
|
+
/** Unique identifier for this search request */
|
|
120
|
+
id: string;
|
|
121
|
+
}
|
|
122
|
+
interface PerplexitySearchError {
|
|
123
|
+
/** Error type */
|
|
124
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'unknown';
|
|
125
|
+
/** HTTP status code if applicable */
|
|
126
|
+
statusCode?: number;
|
|
127
|
+
/** Human-readable error message */
|
|
128
|
+
message: string;
|
|
129
|
+
}
|
|
130
|
+
interface PerplexitySearchInput {
|
|
131
|
+
/**
|
|
132
|
+
* Search query (string) or multiple queries (array of up to 5 strings).
|
|
133
|
+
* Multi-query searches return combined results from all queries.
|
|
134
|
+
*/
|
|
135
|
+
query: string | string[];
|
|
136
|
+
/**
|
|
137
|
+
* Maximum number of search results to return (1-20, default: 10).
|
|
138
|
+
*/
|
|
139
|
+
max_results?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Maximum number of tokens to extract per search result page (256-2048, default: 2048).
|
|
142
|
+
*/
|
|
143
|
+
max_tokens_per_page?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Maximum total tokens across all search results (default: 25000, max: 1000000).
|
|
146
|
+
*/
|
|
147
|
+
max_tokens?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
150
|
+
* Examples: 'US', 'GB', 'FR'
|
|
151
|
+
*/
|
|
152
|
+
country?: string;
|
|
153
|
+
/**
|
|
154
|
+
* List of domains to include or exclude from search results (max 20).
|
|
155
|
+
* To include: ['nature.com', 'science.org']
|
|
156
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
157
|
+
*/
|
|
158
|
+
search_domain_filter?: string[];
|
|
159
|
+
/**
|
|
160
|
+
* List of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
161
|
+
* Examples: ['en', 'fr', 'de']
|
|
162
|
+
*/
|
|
163
|
+
search_language_filter?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* Include only results published after this date.
|
|
166
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
|
|
167
|
+
* Cannot be used with search_recency_filter.
|
|
168
|
+
*/
|
|
169
|
+
search_after_date?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Include only results published before this date.
|
|
172
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
|
|
173
|
+
* Cannot be used with search_recency_filter.
|
|
174
|
+
*/
|
|
175
|
+
search_before_date?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Include only results last updated after this date.
|
|
178
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
|
|
179
|
+
* Cannot be used with search_recency_filter.
|
|
180
|
+
*/
|
|
181
|
+
last_updated_after_filter?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Include only results last updated before this date.
|
|
184
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
|
|
185
|
+
* Cannot be used with search_recency_filter.
|
|
186
|
+
*/
|
|
187
|
+
last_updated_before_filter?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Filter results by relative time period.
|
|
190
|
+
* Cannot be used with search_after_date or search_before_date.
|
|
191
|
+
*/
|
|
192
|
+
search_recency_filter?: 'day' | 'week' | 'month' | 'year';
|
|
193
|
+
}
|
|
194
|
+
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
195
|
+
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Gateway-specific provider-defined tools.
|
|
199
|
+
*/
|
|
200
|
+
declare const gatewayTools: {
|
|
201
|
+
/**
|
|
202
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
203
|
+
* news, research papers, and articles.
|
|
204
|
+
*
|
|
205
|
+
* Provides ranked search results with advanced filtering options including
|
|
206
|
+
* domain, language, date range, and recency filters.
|
|
207
|
+
*/
|
|
208
|
+
perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
interface GatewayProvider extends ProviderV3 {
|
|
212
|
+
(modelId: GatewayModelId): LanguageModelV3;
|
|
69
213
|
/**
|
|
70
214
|
Creates a model for text generation.
|
|
71
215
|
*/
|
|
72
|
-
languageModel(modelId: GatewayModelId):
|
|
216
|
+
languageModel(modelId: GatewayModelId): LanguageModelV3;
|
|
73
217
|
/**
|
|
74
218
|
Returns available providers and models for use with the remote provider.
|
|
75
219
|
*/
|
|
@@ -81,7 +225,19 @@ interface GatewayProvider extends ProviderV2 {
|
|
|
81
225
|
/**
|
|
82
226
|
Creates a model for generating text embeddings.
|
|
83
227
|
*/
|
|
84
|
-
|
|
228
|
+
embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated Use `embeddingModel` instead.
|
|
231
|
+
*/
|
|
232
|
+
textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
233
|
+
/**
|
|
234
|
+
Creates a model for generating images.
|
|
235
|
+
*/
|
|
236
|
+
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
237
|
+
/**
|
|
238
|
+
Gateway-specific tools executed server-side.
|
|
239
|
+
*/
|
|
240
|
+
tools: typeof gatewayTools;
|
|
85
241
|
}
|
|
86
242
|
interface GatewayProviderSettings {
|
|
87
243
|
/**
|
|
@@ -112,11 +268,16 @@ Create a remote provider instance.
|
|
|
112
268
|
declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
|
|
113
269
|
declare const gateway: GatewayProvider;
|
|
114
270
|
|
|
115
|
-
declare const gatewayProviderOptions:
|
|
116
|
-
only
|
|
117
|
-
order
|
|
118
|
-
|
|
119
|
-
|
|
271
|
+
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
272
|
+
only?: string[] | undefined;
|
|
273
|
+
order?: string[] | undefined;
|
|
274
|
+
user?: string | undefined;
|
|
275
|
+
tags?: string[] | undefined;
|
|
276
|
+
models?: string[] | undefined;
|
|
277
|
+
byok?: Record<string, Record<string, unknown>[]> | undefined;
|
|
278
|
+
zeroDataRetention?: boolean | undefined;
|
|
279
|
+
}>;
|
|
280
|
+
type GatewayProviderOptions = InferSchema<typeof gatewayProviderOptions>;
|
|
120
281
|
|
|
121
282
|
declare const symbol$6: unique symbol;
|
|
122
283
|
declare abstract class GatewayError extends Error {
|
|
@@ -139,15 +300,15 @@ declare abstract class GatewayError extends Error {
|
|
|
139
300
|
static hasMarker(error: unknown): error is GatewayError;
|
|
140
301
|
}
|
|
141
302
|
|
|
142
|
-
declare const gatewayErrorResponseSchema:
|
|
143
|
-
error:
|
|
144
|
-
message:
|
|
145
|
-
type
|
|
146
|
-
param
|
|
147
|
-
code
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
type GatewayErrorResponse =
|
|
303
|
+
declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
304
|
+
error: {
|
|
305
|
+
message: string;
|
|
306
|
+
type?: string | null | undefined;
|
|
307
|
+
param?: unknown;
|
|
308
|
+
code?: string | number | null | undefined;
|
|
309
|
+
};
|
|
310
|
+
}>;
|
|
311
|
+
type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
|
|
151
312
|
|
|
152
313
|
declare const symbol$5: unique symbol;
|
|
153
314
|
/**
|
|
@@ -250,12 +411,12 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
250
411
|
readonly name = "GatewayResponseError";
|
|
251
412
|
readonly type = "response_error";
|
|
252
413
|
readonly response?: unknown;
|
|
253
|
-
readonly validationError?:
|
|
414
|
+
readonly validationError?: TypeValidationError;
|
|
254
415
|
constructor({ message, statusCode, response, validationError, cause, }?: {
|
|
255
416
|
message?: string;
|
|
256
417
|
statusCode?: number;
|
|
257
418
|
response?: unknown;
|
|
258
|
-
validationError?:
|
|
419
|
+
validationError?: TypeValidationError;
|
|
259
420
|
cause?: unknown;
|
|
260
421
|
});
|
|
261
422
|
static isInstance(error: unknown): error is GatewayResponseError;
|