@ai-sdk/gateway 3.0.9 → 3.0.11
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 +131 -3
- package/dist/index.d.ts +131 -3
- package/dist/index.js +96 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -1
- 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
|
+
## 3.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 891a60a: feat (provider/gateway): add provider-defined perplexity search
|
|
8
|
+
|
|
9
|
+
## 3.0.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2696fd2: chore(provider/gateway): Update gateway model settings files
|
|
14
|
+
|
|
3
15
|
## 3.0.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-mini' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-
|
|
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
|
/**
|
|
@@ -62,9 +62,133 @@ 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
|
-
type GatewayImageModelId = '
|
|
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
|
+
* The LLM can override this per-invocation.
|
|
73
|
+
*/
|
|
74
|
+
maxResults?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Default maximum tokens to extract per search result page (256-2048, default: 1024).
|
|
77
|
+
* The LLM can override this per-invocation.
|
|
78
|
+
*/
|
|
79
|
+
maxTokensPerPage?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Default two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
82
|
+
* Examples: 'US', 'GB', 'FR'
|
|
83
|
+
*/
|
|
84
|
+
country?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Default list of domains to include or exclude from search results (max 20).
|
|
87
|
+
* To include: ['nature.com', 'science.org']
|
|
88
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
89
|
+
*/
|
|
90
|
+
searchDomainFilter?: string[];
|
|
91
|
+
/**
|
|
92
|
+
* Default list of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
93
|
+
* Examples: ['en', 'fr', 'de']
|
|
94
|
+
*/
|
|
95
|
+
searchLanguageFilter?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Default recency filter for results.
|
|
98
|
+
* Cannot be combined with searchAfterDate/searchBeforeDate at runtime.
|
|
99
|
+
*/
|
|
100
|
+
searchRecencyFilter?: 'day' | 'week' | 'month' | 'year';
|
|
101
|
+
}
|
|
102
|
+
interface PerplexitySearchResult {
|
|
103
|
+
/** Title of the search result */
|
|
104
|
+
title: string;
|
|
105
|
+
/** URL of the search result */
|
|
106
|
+
url: string;
|
|
107
|
+
/** Text snippet/preview of the content */
|
|
108
|
+
snippet: string;
|
|
109
|
+
/** Publication date of the content */
|
|
110
|
+
date?: string;
|
|
111
|
+
/** Last updated date of the content */
|
|
112
|
+
lastUpdated?: string;
|
|
113
|
+
}
|
|
114
|
+
interface PerplexitySearchResponse {
|
|
115
|
+
/** Array of search results */
|
|
116
|
+
results: PerplexitySearchResult[];
|
|
117
|
+
/** Unique identifier for this search request */
|
|
118
|
+
id: string;
|
|
119
|
+
}
|
|
120
|
+
interface PerplexitySearchError {
|
|
121
|
+
/** Error type */
|
|
122
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'unknown';
|
|
123
|
+
/** HTTP status code if applicable */
|
|
124
|
+
statusCode?: number;
|
|
125
|
+
/** Human-readable error message */
|
|
126
|
+
message: string;
|
|
127
|
+
}
|
|
128
|
+
interface PerplexitySearchInput {
|
|
129
|
+
/**
|
|
130
|
+
* Search query (string) or multiple queries (array of up to 5 strings).
|
|
131
|
+
* Multi-query searches return combined results from all queries.
|
|
132
|
+
*/
|
|
133
|
+
query: string | string[];
|
|
134
|
+
/**
|
|
135
|
+
* Maximum number of search results to return (1-20, default: 10).
|
|
136
|
+
*/
|
|
137
|
+
max_results?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Maximum number of tokens to extract per search result page (256-2048, default: 1024).
|
|
140
|
+
*/
|
|
141
|
+
max_tokens_per_page?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
144
|
+
* Examples: 'US', 'GB', 'FR'
|
|
145
|
+
*/
|
|
146
|
+
country?: string;
|
|
147
|
+
/**
|
|
148
|
+
* List of domains to include or exclude from search results (max 20).
|
|
149
|
+
* To include: ['nature.com', 'science.org']
|
|
150
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
151
|
+
*/
|
|
152
|
+
search_domain_filter?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* List of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
155
|
+
* Examples: ['en', 'fr', 'de']
|
|
156
|
+
*/
|
|
157
|
+
search_language_filter?: string[];
|
|
158
|
+
/**
|
|
159
|
+
* Include only results published after this date.
|
|
160
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
|
|
161
|
+
* Cannot be used with search_recency_filter.
|
|
162
|
+
*/
|
|
163
|
+
search_after_date?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Include only results published before this date.
|
|
166
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
|
|
167
|
+
* Cannot be used with search_recency_filter.
|
|
168
|
+
*/
|
|
169
|
+
search_before_date?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Filter results by relative time period.
|
|
172
|
+
* Cannot be used with search_after_date or search_before_date.
|
|
173
|
+
*/
|
|
174
|
+
search_recency_filter?: 'day' | 'week' | 'month' | 'year';
|
|
175
|
+
}
|
|
176
|
+
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
177
|
+
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Gateway-specific provider-defined tools.
|
|
181
|
+
*/
|
|
182
|
+
declare const gatewayTools: {
|
|
183
|
+
/**
|
|
184
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
185
|
+
* news, research papers, and articles.
|
|
186
|
+
*
|
|
187
|
+
* Provides ranked search results with advanced filtering options including
|
|
188
|
+
* domain, language, date range, and recency filters.
|
|
189
|
+
*/
|
|
190
|
+
perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
|
|
191
|
+
};
|
|
68
192
|
|
|
69
193
|
interface GatewayProvider extends ProviderV3 {
|
|
70
194
|
(modelId: GatewayModelId): LanguageModelV3;
|
|
@@ -92,6 +216,10 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
92
216
|
Creates a model for generating images.
|
|
93
217
|
*/
|
|
94
218
|
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
219
|
+
/**
|
|
220
|
+
Gateway-specific tools executed server-side.
|
|
221
|
+
*/
|
|
222
|
+
tools: typeof gatewayTools;
|
|
95
223
|
}
|
|
96
224
|
interface GatewayProviderSettings {
|
|
97
225
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-mini' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-
|
|
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
|
/**
|
|
@@ -62,9 +62,133 @@ 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
|
-
type GatewayImageModelId = '
|
|
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
|
+
* The LLM can override this per-invocation.
|
|
73
|
+
*/
|
|
74
|
+
maxResults?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Default maximum tokens to extract per search result page (256-2048, default: 1024).
|
|
77
|
+
* The LLM can override this per-invocation.
|
|
78
|
+
*/
|
|
79
|
+
maxTokensPerPage?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Default two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
82
|
+
* Examples: 'US', 'GB', 'FR'
|
|
83
|
+
*/
|
|
84
|
+
country?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Default list of domains to include or exclude from search results (max 20).
|
|
87
|
+
* To include: ['nature.com', 'science.org']
|
|
88
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
89
|
+
*/
|
|
90
|
+
searchDomainFilter?: string[];
|
|
91
|
+
/**
|
|
92
|
+
* Default list of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
93
|
+
* Examples: ['en', 'fr', 'de']
|
|
94
|
+
*/
|
|
95
|
+
searchLanguageFilter?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Default recency filter for results.
|
|
98
|
+
* Cannot be combined with searchAfterDate/searchBeforeDate at runtime.
|
|
99
|
+
*/
|
|
100
|
+
searchRecencyFilter?: 'day' | 'week' | 'month' | 'year';
|
|
101
|
+
}
|
|
102
|
+
interface PerplexitySearchResult {
|
|
103
|
+
/** Title of the search result */
|
|
104
|
+
title: string;
|
|
105
|
+
/** URL of the search result */
|
|
106
|
+
url: string;
|
|
107
|
+
/** Text snippet/preview of the content */
|
|
108
|
+
snippet: string;
|
|
109
|
+
/** Publication date of the content */
|
|
110
|
+
date?: string;
|
|
111
|
+
/** Last updated date of the content */
|
|
112
|
+
lastUpdated?: string;
|
|
113
|
+
}
|
|
114
|
+
interface PerplexitySearchResponse {
|
|
115
|
+
/** Array of search results */
|
|
116
|
+
results: PerplexitySearchResult[];
|
|
117
|
+
/** Unique identifier for this search request */
|
|
118
|
+
id: string;
|
|
119
|
+
}
|
|
120
|
+
interface PerplexitySearchError {
|
|
121
|
+
/** Error type */
|
|
122
|
+
error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'unknown';
|
|
123
|
+
/** HTTP status code if applicable */
|
|
124
|
+
statusCode?: number;
|
|
125
|
+
/** Human-readable error message */
|
|
126
|
+
message: string;
|
|
127
|
+
}
|
|
128
|
+
interface PerplexitySearchInput {
|
|
129
|
+
/**
|
|
130
|
+
* Search query (string) or multiple queries (array of up to 5 strings).
|
|
131
|
+
* Multi-query searches return combined results from all queries.
|
|
132
|
+
*/
|
|
133
|
+
query: string | string[];
|
|
134
|
+
/**
|
|
135
|
+
* Maximum number of search results to return (1-20, default: 10).
|
|
136
|
+
*/
|
|
137
|
+
max_results?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Maximum number of tokens to extract per search result page (256-2048, default: 1024).
|
|
140
|
+
*/
|
|
141
|
+
max_tokens_per_page?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Two-letter ISO 3166-1 alpha-2 country code for regional search results.
|
|
144
|
+
* Examples: 'US', 'GB', 'FR'
|
|
145
|
+
*/
|
|
146
|
+
country?: string;
|
|
147
|
+
/**
|
|
148
|
+
* List of domains to include or exclude from search results (max 20).
|
|
149
|
+
* To include: ['nature.com', 'science.org']
|
|
150
|
+
* To exclude: ['-example.com', '-spam.net']
|
|
151
|
+
*/
|
|
152
|
+
search_domain_filter?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* List of ISO 639-1 language codes to filter results (max 10, lowercase).
|
|
155
|
+
* Examples: ['en', 'fr', 'de']
|
|
156
|
+
*/
|
|
157
|
+
search_language_filter?: string[];
|
|
158
|
+
/**
|
|
159
|
+
* Include only results published after this date.
|
|
160
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/1/2025')
|
|
161
|
+
* Cannot be used with search_recency_filter.
|
|
162
|
+
*/
|
|
163
|
+
search_after_date?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Include only results published before this date.
|
|
166
|
+
* Format: 'MM/DD/YYYY' (e.g., '3/15/2025')
|
|
167
|
+
* Cannot be used with search_recency_filter.
|
|
168
|
+
*/
|
|
169
|
+
search_before_date?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Filter results by relative time period.
|
|
172
|
+
* Cannot be used with search_after_date or search_before_date.
|
|
173
|
+
*/
|
|
174
|
+
search_recency_filter?: 'day' | 'week' | 'month' | 'year';
|
|
175
|
+
}
|
|
176
|
+
type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
|
|
177
|
+
declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Gateway-specific provider-defined tools.
|
|
181
|
+
*/
|
|
182
|
+
declare const gatewayTools: {
|
|
183
|
+
/**
|
|
184
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
185
|
+
* news, research papers, and articles.
|
|
186
|
+
*
|
|
187
|
+
* Provides ranked search results with advanced filtering options including
|
|
188
|
+
* domain, language, date range, and recency filters.
|
|
189
|
+
*/
|
|
190
|
+
perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
|
|
191
|
+
};
|
|
68
192
|
|
|
69
193
|
interface GatewayProvider extends ProviderV3 {
|
|
70
194
|
(modelId: GatewayModelId): LanguageModelV3;
|
|
@@ -92,6 +216,10 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
92
216
|
Creates a model for generating images.
|
|
93
217
|
*/
|
|
94
218
|
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
219
|
+
/**
|
|
220
|
+
Gateway-specific tools executed server-side.
|
|
221
|
+
*/
|
|
222
|
+
tools: typeof gatewayTools;
|
|
95
223
|
}
|
|
96
224
|
interface GatewayProviderSettings {
|
|
97
225
|
/**
|
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_utils9 = require("@ai-sdk/provider-utils");
|
|
38
38
|
|
|
39
39
|
// src/errors/as-gateway-error.ts
|
|
40
40
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -810,6 +810,92 @@ var gatewayImageResponseSchema = import_v47.z.object({
|
|
|
810
810
|
providerMetadata: import_v47.z.record(import_v47.z.string(), providerMetadataEntrySchema).optional()
|
|
811
811
|
});
|
|
812
812
|
|
|
813
|
+
// src/tool/perplexity-search.ts
|
|
814
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
815
|
+
var import_zod = require("zod");
|
|
816
|
+
var perplexitySearchInputSchema = (0, import_provider_utils8.lazySchema)(
|
|
817
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
818
|
+
import_zod.z.object({
|
|
819
|
+
query: import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string())]).describe(
|
|
820
|
+
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
821
|
+
),
|
|
822
|
+
max_results: import_zod.z.number().optional().describe(
|
|
823
|
+
"Maximum number of search results to return (1-20, default: 10)"
|
|
824
|
+
),
|
|
825
|
+
max_tokens_per_page: import_zod.z.number().optional().describe(
|
|
826
|
+
"Maximum number of tokens to extract per search result page (256-2048, default: 1024)"
|
|
827
|
+
),
|
|
828
|
+
country: import_zod.z.string().optional().describe(
|
|
829
|
+
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
830
|
+
),
|
|
831
|
+
search_domain_filter: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
832
|
+
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
833
|
+
),
|
|
834
|
+
search_language_filter: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
835
|
+
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
836
|
+
),
|
|
837
|
+
search_after_date: import_zod.z.string().optional().describe(
|
|
838
|
+
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
839
|
+
),
|
|
840
|
+
search_before_date: import_zod.z.string().optional().describe(
|
|
841
|
+
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
842
|
+
),
|
|
843
|
+
search_recency_filter: import_zod.z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
844
|
+
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
845
|
+
)
|
|
846
|
+
})
|
|
847
|
+
)
|
|
848
|
+
);
|
|
849
|
+
var perplexitySearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
850
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
851
|
+
import_zod.z.union([
|
|
852
|
+
// Success response
|
|
853
|
+
import_zod.z.object({
|
|
854
|
+
results: import_zod.z.array(
|
|
855
|
+
import_zod.z.object({
|
|
856
|
+
title: import_zod.z.string(),
|
|
857
|
+
url: import_zod.z.string(),
|
|
858
|
+
snippet: import_zod.z.string(),
|
|
859
|
+
date: import_zod.z.string().optional(),
|
|
860
|
+
lastUpdated: import_zod.z.string().optional()
|
|
861
|
+
})
|
|
862
|
+
),
|
|
863
|
+
id: import_zod.z.string()
|
|
864
|
+
}),
|
|
865
|
+
// Error response
|
|
866
|
+
import_zod.z.object({
|
|
867
|
+
error: import_zod.z.enum([
|
|
868
|
+
"api_error",
|
|
869
|
+
"rate_limit",
|
|
870
|
+
"timeout",
|
|
871
|
+
"invalid_input",
|
|
872
|
+
"unknown"
|
|
873
|
+
]),
|
|
874
|
+
statusCode: import_zod.z.number().optional(),
|
|
875
|
+
message: import_zod.z.string()
|
|
876
|
+
})
|
|
877
|
+
])
|
|
878
|
+
)
|
|
879
|
+
);
|
|
880
|
+
var perplexitySearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
881
|
+
id: "gateway.perplexity_search",
|
|
882
|
+
inputSchema: perplexitySearchInputSchema,
|
|
883
|
+
outputSchema: perplexitySearchOutputSchema
|
|
884
|
+
});
|
|
885
|
+
var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
886
|
+
|
|
887
|
+
// src/gateway-tools.ts
|
|
888
|
+
var gatewayTools = {
|
|
889
|
+
/**
|
|
890
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
891
|
+
* news, research papers, and articles.
|
|
892
|
+
*
|
|
893
|
+
* Provides ranked search results with advanced filtering options including
|
|
894
|
+
* domain, language, date range, and recency filters.
|
|
895
|
+
*/
|
|
896
|
+
perplexitySearch
|
|
897
|
+
};
|
|
898
|
+
|
|
813
899
|
// src/vercel-environment.ts
|
|
814
900
|
var import_oidc = require("@vercel/oidc");
|
|
815
901
|
var import_oidc2 = require("@vercel/oidc");
|
|
@@ -819,10 +905,10 @@ async function getVercelRequestId() {
|
|
|
819
905
|
}
|
|
820
906
|
|
|
821
907
|
// src/gateway-provider.ts
|
|
822
|
-
var
|
|
908
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
823
909
|
|
|
824
910
|
// src/version.ts
|
|
825
|
-
var VERSION = true ? "3.0.
|
|
911
|
+
var VERSION = true ? "3.0.11" : "0.0.0-test";
|
|
826
912
|
|
|
827
913
|
// src/gateway-provider.ts
|
|
828
914
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -832,11 +918,11 @@ function createGatewayProvider(options = {}) {
|
|
|
832
918
|
let metadataCache = null;
|
|
833
919
|
const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
|
|
834
920
|
let lastFetchTime = 0;
|
|
835
|
-
const baseURL = (_b8 = (0,
|
|
921
|
+
const baseURL = (_b8 = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
836
922
|
const getHeaders = async () => {
|
|
837
923
|
try {
|
|
838
924
|
const auth = await getGatewayAuthToken(options);
|
|
839
|
-
return (0,
|
|
925
|
+
return (0, import_provider_utils10.withUserAgentSuffix)(
|
|
840
926
|
{
|
|
841
927
|
Authorization: `Bearer ${auth.token}`,
|
|
842
928
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
@@ -855,15 +941,15 @@ function createGatewayProvider(options = {}) {
|
|
|
855
941
|
}
|
|
856
942
|
};
|
|
857
943
|
const createO11yHeaders = () => {
|
|
858
|
-
const deploymentId = (0,
|
|
944
|
+
const deploymentId = (0, import_provider_utils9.loadOptionalSetting)({
|
|
859
945
|
settingValue: void 0,
|
|
860
946
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
861
947
|
});
|
|
862
|
-
const environment = (0,
|
|
948
|
+
const environment = (0, import_provider_utils9.loadOptionalSetting)({
|
|
863
949
|
settingValue: void 0,
|
|
864
950
|
environmentVariableName: "VERCEL_ENV"
|
|
865
951
|
});
|
|
866
|
-
const region = (0,
|
|
952
|
+
const region = (0, import_provider_utils9.loadOptionalSetting)({
|
|
867
953
|
settingValue: void 0,
|
|
868
954
|
environmentVariableName: "VERCEL_REGION"
|
|
869
955
|
});
|
|
@@ -951,11 +1037,12 @@ function createGatewayProvider(options = {}) {
|
|
|
951
1037
|
};
|
|
952
1038
|
provider.embeddingModel = createEmbeddingModel;
|
|
953
1039
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
1040
|
+
provider.tools = gatewayTools;
|
|
954
1041
|
return provider;
|
|
955
1042
|
}
|
|
956
1043
|
var gateway = createGatewayProvider();
|
|
957
1044
|
async function getGatewayAuthToken(options) {
|
|
958
|
-
const apiKey = (0,
|
|
1045
|
+
const apiKey = (0, import_provider_utils9.loadOptionalSetting)({
|
|
959
1046
|
settingValue: options.apiKey,
|
|
960
1047
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
961
1048
|
});
|