@ai-sdk/gateway 3.0.232 → 3.0.235
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 +26 -0
- package/dist/index.d.mts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/docs/00-ai-gateway.mdx +38 -1
- package/package.json +2 -2
- package/src/gateway-language-model-settings.ts +6 -0
- package/src/tool/tako-search.ts +74 -5
package/docs/00-ai-gateway.mdx
CHANGED
|
@@ -801,7 +801,7 @@ console.log('Tool calls:', JSON.stringify(result.toolCalls, null, 2));
|
|
|
801
801
|
console.log('Tool results:', JSON.stringify(result.toolResults, null, 2));
|
|
802
802
|
```
|
|
803
803
|
|
|
804
|
-
Configure the search with effort, source selection, and localization defaults. These defaults override values the model includes in a tool call:
|
|
804
|
+
Configure the search with effort, source selection, and localization defaults. These defaults override values the model includes in a tool call. `variableCost`, `maxVariableCostUsd`, and `extraBody` are developer-only: the model can't see or set them.
|
|
805
805
|
|
|
806
806
|
```ts
|
|
807
807
|
import { gateway, generateText } from 'ai';
|
|
@@ -856,6 +856,43 @@ The Tako Search tool supports these optional configuration options:
|
|
|
856
856
|
- **timezone** _string_ - IANA timezone, such as `'America/New_York'`.
|
|
857
857
|
- **outputSettings** _object_ - Card rendering controls. `forceRefresh` is available only with `'instant'` effort.
|
|
858
858
|
- **includeRelated** _number_ - Number of related search suggestions to include (1-20).
|
|
859
|
+
- **variableCost** _boolean_ - Serve data from sources priced per unit, such as web traffic and SEO. Each such card adds a charge, and the total per call is capped by `maxVariableCostUsd`. Defaults to `true`. Set it to `false` to opt out; those cards then come back as placeholders. Only searches that include the data index (`sources.data` set, or `sources` omitted) return these cards.
|
|
860
|
+
- **maxVariableCostUsd** _number | null_ - The most one search call can be charged in variable cost, in USD.
|
|
861
|
+
- Defaults to `0.25`, and `null` removes the cap.
|
|
862
|
+
- Tako checks each card's maximum charge (`content.export_pricing.variable_cost_max_usd`) in rank order. A card that doesn't fit comes back as a placeholder with `reason: 'over_cap'`, even if its actual charge would have fit.
|
|
863
|
+
- `0` returns only the cards whose charge the base price already covers.
|
|
864
|
+
- It can't be combined with `variableCost: false`.
|
|
865
|
+
- **extraBody** _Record<string, unknown>_ - Extra Tako request fields, in snake_case, deep-merged into the request body last. Objects merge, and scalars and arrays replace. Use it for Tako parameters this tool doesn't model yet. Its limits:
|
|
866
|
+
- It can't set a field the tool already models, including the `sources.data` variable-cost fields. The gateway answers `invalid_input`.
|
|
867
|
+
- Tako rejects unknown keys, so a typo comes back as an `api_error`.
|
|
868
|
+
- It's limited to 16,384 serialized characters.
|
|
869
|
+
|
|
870
|
+
When Tako withholds a card's data, it returns a placeholder card instead. A placeholder keeps its title and a description but carries no data. `placeholder.withheld_source` names the source, and `placeholder.reason` is `'not_served'` (variable cost is off, or the account isn't served that source) or `'over_cap'`. `usage.variable_cost.cost_usd` reports the variable-cost charge for the call:
|
|
871
|
+
|
|
872
|
+
```ts
|
|
873
|
+
import { gateway, generateText } from 'ai';
|
|
874
|
+
|
|
875
|
+
const result = await generateText({
|
|
876
|
+
model: 'openai/gpt-5.4-nano',
|
|
877
|
+
prompt: 'How much monthly web traffic does vercel.com get?',
|
|
878
|
+
tools: {
|
|
879
|
+
tako_search: gateway.tools.takoSearch({
|
|
880
|
+
sources: { data: {}, web: {} },
|
|
881
|
+
maxVariableCostUsd: 0.1,
|
|
882
|
+
}),
|
|
883
|
+
},
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
for (const toolResult of result.toolResults) {
|
|
887
|
+
if (toolResult.dynamic || 'error' in toolResult.output) continue;
|
|
888
|
+
for (const card of toolResult.output.cards ?? []) {
|
|
889
|
+
if (card.placeholder) {
|
|
890
|
+
const reason = card.placeholder.reason ?? 'not_served';
|
|
891
|
+
console.log(`Withheld (${reason}):`, card.title);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
```
|
|
859
896
|
|
|
860
897
|
For precise entity matching, quote a phrase in the query and optionally append a label: `"Tesla":PRODUCT price`. Tako treats the quoted phrase as one entity before searching.
|
|
861
898
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/gateway",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.235",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@vercel/oidc": "3.2.0",
|
|
34
34
|
"@ai-sdk/provider": "3.0.19",
|
|
35
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
35
|
+
"@ai-sdk/provider-utils": "4.0.66"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "18.15.11",
|
|
@@ -32,6 +32,8 @@ export type GatewayModelId =
|
|
|
32
32
|
| 'anthropic/claude-fable-5-batch'
|
|
33
33
|
| 'anthropic/claude-fable-5.1'
|
|
34
34
|
| 'anthropic/claude-fable-5.1-batch'
|
|
35
|
+
| 'anthropic/claude-fable-5.2'
|
|
36
|
+
| 'anthropic/claude-fable-5.2-batch'
|
|
35
37
|
| 'anthropic/claude-haiku-4.5'
|
|
36
38
|
| 'anthropic/claude-haiku-4.5-batch'
|
|
37
39
|
| 'anthropic/claude-haiku-5.5'
|
|
@@ -76,6 +78,7 @@ export type GatewayModelId =
|
|
|
76
78
|
| 'deepseek/deepseek-v4.1-flash'
|
|
77
79
|
| 'deepseek/deepseek-v4.1-flash-1017'
|
|
78
80
|
| 'deepseek/deepseek-v4.1-flash-1017-fast'
|
|
81
|
+
| 'deepseek/deepseek-v4.1-flash-1017-ultrafast'
|
|
79
82
|
| 'deepseek/deepseek-v4.1-flash-fast'
|
|
80
83
|
| 'elorian/glimpse'
|
|
81
84
|
| 'fireworks/ember-1'
|
|
@@ -103,11 +106,13 @@ export type GatewayModelId =
|
|
|
103
106
|
| 'google/gemini-3.7-flash'
|
|
104
107
|
| 'google/gemini-3.8-flash'
|
|
105
108
|
| 'google/gemini-4-argon'
|
|
109
|
+
| 'google/gemini-4-carbon'
|
|
106
110
|
| 'google/gemini-nano-banana-2.1'
|
|
107
111
|
| 'google/gemini-omni-1.2-flash'
|
|
108
112
|
| 'google/gemini-omni-flash-preview'
|
|
109
113
|
| 'google/gemma-4-26b-a4b-it'
|
|
110
114
|
| 'google/gemma-4-31b-it'
|
|
115
|
+
| 'humansand/ampersand-v0.1'
|
|
111
116
|
| 'inception/mercury-2'
|
|
112
117
|
| 'inception/mercury-2.5'
|
|
113
118
|
| 'inception/mercury-3'
|
|
@@ -128,6 +133,7 @@ export type GatewayModelId =
|
|
|
128
133
|
| 'meta/llama-3.3-70b'
|
|
129
134
|
| 'meta/llama-4-maverick'
|
|
130
135
|
| 'meta/llama-4-scout'
|
|
136
|
+
| 'meta/muse-ember'
|
|
131
137
|
| 'meta/muse-glimmer-30b'
|
|
132
138
|
| 'meta/muse-spark-1.1'
|
|
133
139
|
| 'meta/muse-spark-1.2'
|
package/src/tool/tako-search.ts
CHANGED
|
@@ -97,6 +97,23 @@ export interface TakoSearchConfig {
|
|
|
97
97
|
};
|
|
98
98
|
/** Maximum related search suggestions to include (1-20). */
|
|
99
99
|
includeRelated?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Serve per-unit-priced data, such as web traffic and SEO. Each such card adds
|
|
102
|
+
* a charge, capped by maxVariableCostUsd. On by default; set false to opt out,
|
|
103
|
+
* and those cards come back as placeholders.
|
|
104
|
+
*/
|
|
105
|
+
variableCost?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Most one call can be charged in variable cost, in USD. Defaults to 0.25;
|
|
108
|
+
* null removes the cap. Cards that don't fit come back as placeholders with
|
|
109
|
+
* reason 'over_cap'. Can't be combined with variableCost: false.
|
|
110
|
+
*/
|
|
111
|
+
maxVariableCostUsd?: number | null;
|
|
112
|
+
/**
|
|
113
|
+
* Extra Tako request fields in snake_case, deep-merged into the body last.
|
|
114
|
+
* Can't set fields this tool models; Tako rejects unknown keys (api_error).
|
|
115
|
+
*/
|
|
116
|
+
extraBody?: Record<string, unknown>;
|
|
100
117
|
}
|
|
101
118
|
|
|
102
119
|
export interface TakoSearchInput {
|
|
@@ -168,11 +185,22 @@ export interface TakoResultContent {
|
|
|
168
185
|
expires_at?: string | null;
|
|
169
186
|
total_rows?: number | null;
|
|
170
187
|
truncated?: boolean;
|
|
188
|
+
/** Distinct records per premium class (e.g. company_record) among delivered rows. */
|
|
189
|
+
premium_rows?: Record<string, number> | null;
|
|
190
|
+
/** Column header → 0-based delivered-row positions whose premium value was withheld. */
|
|
191
|
+
redacted_cells?: Record<string, number[]> | null;
|
|
192
|
+
/** Full set size when the card lists only a capped slice of it. */
|
|
193
|
+
total_matching?: number | null;
|
|
171
194
|
export_pricing?: {
|
|
172
195
|
baseline_usd: number;
|
|
173
|
-
|
|
196
|
+
/** @deprecated Always 0, and Tako will stop sending it. */
|
|
197
|
+
free_rows?: number;
|
|
174
198
|
max_rows_ceiling: number;
|
|
175
199
|
row_cpm_usd: number;
|
|
200
|
+
/** USD per 1,000 premium records by class, added to row_cpm_usd when premium. */
|
|
201
|
+
premium_row_cpm_usd?: Record<string, number> | null;
|
|
202
|
+
/** Upper bound on this card's variable-cost charge; set only for per-unit-priced sources. */
|
|
203
|
+
variable_cost_max_usd?: number | null;
|
|
176
204
|
} | null;
|
|
177
205
|
manifest?: Array<{
|
|
178
206
|
dtype?: 'boolean' | 'date' | 'datetime' | 'number' | 'string' | null;
|
|
@@ -205,6 +233,8 @@ export interface TakoCard {
|
|
|
205
233
|
source_indexes?: Array<'data' | 'web'> | null;
|
|
206
234
|
card_type?: string | null;
|
|
207
235
|
relevance?: 'High' | 'Low' | 'Medium' | null;
|
|
236
|
+
/** Relevance to the query, 1.0-5.0. Null unless the account is entitled. */
|
|
237
|
+
relevance_score?: number | null;
|
|
208
238
|
content?: TakoResultContent | null;
|
|
209
239
|
exportable?: boolean;
|
|
210
240
|
nodes?: Array<{
|
|
@@ -222,6 +252,14 @@ export interface TakoCard {
|
|
|
222
252
|
data_as_of?: string | null;
|
|
223
253
|
last_updated?: string | null;
|
|
224
254
|
} | null;
|
|
255
|
+
/**
|
|
256
|
+
* Set when Tako withholds the card's data: variable cost off or not served
|
|
257
|
+
* (`not_served`), or over maxVariableCostUsd (`over_cap`).
|
|
258
|
+
*/
|
|
259
|
+
placeholder?: {
|
|
260
|
+
withheld_source: string;
|
|
261
|
+
reason?: 'not_served' | 'over_cap' | null;
|
|
262
|
+
} | null;
|
|
225
263
|
}
|
|
226
264
|
|
|
227
265
|
export interface TakoWebResult {
|
|
@@ -245,6 +283,10 @@ export interface TakoSearchResponse {
|
|
|
245
283
|
data?: {
|
|
246
284
|
cost_usd: number;
|
|
247
285
|
datasets: number;
|
|
286
|
+
data_points?: number | null;
|
|
287
|
+
} | null;
|
|
288
|
+
variable_cost?: {
|
|
289
|
+
cost_usd: number;
|
|
248
290
|
} | null;
|
|
249
291
|
} | null;
|
|
250
292
|
related?: Array<Record<string, unknown>> | null;
|
|
@@ -413,7 +455,7 @@ const takoSearchInputSchema = lazySchema(() =>
|
|
|
413
455
|
const takoDatasetCellSchema = () =>
|
|
414
456
|
z.union([z.boolean(), z.number(), z.string()]).nullable();
|
|
415
457
|
|
|
416
|
-
const takoResultContentSchema = () =>
|
|
458
|
+
export const takoResultContentSchema = () =>
|
|
417
459
|
z
|
|
418
460
|
.object({
|
|
419
461
|
content_format: z
|
|
@@ -450,13 +492,19 @@ const takoResultContentSchema = () =>
|
|
|
450
492
|
expires_at: z.string().nullish(),
|
|
451
493
|
total_rows: z.number().nullish(),
|
|
452
494
|
truncated: z.boolean().optional(),
|
|
495
|
+
premium_rows: z.record(z.string(), z.number()).nullish(),
|
|
496
|
+
redacted_cells: z.record(z.string(), z.array(z.number())).nullish(),
|
|
497
|
+
total_matching: z.number().nullish(),
|
|
453
498
|
export_pricing: z
|
|
454
499
|
.object({
|
|
455
500
|
baseline_usd: z.number(),
|
|
456
|
-
free_rows: z.number(),
|
|
501
|
+
free_rows: z.number().optional(),
|
|
457
502
|
max_rows_ceiling: z.number(),
|
|
458
503
|
row_cpm_usd: z.number(),
|
|
504
|
+
premium_row_cpm_usd: z.record(z.string(), z.number()).nullish(),
|
|
505
|
+
variable_cost_max_usd: z.number().nullish(),
|
|
459
506
|
})
|
|
507
|
+
.passthrough()
|
|
460
508
|
.nullish(),
|
|
461
509
|
manifest: z
|
|
462
510
|
.array(
|
|
@@ -506,6 +554,7 @@ const takoCardSchema = () =>
|
|
|
506
554
|
source_indexes: z.array(z.enum(['data', 'web'])).nullish(),
|
|
507
555
|
card_type: z.string().nullish(),
|
|
508
556
|
relevance: z.enum(['High', 'Low', 'Medium']).nullish(),
|
|
557
|
+
relevance_score: z.number().nullish(),
|
|
509
558
|
content: takoResultContentSchema().nullish(),
|
|
510
559
|
exportable: z.boolean().optional(),
|
|
511
560
|
nodes: z
|
|
@@ -528,6 +577,13 @@ const takoCardSchema = () =>
|
|
|
528
577
|
last_updated: z.string().nullish(),
|
|
529
578
|
})
|
|
530
579
|
.nullish(),
|
|
580
|
+
placeholder: z
|
|
581
|
+
.object({
|
|
582
|
+
withheld_source: z.string(),
|
|
583
|
+
reason: z.enum(['not_served', 'over_cap']).nullish(),
|
|
584
|
+
})
|
|
585
|
+
.passthrough()
|
|
586
|
+
.nullish(),
|
|
531
587
|
})
|
|
532
588
|
.passthrough();
|
|
533
589
|
|
|
@@ -554,11 +610,24 @@ const takoSearchOutputSchema = lazySchema(() =>
|
|
|
554
610
|
usage: z
|
|
555
611
|
.object({
|
|
556
612
|
total_cost_usd: z.number(),
|
|
557
|
-
compute: z
|
|
613
|
+
compute: z
|
|
614
|
+
.object({ cost_usd: z.number() })
|
|
615
|
+
.passthrough()
|
|
616
|
+
.nullish(),
|
|
558
617
|
data: z
|
|
559
|
-
.object({
|
|
618
|
+
.object({
|
|
619
|
+
cost_usd: z.number(),
|
|
620
|
+
datasets: z.number(),
|
|
621
|
+
data_points: z.number().nullish(),
|
|
622
|
+
})
|
|
623
|
+
.passthrough()
|
|
624
|
+
.nullish(),
|
|
625
|
+
variable_cost: z
|
|
626
|
+
.object({ cost_usd: z.number() })
|
|
627
|
+
.passthrough()
|
|
560
628
|
.nullish(),
|
|
561
629
|
})
|
|
630
|
+
.passthrough()
|
|
562
631
|
.nullish(),
|
|
563
632
|
related: z.array(z.object({}).passthrough()).nullish(),
|
|
564
633
|
})
|