@ai-sdk/gateway 4.0.0-beta.48 → 4.0.0-beta.49

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/dist/index.d.mts DELETED
@@ -1,725 +0,0 @@
1
- import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, RerankingModelV4, 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
-
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-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-flash' | 'alibaba/qwen3.5-plus' | 'alibaba/qwen3.6-plus' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3.5-haiku' | '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-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-large-thinking' | '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-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-lite' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'google/gemini-3.1-flash-image-preview' | 'google/gemini-3.1-flash-lite-preview' | 'google/gemini-3.1-pro-preview' | 'google/gemma-4-26b-a4b-it' | 'google/gemma-4-31b-it' | 'inception/mercury-2' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'kwaipilot/kat-coder-pro-v2' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking-2601' | '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' | 'minimax/minimax-m2.5' | 'minimax/minimax-m2.5-highspeed' | 'minimax/minimax-m2.7' | 'minimax/minimax-m2.7-highspeed' | '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' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-3-super-120b-a12b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | '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-4o-mini-search-preview' | '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-5.3-chat' | 'openai/gpt-5.3-codex' | 'openai/gpt-5.4' | 'openai/gpt-5.4-mini' | 'openai/gpt-5.4-nano' | 'openai/gpt-5.4-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-pro' | 'prime-intellect/intellect-3' | '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-4.20-multi-agent' | 'xai/grok-4.20-multi-agent-beta' | 'xai/grok-4.20-non-reasoning' | 'xai/grok-4.20-non-reasoning-beta' | 'xai/grok-4.20-reasoning' | 'xai/grok-4.20-reasoning-beta' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'xiaomi/mimo-v2-pro' | '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-flash' | 'zai/glm-4.7-flashx' | 'zai/glm-5' | 'zai/glm-5-turbo' | 'zai/glm-5.1' | 'zai/glm-5v-turbo' | (string & {});
6
-
7
- type GatewayRerankingModelId = 'cohere/rerank-v3.5' | (string & {});
8
-
9
- type GatewayVideoModelId = 'alibaba/wan-v2.5-t2v-preview' | 'alibaba/wan-v2.6-i2v' | 'alibaba/wan-v2.6-i2v-flash' | 'alibaba/wan-v2.6-r2v' | 'alibaba/wan-v2.6-r2v-flash' | 'alibaba/wan-v2.6-t2v' | 'bytedance/seedance-v1.0-lite-i2v' | 'bytedance/seedance-v1.0-lite-t2v' | 'bytedance/seedance-v1.0-pro' | 'bytedance/seedance-v1.0-pro-fast' | 'bytedance/seedance-v1.5-pro' | 'google/veo-3.0-fast-generate-001' | 'google/veo-3.0-generate-001' | 'google/veo-3.1-fast-generate-001' | 'google/veo-3.1-generate-001' | 'klingai/kling-v2.5-turbo-i2v' | 'klingai/kling-v2.5-turbo-t2v' | 'klingai/kling-v2.6-i2v' | 'klingai/kling-v2.6-motion-control' | 'klingai/kling-v2.6-t2v' | 'klingai/kling-v3.0-i2v' | 'klingai/kling-v3.0-t2v' | 'xai/grok-imagine-video' | (string & {});
10
-
11
- interface GatewayLanguageModelEntry {
12
- /**
13
- * The model id used by the remote provider in model settings and for specifying the
14
- * intended model for text generation.
15
- */
16
- id: string;
17
- /**
18
- * The display name of the model for presentation in user-facing contexts.
19
- */
20
- name: string;
21
- /**
22
- * Optional description of the model.
23
- */
24
- description?: string | null;
25
- /**
26
- * Optional pricing information for the model.
27
- */
28
- pricing?: {
29
- /**
30
- * Cost per input token in USD.
31
- */
32
- input: string;
33
- /**
34
- * Cost per output token in USD.
35
- */
36
- output: string;
37
- /**
38
- * Cost per cached input token in USD.
39
- * Only present for providers/models that support prompt caching.
40
- */
41
- cachedInputTokens?: string;
42
- /**
43
- * Cost per input token to create/write cache entries in USD.
44
- * Only present for providers/models that support prompt caching.
45
- */
46
- cacheCreationInputTokens?: string;
47
- } | null;
48
- /**
49
- * Additional AI SDK language model specifications for the model.
50
- */
51
- specification: GatewayLanguageModelSpecification;
52
- /**
53
- * Optional field to differentiate between model types.
54
- */
55
- modelType?: 'language' | 'embedding' | 'image' | 'video' | null;
56
- }
57
- type GatewayLanguageModelSpecification = Pick<LanguageModelV4, 'specificationVersion' | 'provider' | 'modelId'>;
58
-
59
- interface GatewayFetchMetadataResponse {
60
- models: GatewayLanguageModelEntry[];
61
- }
62
- interface GatewayCreditsResponse {
63
- /** The remaining gateway credit balance available for API usage */
64
- balance: string;
65
- /** The total amount of gateway credits that have been consumed */
66
- totalUsed: string;
67
- }
68
-
69
- interface GatewaySpendReportParams {
70
- /** Start date in YYYY-MM-DD format (inclusive) */
71
- startDate: string;
72
- /** End date in YYYY-MM-DD format (inclusive) */
73
- endDate: string;
74
- /** Primary aggregation dimension. Defaults to 'day'. */
75
- groupBy?: 'day' | 'user' | 'model' | 'tag' | 'provider' | 'credential_type';
76
- /** Time granularity when groupBy is 'day'. */
77
- datePart?: 'day' | 'hour';
78
- /** Filter to a specific user's spend. */
79
- userId?: string;
80
- /** Filter to a specific model (e.g. 'anthropic/claude-sonnet-4.5'). */
81
- model?: string;
82
- /** Filter to a specific provider (e.g. 'anthropic'). */
83
- provider?: string;
84
- /** Filter to BYOK or system credentials. */
85
- credentialType?: 'byok' | 'system';
86
- /** Filter to requests with these tags. */
87
- tags?: string[];
88
- }
89
- interface GatewaySpendReportRow {
90
- /** Date string (present when groupBy is 'day') */
91
- day?: string;
92
- /** Hour timestamp (present when groupBy is 'day' and datePart is 'hour') */
93
- hour?: string;
94
- /** User identifier (present when groupBy is 'user') */
95
- user?: string;
96
- /** Model identifier (present when groupBy is 'model') */
97
- model?: string;
98
- /** Tag value (present when groupBy is 'tag') */
99
- tag?: string;
100
- /** Provider name (present when groupBy is 'provider') */
101
- provider?: string;
102
- /** Credential type (present when groupBy is 'credential_type') */
103
- credentialType?: 'byok' | 'system';
104
- /** Total cost in USD */
105
- totalCost: number;
106
- /** Market cost in USD */
107
- marketCost?: number;
108
- /** Number of input tokens */
109
- inputTokens?: number;
110
- /** Number of output tokens */
111
- outputTokens?: number;
112
- /** Number of cached input tokens */
113
- cachedInputTokens?: number;
114
- /** Number of cache creation input tokens */
115
- cacheCreationInputTokens?: number;
116
- /** Number of reasoning tokens */
117
- reasoningTokens?: number;
118
- /** Number of requests */
119
- requestCount?: number;
120
- }
121
- interface GatewaySpendReportResponse {
122
- results: GatewaySpendReportRow[];
123
- }
124
-
125
- interface GatewayGenerationInfoParams {
126
- /** The generation ID to look up (format: gen_<ulid>) */
127
- id: string;
128
- }
129
- interface GatewayGenerationInfo {
130
- /** The generation ID */
131
- id: string;
132
- /** Total cost in USD */
133
- totalCost: number;
134
- /** Upstream inference cost in USD (BYOK only) */
135
- upstreamInferenceCost: number;
136
- /** Usage cost in USD (same as totalCost) */
137
- usage: number;
138
- /** ISO 8601 timestamp when the generation was created */
139
- createdAt: string;
140
- /** Model identifier */
141
- model: string;
142
- /** Whether BYOK credentials were used */
143
- isByok: boolean;
144
- /** Provider that served this generation */
145
- providerName: string;
146
- /** Whether streaming was used */
147
- streamed: boolean;
148
- /** Finish reason (e.g. 'stop') */
149
- finishReason: string;
150
- /** Time to first token in milliseconds */
151
- latency: number;
152
- /** Total generation time in milliseconds */
153
- generationTime: number;
154
- /** Number of prompt tokens */
155
- promptTokens: number;
156
- /** Number of completion tokens */
157
- completionTokens: number;
158
- /** Reasoning tokens used */
159
- reasoningTokens: number;
160
- /** Cached tokens used */
161
- cachedTokens: number;
162
- /** Cache creation input tokens */
163
- cacheCreationTokens: number;
164
- /** Billable web search calls */
165
- billableWebSearchCalls: number;
166
- }
167
-
168
- 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/gemini-embedding-2' | '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-4' | 'voyage/voyage-4-large' | 'voyage/voyage-4-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
169
-
170
- type GatewayImageModelId = 'bfl/flux-2-flex' | 'bfl/flux-2-klein-4b' | 'bfl/flux-2-klein-9b' | 'bfl/flux-2-max' | 'bfl/flux-2-pro' | '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' | 'bytedance/seedream-4.0' | 'bytedance/seedream-4.5' | 'bytedance/seedream-5.0-lite' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'prodia/flux-fast-schnell' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'xai/grok-imagine-image' | 'xai/grok-imagine-image-pro' | (string & {});
171
-
172
- interface PerplexitySearchConfig {
173
- /**
174
- * Default maximum number of search results to return (1-20, default: 10).
175
- */
176
- maxResults?: number;
177
- /**
178
- * Default maximum tokens to extract per search result page (256-2048, default: 2048).
179
- */
180
- maxTokensPerPage?: number;
181
- /**
182
- * Default maximum total tokens across all search results (default: 25000, max: 1000000).
183
- */
184
- maxTokens?: number;
185
- /**
186
- * Default two-letter ISO 3166-1 alpha-2 country code for regional search results.
187
- * Examples: 'US', 'GB', 'FR'
188
- */
189
- country?: string;
190
- /**
191
- * Default list of domains to include or exclude from search results (max 20).
192
- * To include: ['nature.com', 'science.org']
193
- * To exclude: ['-example.com', '-spam.net']
194
- */
195
- searchDomainFilter?: string[];
196
- /**
197
- * Default list of ISO 639-1 language codes to filter results (max 10, lowercase).
198
- * Examples: ['en', 'fr', 'de']
199
- */
200
- searchLanguageFilter?: string[];
201
- /**
202
- * Default recency filter for results.
203
- * Cannot be combined with searchAfterDate/searchBeforeDate at runtime.
204
- */
205
- searchRecencyFilter?: 'day' | 'week' | 'month' | 'year';
206
- }
207
- interface PerplexitySearchResult {
208
- /** Title of the search result */
209
- title: string;
210
- /** URL of the search result */
211
- url: string;
212
- /** Text snippet/preview of the content */
213
- snippet: string;
214
- /** Publication date of the content */
215
- date?: string;
216
- /** Last updated date of the content */
217
- lastUpdated?: string;
218
- }
219
- interface PerplexitySearchResponse {
220
- /** Array of search results */
221
- results: PerplexitySearchResult[];
222
- /** Unique identifier for this search request */
223
- id: string;
224
- }
225
- interface PerplexitySearchError {
226
- /** Error type */
227
- error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'unknown';
228
- /** HTTP status code if applicable */
229
- statusCode?: number;
230
- /** Human-readable error message */
231
- message: string;
232
- }
233
- interface PerplexitySearchInput {
234
- /**
235
- * Search query (string) or multiple queries (array of up to 5 strings).
236
- * Multi-query searches return combined results from all queries.
237
- */
238
- query: string | string[];
239
- /**
240
- * Maximum number of search results to return (1-20, default: 10).
241
- */
242
- max_results?: number;
243
- /**
244
- * Maximum number of tokens to extract per search result page (256-2048, default: 2048).
245
- */
246
- max_tokens_per_page?: number;
247
- /**
248
- * Maximum total tokens across all search results (default: 25000, max: 1000000).
249
- */
250
- max_tokens?: number;
251
- /**
252
- * Two-letter ISO 3166-1 alpha-2 country code for regional search results.
253
- * Examples: 'US', 'GB', 'FR'
254
- */
255
- country?: string;
256
- /**
257
- * List of domains to include or exclude from search results (max 20).
258
- * To include: ['nature.com', 'science.org']
259
- * To exclude: ['-example.com', '-spam.net']
260
- */
261
- search_domain_filter?: string[];
262
- /**
263
- * List of ISO 639-1 language codes to filter results (max 10, lowercase).
264
- * Examples: ['en', 'fr', 'de']
265
- */
266
- search_language_filter?: string[];
267
- /**
268
- * Include only results published after this date.
269
- * Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
270
- * Cannot be used with search_recency_filter.
271
- */
272
- search_after_date?: string;
273
- /**
274
- * Include only results published before this date.
275
- * Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
276
- * Cannot be used with search_recency_filter.
277
- */
278
- search_before_date?: string;
279
- /**
280
- * Include only results last updated after this date.
281
- * Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
282
- * Cannot be used with search_recency_filter.
283
- */
284
- last_updated_after_filter?: string;
285
- /**
286
- * Include only results last updated before this date.
287
- * Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
288
- * Cannot be used with search_recency_filter.
289
- */
290
- last_updated_before_filter?: string;
291
- /**
292
- * Filter results by relative time period.
293
- * Cannot be used with search_after_date or search_before_date.
294
- */
295
- search_recency_filter?: 'day' | 'week' | 'month' | 'year';
296
- }
297
- type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
298
- declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig, {}>;
299
-
300
- interface ParallelSearchSourcePolicy {
301
- /**
302
- * List of domains to include in search results.
303
- * Example: ['wikipedia.org', 'nature.com']
304
- */
305
- includeDomains?: string[];
306
- /**
307
- * List of domains to exclude from search results.
308
- * Example: ['reddit.com', 'twitter.com']
309
- */
310
- excludeDomains?: string[];
311
- /**
312
- * Only include results published after this date (ISO 8601 format).
313
- * Example: '2024-01-01'
314
- */
315
- afterDate?: string;
316
- }
317
- interface ParallelSearchExcerpts {
318
- /**
319
- * Maximum characters per result.
320
- */
321
- maxCharsPerResult?: number;
322
- /**
323
- * Maximum total characters across all results.
324
- */
325
- maxCharsTotal?: number;
326
- }
327
- interface ParallelSearchFetchPolicy {
328
- /**
329
- * Maximum age in seconds for cached content.
330
- * Set to 0 to always fetch fresh content.
331
- */
332
- maxAgeSeconds?: number;
333
- }
334
- interface ParallelSearchConfig {
335
- /**
336
- * Mode preset for different use cases:
337
- * - "one-shot": Comprehensive results with longer excerpts for single-response answers (default)
338
- * - "agentic": Concise, token-efficient results for multi-step agentic workflows
339
- */
340
- mode?: 'one-shot' | 'agentic';
341
- /**
342
- * Default maximum number of results to return (1-20).
343
- * Defaults to 10 if not specified.
344
- */
345
- maxResults?: number;
346
- /**
347
- * Default source policy for controlling which domains to include/exclude.
348
- */
349
- sourcePolicy?: ParallelSearchSourcePolicy;
350
- /**
351
- * Default excerpt configuration for controlling result length.
352
- */
353
- excerpts?: ParallelSearchExcerpts;
354
- /**
355
- * Default fetch policy for controlling content freshness.
356
- */
357
- fetchPolicy?: ParallelSearchFetchPolicy;
358
- }
359
- interface ParallelSearchResult {
360
- /** URL of the search result */
361
- url: string;
362
- /** Title of the search result */
363
- title: string;
364
- /** Extracted text excerpt/content from the page */
365
- excerpt: string;
366
- /** Publication date of the content (may be null) */
367
- publishDate?: string | null;
368
- /** Relevance score for the result */
369
- relevanceScore?: number;
370
- }
371
- interface ParallelSearchResponse {
372
- /** Unique identifier for this search request */
373
- searchId: string;
374
- /** Array of search results */
375
- results: ParallelSearchResult[];
376
- }
377
- interface ParallelSearchError {
378
- /** Error type */
379
- error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'unknown';
380
- /** HTTP status code if applicable */
381
- statusCode?: number;
382
- /** Human-readable error message */
383
- message: string;
384
- }
385
- interface ParallelSearchInput {
386
- /**
387
- * Natural-language description of the web research goal.
388
- * Include source or freshness guidance and broader context from the task.
389
- * Maximum 5000 characters.
390
- */
391
- objective: string;
392
- /**
393
- * Optional search queries to supplement the objective.
394
- * Maximum 200 characters per query.
395
- */
396
- search_queries?: string[];
397
- /**
398
- * Mode preset for different use cases:
399
- * - "one-shot": Comprehensive results with longer excerpts
400
- * - "agentic": Concise, token-efficient results for multi-step workflows
401
- */
402
- mode?: 'one-shot' | 'agentic';
403
- /**
404
- * Maximum number of results to return (1-20).
405
- * Defaults to 10 if not specified.
406
- */
407
- max_results?: number;
408
- /**
409
- * Source policy for controlling which domains to include/exclude.
410
- */
411
- source_policy?: {
412
- include_domains?: string[];
413
- exclude_domains?: string[];
414
- after_date?: string;
415
- };
416
- /**
417
- * Excerpt configuration for controlling result length.
418
- */
419
- excerpts?: {
420
- max_chars_per_result?: number;
421
- max_chars_total?: number;
422
- };
423
- /**
424
- * Fetch policy for controlling content freshness.
425
- */
426
- fetch_policy?: {
427
- max_age_seconds?: number;
428
- };
429
- }
430
- type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
431
- declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig, {}>;
432
-
433
- /**
434
- * Gateway-specific provider-defined tools.
435
- */
436
- declare const gatewayTools: {
437
- /**
438
- * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
439
- *
440
- * Takes a natural language objective and returns relevant excerpts,
441
- * replacing multiple keyword searches with a single call for broad
442
- * or complex queries. Supports different search types for depth vs
443
- * breadth tradeoffs.
444
- */
445
- parallelSearch: (config?: ParallelSearchConfig) => ReturnType<typeof parallelSearchToolFactory>;
446
- /**
447
- * Search the web using Perplexity's Search API for real-time information,
448
- * news, research papers, and articles.
449
- *
450
- * Provides ranked search results with advanced filtering options including
451
- * domain, language, date range, and recency filters.
452
- */
453
- perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
454
- };
455
-
456
- interface GatewayProvider extends ProviderV4 {
457
- (modelId: GatewayModelId): LanguageModelV4;
458
- /**
459
- * Creates a model for text generation.
460
- */
461
- chat(modelId: GatewayModelId): LanguageModelV4;
462
- /**
463
- * Creates a model for text generation.
464
- */
465
- languageModel(modelId: GatewayModelId): LanguageModelV4;
466
- /**
467
- * Returns available providers and models for use with the remote provider.
468
- */
469
- getAvailableModels(): Promise<GatewayFetchMetadataResponse>;
470
- /**
471
- * Returns credit information for the authenticated user.
472
- */
473
- getCredits(): Promise<GatewayCreditsResponse>;
474
- /**
475
- * Returns a spend report with cost, token, and request count data,
476
- * aggregated by the specified dimension.
477
- */
478
- getSpendReport(params: GatewaySpendReportParams): Promise<GatewaySpendReportResponse>;
479
- /**
480
- * Returns detailed information about a specific generation by its ID,
481
- * including cost, token usage, latency, and provider details.
482
- */
483
- getGenerationInfo(params: GatewayGenerationInfoParams): Promise<GatewayGenerationInfo>;
484
- /**
485
- * Creates a model for generating text embeddings.
486
- */
487
- embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV4;
488
- /**
489
- * Creates a model for generating text embeddings.
490
- */
491
- embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV4;
492
- /**
493
- * @deprecated Use `embeddingModel` instead.
494
- */
495
- textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV4;
496
- /**
497
- * Creates a model for generating images.
498
- */
499
- image(modelId: GatewayImageModelId): ImageModelV4;
500
- /**
501
- * Creates a model for generating images.
502
- */
503
- imageModel(modelId: GatewayImageModelId): ImageModelV4;
504
- /**
505
- * Creates a model for generating videos.
506
- */
507
- video(modelId: GatewayVideoModelId): Experimental_VideoModelV4;
508
- /**
509
- * Creates a model for generating videos.
510
- */
511
- videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV4;
512
- /**
513
- * Creates a model for reranking documents.
514
- */
515
- reranking(modelId: GatewayRerankingModelId): RerankingModelV4;
516
- /**
517
- * Creates a model for reranking documents.
518
- */
519
- rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV4;
520
- /**
521
- * Gateway-specific tools executed server-side.
522
- */
523
- tools: typeof gatewayTools;
524
- }
525
- interface GatewayProviderSettings {
526
- /**
527
- * The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.
528
- */
529
- baseURL?: string;
530
- /**
531
- * API key that is being sent using the `Authorization` header.
532
- */
533
- apiKey?: string;
534
- /**
535
- * Custom headers to include in the requests.
536
- */
537
- headers?: Record<string, string>;
538
- /**
539
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
540
- * or to provide a custom fetch implementation for e.g. testing.
541
- */
542
- fetch?: FetchFunction;
543
- /**
544
- * How frequently to refresh the metadata cache in milliseconds.
545
- */
546
- metadataCacheRefreshMillis?: number;
547
- }
548
- /**
549
- * Create a remote provider instance.
550
- */
551
- declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
552
- declare const gateway: GatewayProvider;
553
-
554
- declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
555
- only?: string[] | undefined;
556
- order?: string[] | undefined;
557
- sort?: "cost" | "ttft" | "tps" | undefined;
558
- user?: string | undefined;
559
- tags?: string[] | undefined;
560
- models?: string[] | undefined;
561
- byok?: Record<string, Record<string, unknown>[]> | undefined;
562
- zeroDataRetention?: boolean | undefined;
563
- disallowPromptTraining?: boolean | undefined;
564
- hipaaCompliant?: boolean | undefined;
565
- quotaEntityId?: string | undefined;
566
- providerTimeouts?: {
567
- byok?: Record<string, number> | undefined;
568
- } | undefined;
569
- }>;
570
- type GatewayProviderOptions = InferSchema<typeof gatewayProviderOptions>;
571
-
572
- declare const symbol$6: unique symbol;
573
- declare abstract class GatewayError extends Error {
574
- private readonly [symbol$6];
575
- abstract readonly name: string;
576
- abstract readonly type: string;
577
- readonly statusCode: number;
578
- readonly cause?: unknown;
579
- readonly generationId?: string;
580
- constructor({ message, statusCode, cause, generationId, }: {
581
- message: string;
582
- statusCode?: number;
583
- cause?: unknown;
584
- generationId?: string;
585
- });
586
- /**
587
- * Checks if the given error is a Gateway Error.
588
- * @param {unknown} error - The error to check.
589
- * @returns {boolean} True if the error is a Gateway Error, false otherwise.
590
- */
591
- static isInstance(error: unknown): error is GatewayError;
592
- static hasMarker(error: unknown): error is GatewayError;
593
- }
594
-
595
- declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
596
- error: {
597
- message: string;
598
- type?: string | null | undefined;
599
- param?: unknown;
600
- code?: string | number | null | undefined;
601
- };
602
- generationId?: string | null | undefined;
603
- }>;
604
- type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
605
-
606
- declare const symbol$5: unique symbol;
607
- /**
608
- * Authentication failed - invalid API key or OIDC token
609
- */
610
- declare class GatewayAuthenticationError extends GatewayError {
611
- private readonly [symbol$5];
612
- readonly name = "GatewayAuthenticationError";
613
- readonly type = "authentication_error";
614
- constructor({ message, statusCode, cause, generationId, }?: {
615
- message?: string;
616
- statusCode?: number;
617
- cause?: unknown;
618
- generationId?: string;
619
- });
620
- static isInstance(error: unknown): error is GatewayAuthenticationError;
621
- /**
622
- * Creates a contextual error message when authentication fails
623
- */
624
- static createContextualError({ apiKeyProvided, oidcTokenProvided, statusCode, cause, generationId, }: {
625
- apiKeyProvided: boolean;
626
- oidcTokenProvided: boolean;
627
- message?: string;
628
- statusCode?: number;
629
- cause?: unknown;
630
- generationId?: string;
631
- }): GatewayAuthenticationError;
632
- }
633
-
634
- declare const symbol$4: unique symbol;
635
- /**
636
- * Internal server error from the Gateway
637
- */
638
- declare class GatewayInternalServerError extends GatewayError {
639
- private readonly [symbol$4];
640
- readonly name = "GatewayInternalServerError";
641
- readonly type = "internal_server_error";
642
- constructor({ message, statusCode, cause, generationId, }?: {
643
- message?: string;
644
- statusCode?: number;
645
- cause?: unknown;
646
- generationId?: string;
647
- });
648
- static isInstance(error: unknown): error is GatewayInternalServerError;
649
- }
650
-
651
- declare const symbol$3: unique symbol;
652
- /**
653
- * Invalid request - missing headers, malformed data, etc.
654
- */
655
- declare class GatewayInvalidRequestError extends GatewayError {
656
- private readonly [symbol$3];
657
- readonly name = "GatewayInvalidRequestError";
658
- readonly type = "invalid_request_error";
659
- constructor({ message, statusCode, cause, generationId, }?: {
660
- message?: string;
661
- statusCode?: number;
662
- cause?: unknown;
663
- generationId?: string;
664
- });
665
- static isInstance(error: unknown): error is GatewayInvalidRequestError;
666
- }
667
-
668
- declare const symbol$2: unique symbol;
669
- /**
670
- * Model not found or not available
671
- */
672
- declare class GatewayModelNotFoundError extends GatewayError {
673
- private readonly [symbol$2];
674
- readonly name = "GatewayModelNotFoundError";
675
- readonly type = "model_not_found";
676
- readonly modelId?: string;
677
- constructor({ message, statusCode, modelId, cause, generationId, }?: {
678
- message?: string;
679
- statusCode?: number;
680
- modelId?: string;
681
- cause?: unknown;
682
- generationId?: string;
683
- });
684
- static isInstance(error: unknown): error is GatewayModelNotFoundError;
685
- }
686
-
687
- declare const symbol$1: unique symbol;
688
- /**
689
- * Rate limit exceeded.
690
- */
691
- declare class GatewayRateLimitError extends GatewayError {
692
- private readonly [symbol$1];
693
- readonly name = "GatewayRateLimitError";
694
- readonly type = "rate_limit_exceeded";
695
- constructor({ message, statusCode, cause, generationId, }?: {
696
- message?: string;
697
- statusCode?: number;
698
- cause?: unknown;
699
- generationId?: string;
700
- });
701
- static isInstance(error: unknown): error is GatewayRateLimitError;
702
- }
703
-
704
- declare const symbol: unique symbol;
705
- /**
706
- * Gateway response parsing error
707
- */
708
- declare class GatewayResponseError extends GatewayError {
709
- private readonly [symbol];
710
- readonly name = "GatewayResponseError";
711
- readonly type = "response_error";
712
- readonly response?: unknown;
713
- readonly validationError?: TypeValidationError;
714
- constructor({ message, statusCode, response, validationError, cause, generationId, }?: {
715
- message?: string;
716
- statusCode?: number;
717
- response?: unknown;
718
- validationError?: TypeValidationError;
719
- cause?: unknown;
720
- generationId?: string;
721
- });
722
- static isInstance(error: unknown): error is GatewayResponseError;
723
- }
724
-
725
- export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, type GatewayGenerationInfo, type GatewayGenerationInfoParams, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayProviderOptions as GatewayLanguageModelOptions, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, type GatewayRerankingModelId, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };