@ai-sdk/gateway 2.0.31 → 2.0.33
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 +12 -0
- package/dist/index.d.mts +143 -1
- package/dist/index.d.ts +143 -1
- package/dist/index.js +128 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
+
## 2.0.33
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- db2e810: feat(anthropic): add support for Opus 4.6
|
|
8
|
+
|
|
9
|
+
## 2.0.32
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- beba89c: feat (provider/gateway): add parallel search tool
|
|
14
|
+
|
|
3
15
|
## 2.0.31
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV2, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferValidator } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | '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-large-preview' | '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-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' | 'moonshotai/kimi-k2.5' | '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-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-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-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-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' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
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-max-thinking' | '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-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | '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-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' | 'moonshotai/kimi-k2.5' | '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-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-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-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-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' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
6
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
|
@@ -194,10 +194,152 @@ interface PerplexitySearchInput {
|
|
|
194
194
|
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
195
195
|
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
196
196
|
|
|
197
|
+
interface ParallelSearchSourcePolicy {
|
|
198
|
+
/**
|
|
199
|
+
* List of domains to include in search results.
|
|
200
|
+
* Example: ['wikipedia.org', 'nature.com']
|
|
201
|
+
*/
|
|
202
|
+
includeDomains?: string[];
|
|
203
|
+
/**
|
|
204
|
+
* List of domains to exclude from search results.
|
|
205
|
+
* Example: ['reddit.com', 'twitter.com']
|
|
206
|
+
*/
|
|
207
|
+
excludeDomains?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Only include results published after this date (ISO 8601 format).
|
|
210
|
+
* Example: '2024-01-01'
|
|
211
|
+
*/
|
|
212
|
+
afterDate?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ParallelSearchExcerpts {
|
|
215
|
+
/**
|
|
216
|
+
* Maximum characters per result.
|
|
217
|
+
*/
|
|
218
|
+
maxCharsPerResult?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Maximum total characters across all results.
|
|
221
|
+
*/
|
|
222
|
+
maxCharsTotal?: number;
|
|
223
|
+
}
|
|
224
|
+
interface ParallelSearchFetchPolicy {
|
|
225
|
+
/**
|
|
226
|
+
* Maximum age in seconds for cached content.
|
|
227
|
+
* Set to 0 to always fetch fresh content.
|
|
228
|
+
*/
|
|
229
|
+
maxAgeSeconds?: number;
|
|
230
|
+
}
|
|
231
|
+
interface ParallelSearchConfig {
|
|
232
|
+
/**
|
|
233
|
+
* Mode preset for different use cases:
|
|
234
|
+
* - "one-shot": Comprehensive results with longer excerpts for single-response answers (default)
|
|
235
|
+
* - "agentic": Concise, token-efficient results for multi-step agentic workflows
|
|
236
|
+
*/
|
|
237
|
+
mode?: 'one-shot' | 'agentic';
|
|
238
|
+
/**
|
|
239
|
+
* Default maximum number of results to return (1-20).
|
|
240
|
+
* Defaults to 10 if not specified.
|
|
241
|
+
*/
|
|
242
|
+
maxResults?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Default source policy for controlling which domains to include/exclude.
|
|
245
|
+
*/
|
|
246
|
+
sourcePolicy?: ParallelSearchSourcePolicy;
|
|
247
|
+
/**
|
|
248
|
+
* Default excerpt configuration for controlling result length.
|
|
249
|
+
*/
|
|
250
|
+
excerpts?: ParallelSearchExcerpts;
|
|
251
|
+
/**
|
|
252
|
+
* Default fetch policy for controlling content freshness.
|
|
253
|
+
*/
|
|
254
|
+
fetchPolicy?: ParallelSearchFetchPolicy;
|
|
255
|
+
}
|
|
256
|
+
interface ParallelSearchResult {
|
|
257
|
+
/** URL of the search result */
|
|
258
|
+
url: string;
|
|
259
|
+
/** Title of the search result */
|
|
260
|
+
title: string;
|
|
261
|
+
/** Extracted text excerpt/content from the page */
|
|
262
|
+
excerpt: string;
|
|
263
|
+
/** Publication date of the content (may be null) */
|
|
264
|
+
publishDate?: string | null;
|
|
265
|
+
/** Relevance score for the result */
|
|
266
|
+
relevanceScore?: number;
|
|
267
|
+
}
|
|
268
|
+
interface ParallelSearchResponse {
|
|
269
|
+
/** Unique identifier for this search request */
|
|
270
|
+
searchId: string;
|
|
271
|
+
/** Array of search results */
|
|
272
|
+
results: ParallelSearchResult[];
|
|
273
|
+
}
|
|
274
|
+
interface ParallelSearchError {
|
|
275
|
+
/** Error type */
|
|
276
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'unknown';
|
|
277
|
+
/** HTTP status code if applicable */
|
|
278
|
+
statusCode?: number;
|
|
279
|
+
/** Human-readable error message */
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
interface ParallelSearchInput {
|
|
283
|
+
/**
|
|
284
|
+
* Natural-language description of the web research goal.
|
|
285
|
+
* Include source or freshness guidance and broader context from the task.
|
|
286
|
+
* Maximum 5000 characters.
|
|
287
|
+
*/
|
|
288
|
+
objective: string;
|
|
289
|
+
/**
|
|
290
|
+
* Optional search queries to supplement the objective.
|
|
291
|
+
* Maximum 200 characters per query.
|
|
292
|
+
*/
|
|
293
|
+
search_queries?: string[];
|
|
294
|
+
/**
|
|
295
|
+
* Mode preset for different use cases:
|
|
296
|
+
* - "one-shot": Comprehensive results with longer excerpts
|
|
297
|
+
* - "agentic": Concise, token-efficient results for multi-step workflows
|
|
298
|
+
*/
|
|
299
|
+
mode?: 'one-shot' | 'agentic';
|
|
300
|
+
/**
|
|
301
|
+
* Maximum number of results to return (1-20).
|
|
302
|
+
* Defaults to 10 if not specified.
|
|
303
|
+
*/
|
|
304
|
+
max_results?: number;
|
|
305
|
+
/**
|
|
306
|
+
* Source policy for controlling which domains to include/exclude.
|
|
307
|
+
*/
|
|
308
|
+
source_policy?: {
|
|
309
|
+
include_domains?: string[];
|
|
310
|
+
exclude_domains?: string[];
|
|
311
|
+
after_date?: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Excerpt configuration for controlling result length.
|
|
315
|
+
*/
|
|
316
|
+
excerpts?: {
|
|
317
|
+
max_chars_per_result?: number;
|
|
318
|
+
max_chars_total?: number;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Fetch policy for controlling content freshness.
|
|
322
|
+
*/
|
|
323
|
+
fetch_policy?: {
|
|
324
|
+
max_age_seconds?: number;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
|
|
328
|
+
declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig>;
|
|
329
|
+
|
|
197
330
|
/**
|
|
198
331
|
* Gateway-specific provider-defined tools.
|
|
199
332
|
*/
|
|
200
333
|
declare const gatewayTools: {
|
|
334
|
+
/**
|
|
335
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
336
|
+
*
|
|
337
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
338
|
+
* replacing multiple keyword searches with a single call for broad
|
|
339
|
+
* or complex queries. Supports different search types for depth vs
|
|
340
|
+
* breadth tradeoffs.
|
|
341
|
+
*/
|
|
342
|
+
parallelSearch: (config?: ParallelSearchConfig) => ReturnType<typeof parallelSearchToolFactory>;
|
|
201
343
|
/**
|
|
202
344
|
* Search the web using Perplexity's Search API for real-time information,
|
|
203
345
|
* news, research papers, and articles.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV2, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferValidator } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | '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-large-preview' | '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-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' | 'moonshotai/kimi-k2.5' | '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-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-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-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-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' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
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-max-thinking' | '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-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | '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-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' | 'moonshotai/kimi-k2.5' | '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-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-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-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-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' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
6
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
|
@@ -194,10 +194,152 @@ interface PerplexitySearchInput {
|
|
|
194
194
|
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
195
195
|
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
196
196
|
|
|
197
|
+
interface ParallelSearchSourcePolicy {
|
|
198
|
+
/**
|
|
199
|
+
* List of domains to include in search results.
|
|
200
|
+
* Example: ['wikipedia.org', 'nature.com']
|
|
201
|
+
*/
|
|
202
|
+
includeDomains?: string[];
|
|
203
|
+
/**
|
|
204
|
+
* List of domains to exclude from search results.
|
|
205
|
+
* Example: ['reddit.com', 'twitter.com']
|
|
206
|
+
*/
|
|
207
|
+
excludeDomains?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Only include results published after this date (ISO 8601 format).
|
|
210
|
+
* Example: '2024-01-01'
|
|
211
|
+
*/
|
|
212
|
+
afterDate?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ParallelSearchExcerpts {
|
|
215
|
+
/**
|
|
216
|
+
* Maximum characters per result.
|
|
217
|
+
*/
|
|
218
|
+
maxCharsPerResult?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Maximum total characters across all results.
|
|
221
|
+
*/
|
|
222
|
+
maxCharsTotal?: number;
|
|
223
|
+
}
|
|
224
|
+
interface ParallelSearchFetchPolicy {
|
|
225
|
+
/**
|
|
226
|
+
* Maximum age in seconds for cached content.
|
|
227
|
+
* Set to 0 to always fetch fresh content.
|
|
228
|
+
*/
|
|
229
|
+
maxAgeSeconds?: number;
|
|
230
|
+
}
|
|
231
|
+
interface ParallelSearchConfig {
|
|
232
|
+
/**
|
|
233
|
+
* Mode preset for different use cases:
|
|
234
|
+
* - "one-shot": Comprehensive results with longer excerpts for single-response answers (default)
|
|
235
|
+
* - "agentic": Concise, token-efficient results for multi-step agentic workflows
|
|
236
|
+
*/
|
|
237
|
+
mode?: 'one-shot' | 'agentic';
|
|
238
|
+
/**
|
|
239
|
+
* Default maximum number of results to return (1-20).
|
|
240
|
+
* Defaults to 10 if not specified.
|
|
241
|
+
*/
|
|
242
|
+
maxResults?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Default source policy for controlling which domains to include/exclude.
|
|
245
|
+
*/
|
|
246
|
+
sourcePolicy?: ParallelSearchSourcePolicy;
|
|
247
|
+
/**
|
|
248
|
+
* Default excerpt configuration for controlling result length.
|
|
249
|
+
*/
|
|
250
|
+
excerpts?: ParallelSearchExcerpts;
|
|
251
|
+
/**
|
|
252
|
+
* Default fetch policy for controlling content freshness.
|
|
253
|
+
*/
|
|
254
|
+
fetchPolicy?: ParallelSearchFetchPolicy;
|
|
255
|
+
}
|
|
256
|
+
interface ParallelSearchResult {
|
|
257
|
+
/** URL of the search result */
|
|
258
|
+
url: string;
|
|
259
|
+
/** Title of the search result */
|
|
260
|
+
title: string;
|
|
261
|
+
/** Extracted text excerpt/content from the page */
|
|
262
|
+
excerpt: string;
|
|
263
|
+
/** Publication date of the content (may be null) */
|
|
264
|
+
publishDate?: string | null;
|
|
265
|
+
/** Relevance score for the result */
|
|
266
|
+
relevanceScore?: number;
|
|
267
|
+
}
|
|
268
|
+
interface ParallelSearchResponse {
|
|
269
|
+
/** Unique identifier for this search request */
|
|
270
|
+
searchId: string;
|
|
271
|
+
/** Array of search results */
|
|
272
|
+
results: ParallelSearchResult[];
|
|
273
|
+
}
|
|
274
|
+
interface ParallelSearchError {
|
|
275
|
+
/** Error type */
|
|
276
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'unknown';
|
|
277
|
+
/** HTTP status code if applicable */
|
|
278
|
+
statusCode?: number;
|
|
279
|
+
/** Human-readable error message */
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
interface ParallelSearchInput {
|
|
283
|
+
/**
|
|
284
|
+
* Natural-language description of the web research goal.
|
|
285
|
+
* Include source or freshness guidance and broader context from the task.
|
|
286
|
+
* Maximum 5000 characters.
|
|
287
|
+
*/
|
|
288
|
+
objective: string;
|
|
289
|
+
/**
|
|
290
|
+
* Optional search queries to supplement the objective.
|
|
291
|
+
* Maximum 200 characters per query.
|
|
292
|
+
*/
|
|
293
|
+
search_queries?: string[];
|
|
294
|
+
/**
|
|
295
|
+
* Mode preset for different use cases:
|
|
296
|
+
* - "one-shot": Comprehensive results with longer excerpts
|
|
297
|
+
* - "agentic": Concise, token-efficient results for multi-step workflows
|
|
298
|
+
*/
|
|
299
|
+
mode?: 'one-shot' | 'agentic';
|
|
300
|
+
/**
|
|
301
|
+
* Maximum number of results to return (1-20).
|
|
302
|
+
* Defaults to 10 if not specified.
|
|
303
|
+
*/
|
|
304
|
+
max_results?: number;
|
|
305
|
+
/**
|
|
306
|
+
* Source policy for controlling which domains to include/exclude.
|
|
307
|
+
*/
|
|
308
|
+
source_policy?: {
|
|
309
|
+
include_domains?: string[];
|
|
310
|
+
exclude_domains?: string[];
|
|
311
|
+
after_date?: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Excerpt configuration for controlling result length.
|
|
315
|
+
*/
|
|
316
|
+
excerpts?: {
|
|
317
|
+
max_chars_per_result?: number;
|
|
318
|
+
max_chars_total?: number;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Fetch policy for controlling content freshness.
|
|
322
|
+
*/
|
|
323
|
+
fetch_policy?: {
|
|
324
|
+
max_age_seconds?: number;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
|
|
328
|
+
declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig>;
|
|
329
|
+
|
|
197
330
|
/**
|
|
198
331
|
* Gateway-specific provider-defined tools.
|
|
199
332
|
*/
|
|
200
333
|
declare const gatewayTools: {
|
|
334
|
+
/**
|
|
335
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
336
|
+
*
|
|
337
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
338
|
+
* replacing multiple keyword searches with a single call for broad
|
|
339
|
+
* or complex queries. Supports different search types for depth vs
|
|
340
|
+
* breadth tradeoffs.
|
|
341
|
+
*/
|
|
342
|
+
parallelSearch: (config?: ParallelSearchConfig) => ReturnType<typeof parallelSearchToolFactory>;
|
|
201
343
|
/**
|
|
202
344
|
* Search the web using Perplexity's Search API for real-time information,
|
|
203
345
|
* news, research papers, and articles.
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
35
|
|
|
36
36
|
// src/gateway-provider.ts
|
|
37
|
-
var
|
|
37
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
38
38
|
|
|
39
39
|
// src/errors/as-gateway-error.ts
|
|
40
40
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -794,83 +794,162 @@ var gatewayImageResponseSchema = import_v47.z.object({
|
|
|
794
794
|
providerMetadata: import_v47.z.record(import_v47.z.string(), providerMetadataEntrySchema).optional()
|
|
795
795
|
});
|
|
796
796
|
|
|
797
|
-
// src/tool/
|
|
797
|
+
// src/tool/parallel-search.ts
|
|
798
798
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
799
799
|
var import_zod = require("zod");
|
|
800
|
-
var
|
|
800
|
+
var parallelSearchInputSchema = (0, import_provider_utils8.lazySchema)(
|
|
801
801
|
() => (0, import_provider_utils8.zodSchema)(
|
|
802
802
|
import_zod.z.object({
|
|
803
|
-
|
|
804
|
-
"
|
|
803
|
+
objective: import_zod.z.string().describe(
|
|
804
|
+
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
805
|
+
),
|
|
806
|
+
search_queries: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
807
|
+
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
808
|
+
),
|
|
809
|
+
mode: import_zod.z.enum(["one-shot", "agentic"]).optional().describe(
|
|
810
|
+
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
805
811
|
),
|
|
806
812
|
max_results: import_zod.z.number().optional().describe(
|
|
813
|
+
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
814
|
+
),
|
|
815
|
+
source_policy: import_zod.z.object({
|
|
816
|
+
include_domains: import_zod.z.array(import_zod.z.string()).optional().describe("List of domains to include in search results."),
|
|
817
|
+
exclude_domains: import_zod.z.array(import_zod.z.string()).optional().describe("List of domains to exclude from search results."),
|
|
818
|
+
after_date: import_zod.z.string().optional().describe(
|
|
819
|
+
"Only include results published after this date (ISO 8601 format)."
|
|
820
|
+
)
|
|
821
|
+
}).optional().describe(
|
|
822
|
+
"Source policy for controlling which domains to include/exclude and freshness."
|
|
823
|
+
),
|
|
824
|
+
excerpts: import_zod.z.object({
|
|
825
|
+
max_chars_per_result: import_zod.z.number().optional().describe("Maximum characters per result."),
|
|
826
|
+
max_chars_total: import_zod.z.number().optional().describe("Maximum total characters across all results.")
|
|
827
|
+
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
828
|
+
fetch_policy: import_zod.z.object({
|
|
829
|
+
max_age_seconds: import_zod.z.number().optional().describe(
|
|
830
|
+
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
831
|
+
)
|
|
832
|
+
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
833
|
+
})
|
|
834
|
+
)
|
|
835
|
+
);
|
|
836
|
+
var parallelSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
837
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
838
|
+
import_zod.z.union([
|
|
839
|
+
// Success response
|
|
840
|
+
import_zod.z.object({
|
|
841
|
+
searchId: import_zod.z.string(),
|
|
842
|
+
results: import_zod.z.array(
|
|
843
|
+
import_zod.z.object({
|
|
844
|
+
url: import_zod.z.string(),
|
|
845
|
+
title: import_zod.z.string(),
|
|
846
|
+
excerpt: import_zod.z.string(),
|
|
847
|
+
publishDate: import_zod.z.string().nullable().optional(),
|
|
848
|
+
relevanceScore: import_zod.z.number().optional()
|
|
849
|
+
})
|
|
850
|
+
)
|
|
851
|
+
}),
|
|
852
|
+
// Error response
|
|
853
|
+
import_zod.z.object({
|
|
854
|
+
error: import_zod.z.enum([
|
|
855
|
+
"api_error",
|
|
856
|
+
"rate_limit",
|
|
857
|
+
"timeout",
|
|
858
|
+
"invalid_input",
|
|
859
|
+
"configuration_error",
|
|
860
|
+
"unknown"
|
|
861
|
+
]),
|
|
862
|
+
statusCode: import_zod.z.number().optional(),
|
|
863
|
+
message: import_zod.z.string()
|
|
864
|
+
})
|
|
865
|
+
])
|
|
866
|
+
)
|
|
867
|
+
);
|
|
868
|
+
var parallelSearchToolFactory = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
869
|
+
id: "gateway.parallel_search",
|
|
870
|
+
name: "parallel_search",
|
|
871
|
+
inputSchema: parallelSearchInputSchema,
|
|
872
|
+
outputSchema: parallelSearchOutputSchema
|
|
873
|
+
});
|
|
874
|
+
var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
875
|
+
|
|
876
|
+
// src/tool/perplexity-search.ts
|
|
877
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
878
|
+
var import_zod2 = require("zod");
|
|
879
|
+
var perplexitySearchInputSchema = (0, import_provider_utils9.lazySchema)(
|
|
880
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
881
|
+
import_zod2.z.object({
|
|
882
|
+
query: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).describe(
|
|
883
|
+
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
884
|
+
),
|
|
885
|
+
max_results: import_zod2.z.number().optional().describe(
|
|
807
886
|
"Maximum number of search results to return (1-20, default: 10)"
|
|
808
887
|
),
|
|
809
|
-
max_tokens_per_page:
|
|
888
|
+
max_tokens_per_page: import_zod2.z.number().optional().describe(
|
|
810
889
|
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
811
890
|
),
|
|
812
|
-
max_tokens:
|
|
891
|
+
max_tokens: import_zod2.z.number().optional().describe(
|
|
813
892
|
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
814
893
|
),
|
|
815
|
-
country:
|
|
894
|
+
country: import_zod2.z.string().optional().describe(
|
|
816
895
|
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
817
896
|
),
|
|
818
|
-
search_domain_filter:
|
|
897
|
+
search_domain_filter: import_zod2.z.array(import_zod2.z.string()).optional().describe(
|
|
819
898
|
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
820
899
|
),
|
|
821
|
-
search_language_filter:
|
|
900
|
+
search_language_filter: import_zod2.z.array(import_zod2.z.string()).optional().describe(
|
|
822
901
|
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
823
902
|
),
|
|
824
|
-
search_after_date:
|
|
903
|
+
search_after_date: import_zod2.z.string().optional().describe(
|
|
825
904
|
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
826
905
|
),
|
|
827
|
-
search_before_date:
|
|
906
|
+
search_before_date: import_zod2.z.string().optional().describe(
|
|
828
907
|
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
829
908
|
),
|
|
830
|
-
last_updated_after_filter:
|
|
909
|
+
last_updated_after_filter: import_zod2.z.string().optional().describe(
|
|
831
910
|
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
832
911
|
),
|
|
833
|
-
last_updated_before_filter:
|
|
912
|
+
last_updated_before_filter: import_zod2.z.string().optional().describe(
|
|
834
913
|
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
835
914
|
),
|
|
836
|
-
search_recency_filter:
|
|
915
|
+
search_recency_filter: import_zod2.z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
837
916
|
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
838
917
|
)
|
|
839
918
|
})
|
|
840
919
|
)
|
|
841
920
|
);
|
|
842
|
-
var perplexitySearchOutputSchema = (0,
|
|
843
|
-
() => (0,
|
|
844
|
-
|
|
921
|
+
var perplexitySearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
922
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
923
|
+
import_zod2.z.union([
|
|
845
924
|
// Success response
|
|
846
|
-
|
|
847
|
-
results:
|
|
848
|
-
|
|
849
|
-
title:
|
|
850
|
-
url:
|
|
851
|
-
snippet:
|
|
852
|
-
date:
|
|
853
|
-
lastUpdated:
|
|
925
|
+
import_zod2.z.object({
|
|
926
|
+
results: import_zod2.z.array(
|
|
927
|
+
import_zod2.z.object({
|
|
928
|
+
title: import_zod2.z.string(),
|
|
929
|
+
url: import_zod2.z.string(),
|
|
930
|
+
snippet: import_zod2.z.string(),
|
|
931
|
+
date: import_zod2.z.string().optional(),
|
|
932
|
+
lastUpdated: import_zod2.z.string().optional()
|
|
854
933
|
})
|
|
855
934
|
),
|
|
856
|
-
id:
|
|
935
|
+
id: import_zod2.z.string()
|
|
857
936
|
}),
|
|
858
937
|
// Error response
|
|
859
|
-
|
|
860
|
-
error:
|
|
938
|
+
import_zod2.z.object({
|
|
939
|
+
error: import_zod2.z.enum([
|
|
861
940
|
"api_error",
|
|
862
941
|
"rate_limit",
|
|
863
942
|
"timeout",
|
|
864
943
|
"invalid_input",
|
|
865
944
|
"unknown"
|
|
866
945
|
]),
|
|
867
|
-
statusCode:
|
|
868
|
-
message:
|
|
946
|
+
statusCode: import_zod2.z.number().optional(),
|
|
947
|
+
message: import_zod2.z.string()
|
|
869
948
|
})
|
|
870
949
|
])
|
|
871
950
|
)
|
|
872
951
|
);
|
|
873
|
-
var perplexitySearchToolFactory = (0,
|
|
952
|
+
var perplexitySearchToolFactory = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
874
953
|
id: "gateway.perplexity_search",
|
|
875
954
|
name: "perplexity_search",
|
|
876
955
|
inputSchema: perplexitySearchInputSchema,
|
|
@@ -880,6 +959,15 @@ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
|
880
959
|
|
|
881
960
|
// src/gateway-tools.ts
|
|
882
961
|
var gatewayTools = {
|
|
962
|
+
/**
|
|
963
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
964
|
+
*
|
|
965
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
966
|
+
* replacing multiple keyword searches with a single call for broad
|
|
967
|
+
* or complex queries. Supports different search types for depth vs
|
|
968
|
+
* breadth tradeoffs.
|
|
969
|
+
*/
|
|
970
|
+
parallelSearch,
|
|
883
971
|
/**
|
|
884
972
|
* Search the web using Perplexity's Search API for real-time information,
|
|
885
973
|
* news, research papers, and articles.
|
|
@@ -899,10 +987,10 @@ async function getVercelRequestId() {
|
|
|
899
987
|
}
|
|
900
988
|
|
|
901
989
|
// src/gateway-provider.ts
|
|
902
|
-
var
|
|
990
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
903
991
|
|
|
904
992
|
// src/version.ts
|
|
905
|
-
var VERSION = true ? "2.0.
|
|
993
|
+
var VERSION = true ? "2.0.33" : "0.0.0-test";
|
|
906
994
|
|
|
907
995
|
// src/gateway-provider.ts
|
|
908
996
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -912,11 +1000,11 @@ function createGatewayProvider(options = {}) {
|
|
|
912
1000
|
let metadataCache = null;
|
|
913
1001
|
const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
|
|
914
1002
|
let lastFetchTime = 0;
|
|
915
|
-
const baseURL = (_b8 = (0,
|
|
1003
|
+
const baseURL = (_b8 = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
916
1004
|
const getHeaders = async () => {
|
|
917
1005
|
const auth = await getGatewayAuthToken(options);
|
|
918
1006
|
if (auth) {
|
|
919
|
-
return (0,
|
|
1007
|
+
return (0, import_provider_utils11.withUserAgentSuffix)(
|
|
920
1008
|
{
|
|
921
1009
|
Authorization: `Bearer ${auth.token}`,
|
|
922
1010
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
@@ -933,15 +1021,15 @@ function createGatewayProvider(options = {}) {
|
|
|
933
1021
|
});
|
|
934
1022
|
};
|
|
935
1023
|
const createO11yHeaders = () => {
|
|
936
|
-
const deploymentId = (0,
|
|
1024
|
+
const deploymentId = (0, import_provider_utils10.loadOptionalSetting)({
|
|
937
1025
|
settingValue: void 0,
|
|
938
1026
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
939
1027
|
});
|
|
940
|
-
const environment = (0,
|
|
1028
|
+
const environment = (0, import_provider_utils10.loadOptionalSetting)({
|
|
941
1029
|
settingValue: void 0,
|
|
942
1030
|
environmentVariableName: "VERCEL_ENV"
|
|
943
1031
|
});
|
|
944
|
-
const region = (0,
|
|
1032
|
+
const region = (0, import_provider_utils10.loadOptionalSetting)({
|
|
945
1033
|
settingValue: void 0,
|
|
946
1034
|
environmentVariableName: "VERCEL_REGION"
|
|
947
1035
|
});
|
|
@@ -1031,7 +1119,7 @@ function createGatewayProvider(options = {}) {
|
|
|
1031
1119
|
}
|
|
1032
1120
|
var gateway = createGatewayProvider();
|
|
1033
1121
|
async function getGatewayAuthToken(options) {
|
|
1034
|
-
const apiKey = (0,
|
|
1122
|
+
const apiKey = (0, import_provider_utils10.loadOptionalSetting)({
|
|
1035
1123
|
settingValue: options.apiKey,
|
|
1036
1124
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
1037
1125
|
});
|