@ai-sdk/gateway 4.0.91 → 4.0.94

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.
@@ -29,7 +29,7 @@ For most use cases, you can use the AI Gateway directly with a model string:
29
29
  import { generateText } from 'ai';
30
30
 
31
31
  const { text } = await generateText({
32
- model: 'openai/gpt-5.4',
32
+ model: 'openai/gpt-6-astra',
33
33
  prompt: 'Hello world',
34
34
  });
35
35
  ```
@@ -39,7 +39,7 @@ const { text } = await generateText({
39
39
  import { generateText, gateway } from 'ai';
40
40
 
41
41
  const { text } = await generateText({
42
- model: gateway('openai/gpt-5.4'),
42
+ model: gateway('openai/gpt-6-astra'),
43
43
  prompt: 'Hello world',
44
44
  });
45
45
  ```
@@ -200,7 +200,7 @@ You can create language models using a provider instance. The first argument is
200
200
  import { generateText } from 'ai';
201
201
 
202
202
  const { text } = await generateText({
203
- model: 'openai/gpt-5.4',
203
+ model: 'openai/gpt-6-astra',
204
204
  prompt: 'Explain quantum computing in simple terms',
205
205
  });
206
206
  ```
@@ -586,7 +586,7 @@ availableModels.models.forEach(model => {
586
586
 
587
587
  // Use any discovered model with plain string
588
588
  const { text } = await generateText({
589
- model: availableModels.models[0].id, // e.g., 'openai/gpt-5.4'
589
+ model: availableModels.models[0].id, // e.g., 'openai/gpt-6-astra'
590
590
  prompt: 'Hello world',
591
591
  });
592
592
  ```
@@ -620,7 +620,7 @@ import { gateway, generateText } from 'ai';
620
620
 
621
621
  // Make a request
622
622
  const result = await generateText({
623
- model: gateway('anthropic/claude-sonnet-4'),
623
+ model: gateway('anthropic/claude-sonnet-5'),
624
624
  prompt: 'Explain quantum entanglement briefly',
625
625
  });
626
626
 
@@ -643,7 +643,7 @@ With `streamText`, you can capture the generation ID from the first chunk via `s
643
643
  import { gateway, streamText } from 'ai';
644
644
 
645
645
  const result = streamText({
646
- model: gateway('anthropic/claude-sonnet-4'),
646
+ model: gateway('anthropic/claude-sonnet-5'),
647
647
  prompt: 'Explain quantum entanglement briefly',
648
648
  });
649
649
 
@@ -673,7 +673,7 @@ a tool is running:
673
673
  import { gateway, generateText } from 'ai';
674
674
 
675
675
  await generateText({
676
- model: gateway('anthropic/claude-sonnet-4'),
676
+ model: gateway('anthropic/claude-sonnet-5'),
677
677
  prompt: 'Explain quantum entanglement briefly',
678
678
  onLanguageModelCallEnd({ providerMetadata }) {
679
679
  const generationId = providerMetadata?.gateway?.generationId as
@@ -720,7 +720,7 @@ It returns a `GatewayGenerationInfo` object with the following fields:
720
720
  import { generateText } from 'ai';
721
721
 
722
722
  const { text } = await generateText({
723
- model: 'anthropic/claude-sonnet-4.6',
723
+ model: 'anthropic/claude-sonnet-5',
724
724
  prompt: 'Write a haiku about programming',
725
725
  });
726
726
 
@@ -733,7 +733,7 @@ console.log(text);
733
733
  import { streamText } from 'ai';
734
734
 
735
735
  const { textStream } = await streamText({
736
- model: 'openai/gpt-5.4',
736
+ model: 'openai/gpt-6-astra',
737
737
  prompt: 'Explain the benefits of serverless architecture',
738
738
  });
739
739
 
@@ -749,7 +749,7 @@ import { generateText, tool } from 'ai';
749
749
  import { z } from 'zod';
750
750
 
751
751
  const { text } = await generateText({
752
- model: 'xai/grok-4.7',
752
+ model: 'spacexai/grok-4.7',
753
753
  prompt: 'What is the weather like in San Francisco?',
754
754
  tools: {
755
755
  getWeather: tool({
@@ -775,7 +775,7 @@ import { generateText, isStepCount } from 'ai';
775
775
  import { openai } from '@ai-sdk/openai';
776
776
 
777
777
  const result = await generateText({
778
- model: 'openai/gpt-5.4-mini',
778
+ model: 'openai/gpt-6-luna',
779
779
  prompt: 'What is the Vercel AI Gateway?',
780
780
  stopWhen: isStepCount(10),
781
781
  tools: {
@@ -985,6 +985,132 @@ token-efficient content controls. Deep synthesis modes and generated summaries
985
985
  are intentionally not exposed yet because they have separate pricing from
986
986
  standard Search.
987
987
 
988
+ #### Browserbase Search
989
+
990
+ The Browserbase Search tool enables models to search the web using [Browserbase's Search API](https://docs.browserbase.com/reference/api/web-search). It is executed by AI Gateway and returns fast, structured search results without opening a browser session.
991
+
992
+ ```ts
993
+ import { gateway, generateText } from 'ai';
994
+
995
+ const result = await generateText({
996
+ model: 'openai/gpt-5.6-luna',
997
+ prompt:
998
+ 'Find official guidance on traveling with power banks on U.S. flights. Return the most relevant page titles and URLs.',
999
+ tools: {
1000
+ browserbase_search: gateway.tools.browserbaseSearch(),
1001
+ },
1002
+ });
1003
+
1004
+ console.log(result.text);
1005
+ console.log('Tool calls:', JSON.stringify(result.toolCalls, null, 2));
1006
+ console.log('Tool results:', JSON.stringify(result.toolResults, null, 2));
1007
+ ```
1008
+
1009
+ You can configure the maximum number of results returned by each search:
1010
+
1011
+ ```ts
1012
+ import { gateway, generateText } from 'ai';
1013
+
1014
+ const result = await generateText({
1015
+ model: 'openai/gpt-5.6-luna',
1016
+ prompt:
1017
+ 'Find three recent reviews comparing e-readers for outdoor reading. Return their titles and URLs.',
1018
+ tools: {
1019
+ browserbase_search: gateway.tools.browserbaseSearch({
1020
+ numResults: 3,
1021
+ }),
1022
+ },
1023
+ });
1024
+
1025
+ console.log(result.text);
1026
+ ```
1027
+
1028
+ The Browserbase Search tool supports this optional configuration option:
1029
+
1030
+ - **numResults** _number_
1031
+
1032
+ Maximum number of search results to return (1-25, default: 10).
1033
+
1034
+ The tool works with both `generateText` and `streamText`.
1035
+
1036
+ #### Browserbase Fetch
1037
+
1038
+ The Browserbase Fetch tool enables models to retrieve page content using [Browserbase's Fetch API](https://docs.browserbase.com/platform/fetch/overview). It is a lightweight option for pages that do not require JavaScript execution or browser interaction, and it supports raw, Markdown, and schema-driven JSON output.
1039
+
1040
+ ```ts
1041
+ import { gateway, generateText } from 'ai';
1042
+
1043
+ const result = await generateText({
1044
+ model: 'openai/gpt-5.6-luna',
1045
+ prompt:
1046
+ 'Fetch https://www.nps.gov/yose/planyourvisit/halfdome.htm and summarize the permit requirements and main safety warnings.',
1047
+ tools: {
1048
+ browserbase_fetch: gateway.tools.browserbaseFetch(),
1049
+ },
1050
+ });
1051
+
1052
+ console.log(result.text);
1053
+ console.log('Tool calls:', JSON.stringify(result.toolCalls, null, 2));
1054
+ console.log('Tool results:', JSON.stringify(result.toolResults, null, 2));
1055
+ ```
1056
+
1057
+ You can configure the output format and request behavior. For example, use JSON extraction to return content matching a JSON Schema:
1058
+
1059
+ ```ts
1060
+ import { gateway, generateText } from 'ai';
1061
+
1062
+ const result = await generateText({
1063
+ model: 'openai/gpt-5.6-luna',
1064
+ prompt:
1065
+ 'Fetch https://www.nps.gov/yose/planyourvisit/halfdome.htm and extract its page title, whether a permit is required, and three safety tips.',
1066
+ tools: {
1067
+ browserbase_fetch: gateway.tools.browserbaseFetch({
1068
+ allowRedirects: true,
1069
+ format: 'json',
1070
+ schema: {
1071
+ type: 'object',
1072
+ properties: {
1073
+ pageTitle: { type: 'string' },
1074
+ permitRequired: { type: 'boolean' },
1075
+ safetyTips: {
1076
+ type: 'array',
1077
+ items: { type: 'string' },
1078
+ maxItems: 3,
1079
+ },
1080
+ },
1081
+ required: ['pageTitle', 'permitRequired', 'safetyTips'],
1082
+ },
1083
+ }),
1084
+ },
1085
+ });
1086
+
1087
+ console.log(result.text);
1088
+ ```
1089
+
1090
+ The Browserbase Fetch tool supports these optional configuration options:
1091
+
1092
+ - **format** _'raw' | 'markdown' | 'json'_
1093
+
1094
+ Output format for the fetched content. `raw` returns the upstream response body unchanged and is the default. `markdown` converts the page to Markdown. `json` performs structured extraction and requires `schema`.
1095
+
1096
+ - **schema** _object_
1097
+
1098
+ JSON Schema describing the desired structured content. Only used when `format` is `json`.
1099
+
1100
+ - **allowRedirects** _boolean_
1101
+
1102
+ Follow HTTP redirects. Defaults to `false`.
1103
+
1104
+ - **proxies** _boolean_
1105
+
1106
+ Route the request through Browserbase's proxy network. Defaults to `false`.
1107
+
1108
+ - **allowInsecureSsl** _boolean_
1109
+
1110
+ Bypass TLS certificate verification. Defaults to `false`; only enable it for trusted hosts.
1111
+
1112
+ The Fetch API does not execute JavaScript. Use a browser session for interactive or JavaScript-rendered pages. The tool works with both `generateText` and `streamText`.
1113
+
988
1114
  #### Tako Search
989
1115
 
990
1116
  The Tako Search tool enables models to search the web and Tako's curated knowledge graph in a single call using [Tako's Search API](https://docs.tako.com/documentation/integrating-tako/search/overview). This tool is executed by the AI Gateway and returns token-efficient web excerpts, plus knowledge-graph results that carry structured data, premium source attribution, and an embed-ready visualization.
@@ -1207,7 +1333,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1207
1333
  import { generateText } from 'ai';
1208
1334
 
1209
1335
  const { text } = await generateText({
1210
- model: 'openai/gpt-5.4',
1336
+ model: 'openai/gpt-6-astra',
1211
1337
  prompt: 'Summarize this document...',
1212
1338
  providerOptions: {
1213
1339
  gateway: {
@@ -1249,7 +1375,7 @@ The `getSpendReport()` method accepts the following parameters:
1249
1375
  - **groupBy** _string_ - Aggregation dimension: `'day'` (default), `'user'`, `'model'`, `'tag'`, `'provider'`, or `'credential_type'`
1250
1376
  - **datePart** _string_ - Time granularity when `groupBy` is `'day'`: `'day'` or `'hour'`
1251
1377
  - **userId** _string_ - Filter to a specific user
1252
- - **model** _string_ - Filter to a specific model (e.g. `'anthropic/claude-sonnet-4.5'`)
1378
+ - **model** _string_ - Filter to a specific model (e.g. `'anthropic/claude-sonnet-5'`)
1253
1379
  - **provider** _string_ - Filter to a specific provider (e.g. `'anthropic'`)
1254
1380
  - **credentialType** _string_ - Filter by `'byok'` or `'system'` credentials
1255
1381
  - **tags** _string[]_ - Filter to requests matching these tags
@@ -1308,7 +1434,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1308
1434
  import { generateText } from 'ai';
1309
1435
 
1310
1436
  const { text } = await generateText({
1311
- model: 'anthropic/claude-sonnet-4.6',
1437
+ model: 'anthropic/claude-sonnet-5',
1312
1438
  prompt: 'Explain quantum computing',
1313
1439
  providerOptions: {
1314
1440
  gateway: {
@@ -1350,7 +1476,7 @@ The following gateway provider options are available:
1350
1476
 
1351
1477
  Specifies fallback models to use when the primary model fails or is unavailable. The gateway will try the primary model first (specified in the `model` parameter), then try each model in this array in order until one succeeds.
1352
1478
 
1353
- Example: `models: ['openai/gpt-5.4-nano', 'gemini-3-flash-preview']` will try the fallback models in order if the primary model fails.
1479
+ Example: `models: ['openai/gpt-5.4-nano', 'google/gemini-3.8-flash']` will try the fallback models in order if the primary model fails.
1354
1480
 
1355
1481
  - **user** _string_
1356
1482
 
@@ -1390,13 +1516,14 @@ The following gateway provider options are available:
1390
1516
 
1391
1517
  The unique identifier for the entity against which quota is tracked. Used for quota management and enforcement purposes.
1392
1518
 
1393
- - **has** _Array<'implicit-caching' | 'reasoning' | 'tool-use' | 'vision' | `quantization:${string}` | `!quantization:${string}`>_
1519
+ - **has** _Array<'implicit-caching' | 'reasoning' | 'structured-output' | 'tool-use' | 'vision' | `quantization:${string}` | `!quantization:${string}`>_
1394
1520
 
1395
1521
  Restricts routing to provider models that have all of the specified capabilities. Applies to both BYOK and system credentials, since the capability is a property of the model rather than the credential. If no provider model for the requested model satisfies the capabilities, the request fails. Unsupported values are rejected.
1396
1522
 
1397
1523
  Supported capabilities:
1398
1524
  - `'implicit-caching'` — models that perform automatic (implicit) prompt caching.
1399
1525
  - `'reasoning'` — models that support reasoning.
1526
+ - `'structured-output'` — models that support schema-constrained output.
1400
1527
  - `'tool-use'` — models that support tool calling.
1401
1528
  - `'vision'` — models that accept image input.
1402
1529
 
@@ -1428,7 +1555,7 @@ The following gateway provider options are available:
1428
1555
  import { generateText } from 'ai';
1429
1556
 
1430
1557
  const { text } = await generateText({
1431
- model: 'openai/gpt-5-mini',
1558
+ model: 'openai/gpt-6-luna',
1432
1559
  prompt: 'Hello',
1433
1560
  providerOptions: {
1434
1561
  gateway: {
@@ -1445,7 +1572,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1445
1572
  import { generateText } from 'ai';
1446
1573
 
1447
1574
  const { text } = await generateText({
1448
- model: 'anthropic/claude-sonnet-4.6',
1575
+ model: 'anthropic/claude-sonnet-5',
1449
1576
  prompt: 'Write a haiku about programming',
1450
1577
  providerOptions: {
1451
1578
  gateway: {
@@ -1465,11 +1592,11 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1465
1592
  import { generateText } from 'ai';
1466
1593
 
1467
1594
  const { text } = await generateText({
1468
- model: 'openai/gpt-5.4', // Primary model
1595
+ model: 'openai/gpt-6-astra', // Primary model
1469
1596
  prompt: 'Write a TypeScript haiku',
1470
1597
  providerOptions: {
1471
1598
  gateway: {
1472
- models: ['openai/gpt-5.4-nano', 'gemini-3-flash-preview'], // Fallback models
1599
+ models: ['openai/gpt-5.4-nano', 'gemini-3.8-flash'], // Fallback models
1473
1600
  } satisfies GatewayProviderOptions,
1474
1601
  },
1475
1602
  });
@@ -1490,7 +1617,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1490
1617
  import { generateText } from 'ai';
1491
1618
 
1492
1619
  const { text } = await generateText({
1493
- model: 'anthropic/claude-sonnet-4.6',
1620
+ model: 'anthropic/claude-sonnet-5',
1494
1621
  prompt: 'Analyze this sensitive document...',
1495
1622
  providerOptions: {
1496
1623
  gateway: {
@@ -1509,7 +1636,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1509
1636
  import { generateText } from 'ai';
1510
1637
 
1511
1638
  const { text } = await generateText({
1512
- model: 'anthropic/claude-sonnet-4.6',
1639
+ model: 'anthropic/claude-sonnet-5',
1513
1640
  prompt: 'Analyze this proprietary business data...',
1514
1641
  providerOptions: {
1515
1642
  gateway: {
@@ -1528,7 +1655,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1528
1655
  import { generateText } from 'ai';
1529
1656
 
1530
1657
  const { text } = await generateText({
1531
- model: 'anthropic/claude-sonnet-4.6',
1658
+ model: 'anthropic/claude-sonnet-5',
1532
1659
  prompt: 'Summarize this report...',
1533
1660
  providerOptions: {
1534
1661
  gateway: {
@@ -1540,14 +1667,14 @@ const { text } = await generateText({
1540
1667
 
1541
1668
  #### Filtering by Model Capability
1542
1669
 
1543
- Set `has` to restrict routing to provider models that have the specified capabilities. This applies to both BYOK and system credentials, since the capability is a property of the model rather than the credential. `'implicit-caching'` limits routing to models that perform automatic prompt caching, `'vision'` limits routing to models that accept image input, `'reasoning'` limits routing to models that support reasoning, and `'tool-use'` limits routing to models that support tool calling. Weight-format conditions (`'quantization:fp8'` to require, `'!quantization:fp8'` to exclude) limit routing by the serving provider's recorded weight format. If no provider model for the requested model satisfies the capabilities, the request fails.
1670
+ Set `has` to restrict routing to provider models that have the specified capabilities. This applies to both BYOK and system credentials, since the capability is a property of the model rather than the credential. `'implicit-caching'` limits routing to models that perform automatic prompt caching, `'vision'` limits routing to models that accept image input, `'reasoning'` limits routing to models that support reasoning, `'structured-output'` limits routing to models that support schema-constrained output, and `'tool-use'` limits routing to models that support tool calling. Weight-format conditions (`'quantization:fp8'` to require, `'!quantization:fp8'` to exclude) limit routing by the serving provider's recorded weight format. If no provider model for the requested model satisfies the capabilities, the request fails.
1544
1671
 
1545
1672
  ```ts
1546
1673
  import type { GatewayProviderOptions } from '@ai-sdk/gateway';
1547
1674
  import { generateText } from 'ai';
1548
1675
 
1549
1676
  const { text } = await generateText({
1550
- model: 'openai/gpt-5.5',
1677
+ model: 'openai/gpt-6-astra',
1551
1678
  prompt: 'Summarize this report...',
1552
1679
  providerOptions: {
1553
1680
  gateway: {
@@ -1566,7 +1693,7 @@ import { generateText } from 'ai';
1566
1693
  import fs from 'node:fs';
1567
1694
 
1568
1695
  const { text } = await generateText({
1569
- model: 'anthropic/claude-sonnet-4.6',
1696
+ model: 'anthropic/claude-sonnet-5',
1570
1697
  messages: [
1571
1698
  {
1572
1699
  role: 'user',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "4.0.91",
4
+ "version": "4.0.94",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "sideEffects": false,
@@ -31,11 +31,11 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@ai-sdk/provider": "4.0.18",
34
- "@ai-sdk/provider-utils": "5.0.47",
34
+ "@ai-sdk/provider-utils": "5.0.49",
35
35
  "@vercel/oidc": "3.2.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@ai-sdk/test-server": "2.0.1",
38
+ "@ai-sdk/test-server": "2.0.2",
39
39
  "@types/node": "22.19.19",
40
40
  "@vercel/ai-tsconfig": "0.0.0",
41
41
  "tsup": "^8.5.1",
@@ -27,6 +27,7 @@ export type GatewayImageModelId =
27
27
  | 'recraft/recraft-v4'
28
28
  | 'recraft/recraft-v4-pro'
29
29
  | 'recraft/recraft-v4.1'
30
+ | 'recraft/recraft-v4.1-flash'
30
31
  | 'recraft/recraft-v4.1-pro'
31
32
  | 'recraft/recraft-v4.1-utility'
32
33
  | 'recraft/recraft-v4.1-utility-pro'
@@ -29,6 +29,7 @@ export type GatewayModelId =
29
29
  | 'alibaba/qwen3.8-flash'
30
30
  | 'alibaba/qwen3.8-max'
31
31
  | 'alibaba/qwen3.8-max-0902'
32
+ | 'alibaba/qwen3.8-max-prime'
32
33
  | 'alibaba/qwen3.8-omni-flash'
33
34
  | 'amazon/nova-2-lite'
34
35
  | 'amazon/nova-lite'
@@ -47,6 +48,7 @@ export type GatewayModelId =
47
48
  | 'anthropic/claude-opus-5'
48
49
  | 'anthropic/claude-opus-5-fast'
49
50
  | 'anthropic/claude-opus-5.5'
51
+ | 'anthropic/claude-opus-5.5-fast'
50
52
  | 'anthropic/claude-sonnet-4'
51
53
  | 'anthropic/claude-sonnet-4.5'
52
54
  | 'anthropic/claude-sonnet-4.6'
@@ -67,6 +69,7 @@ export type GatewayModelId =
67
69
  | 'deepseek/deepseek-v4-pro'
68
70
  | 'deepseek/deepseek-v4-pro-0813'
69
71
  | 'deepseek/deepseek-v4.1-flash'
72
+ | 'fireworks/ember-1'
70
73
  | 'google/gemini-2.5-flash'
71
74
  | 'google/gemini-2.5-flash-image'
72
75
  | 'google/gemini-2.5-flash-lite'
@@ -95,7 +98,6 @@ export type GatewayModelId =
95
98
  | 'inclusionai/ling-3.0-flash-sante'
96
99
  | 'inclusionai/ling-3.0-flash-sante-free'
97
100
  | 'inclusionai/ling-3.0-flash-vl'
98
- | 'inclusionai/ling-3.0-flash-vl-free'
99
101
  | 'inference-net/schematron-v2-small'
100
102
  | 'inference-net/schematron-v2-turbo'
101
103
  | 'interfaze/interfaze-beta'
@@ -19,16 +19,18 @@ export type GatewayProviderOptions = {
19
19
  * Restrict routing to provider models that satisfy every given entry.
20
20
  *
21
21
  * Entries are capability tags (`'implicit-caching'`, `'reasoning'`,
22
- * `'tool-use'`, `'vision'`) or weight-format conditions: `'quantization:fp8'`
23
- * requires the serving provider to report that weight format,
24
- * `'!quantization:fp8'` excludes it (providers with no recorded format still
25
- * pass an exclusion). Format values are an open space but must match
26
- * `[a-zA-Z0-9._-]{1,32}` and compare case-insensitively; unknown capability
27
- * names are rejected by the Gateway with a 400.
22
+ * `'tool-use'`, `'vision'` (image input), `'structured-output'`
23
+ * (schema-constrained output)) or weight-format conditions:
24
+ * `'quantization:fp8'` requires the serving provider to report that weight
25
+ * format, `'!quantization:fp8'` excludes it (providers with no recorded
26
+ * format still pass an exclusion). Format values are an open space but must
27
+ * match `[a-zA-Z0-9._-]{1,32}` and compare case-insensitively. Unknown
28
+ * capability names are rejected by the Gateway with a 400.
28
29
  */
29
30
  has?: Array<
30
31
  | 'implicit-caching'
31
32
  | 'reasoning'
33
+ | 'structured-output'
32
34
  | 'tool-use'
33
35
  | 'vision'
34
36
  | `quantization:${string}`
@@ -2,8 +2,8 @@ export type GatewaySpeechModelId =
2
2
  | 'fish-audio/s1'
3
3
  | 'fish-audio/s2-pro'
4
4
  | 'fish-audio/s2.1-pro'
5
- | 'google/gemini-3.8-flash-tts'
6
5
  | 'google/gemini-3.8-flash-lite-tts'
6
+ | 'google/gemini-3.8-flash-tts'
7
7
  | 'openai/tts-1'
8
8
  | 'openai/tts-1-hd'
9
9
  | 'spacexai/grok-tts'
@@ -1,3 +1,5 @@
1
+ import { browserbaseFetch } from './tool/browserbase-fetch';
2
+ import { browserbaseSearch } from './tool/browserbase-search';
1
3
  import { exaSearch } from './tool/exa-search';
2
4
  import { parallelSearch } from './tool/parallel-search';
3
5
  import { perplexitySearch } from './tool/perplexity-search';
@@ -7,6 +9,22 @@ import { takoSearch } from './tool/tako-search';
7
9
  * Gateway-specific provider-defined tools.
8
10
  */
9
11
  export const gatewayTools = {
12
+ /**
13
+ * Fetch page content using Browserbase's lightweight Fetch API.
14
+ *
15
+ * Supports raw, Markdown, and schema-driven JSON output as well as redirects,
16
+ * proxy routing, and TLS controls.
17
+ */
18
+ browserbaseFetch,
19
+
20
+ /**
21
+ * Search the web using Browserbase's Search API for fast, structured results.
22
+ *
23
+ * Returns titles, URLs, and available publication metadata without requiring
24
+ * a browser session.
25
+ */
26
+ browserbaseSearch,
27
+
10
28
  /**
11
29
  * Search the web using Exa for current information and token-efficient
12
30
  * excerpts optimized for agent workflows.
@@ -0,0 +1,157 @@
1
+ import {
2
+ createProviderExecutedToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from '../zod';
7
+
8
+ export type BrowserbaseFetchFormat = 'raw' | 'json' | 'markdown';
9
+
10
+ export interface BrowserbaseFetchConfig {
11
+ /** Whether to follow HTTP redirects (default: false). */
12
+ allowRedirects?: boolean;
13
+ /** Whether to bypass TLS certificate verification (default: false). */
14
+ allowInsecureSsl?: boolean;
15
+ /** Whether to route the request through Browserbase proxies (default: false). */
16
+ proxies?: boolean;
17
+ /** Output format for the response content (default: raw). */
18
+ format?: BrowserbaseFetchFormat;
19
+ /**
20
+ * JSON Schema describing the desired response content. Only used when format
21
+ * is json.
22
+ */
23
+ schema?: Record<string, unknown>;
24
+ }
25
+
26
+ export interface BrowserbaseFetchInput {
27
+ /** URL of the page to fetch. */
28
+ url: string;
29
+ /** Whether to follow HTTP redirects. */
30
+ allow_redirects?: boolean;
31
+ /** Whether to bypass TLS certificate verification. */
32
+ allow_insecure_ssl?: boolean;
33
+ /** Whether to route the request through Browserbase proxies. */
34
+ proxies?: boolean;
35
+ /** Output format for the response content. */
36
+ format?: BrowserbaseFetchFormat;
37
+ /**
38
+ * JSON Schema describing the desired response content. Only used when format
39
+ * is json.
40
+ */
41
+ schema?: Record<string, unknown>;
42
+ }
43
+
44
+ export interface BrowserbaseFetchResponse {
45
+ /** Unique identifier for the fetch request. */
46
+ id: string;
47
+ /**
48
+ * Response body. Raw and markdown responses return strings; JSON extraction
49
+ * returns an object matching the requested schema.
50
+ */
51
+ content: string | Record<string, unknown>;
52
+ /** MIME type of the response. */
53
+ contentType: string;
54
+ /** Character encoding of the response. */
55
+ encoding: string;
56
+ /** Response headers from the fetched page. */
57
+ headers: Record<string, string>;
58
+ /** HTTP status code returned by the fetched page. */
59
+ statusCode: number;
60
+ }
61
+
62
+ export interface BrowserbaseFetchError {
63
+ error:
64
+ | 'api_error'
65
+ | 'configuration_error'
66
+ | 'execution_error'
67
+ | 'invalid_input'
68
+ | 'rate_limit'
69
+ | 'timeout'
70
+ | 'unknown';
71
+ statusCode?: number;
72
+ message: string;
73
+ }
74
+
75
+ export type BrowserbaseFetchOutput =
76
+ | BrowserbaseFetchError
77
+ | BrowserbaseFetchResponse;
78
+
79
+ const jsonObjectSchema = z.record(z.string(), z.unknown());
80
+
81
+ const browserbaseFetchInputSchema = lazySchema(() =>
82
+ zodSchema(
83
+ z.object({
84
+ url: z.string().url().describe('URL of the page to fetch.'),
85
+ allow_redirects: z
86
+ .boolean()
87
+ .optional()
88
+ .describe('Whether to follow HTTP redirects (default: false).'),
89
+ allow_insecure_ssl: z
90
+ .boolean()
91
+ .optional()
92
+ .describe(
93
+ 'Whether to bypass TLS certificate verification (default: false). Only use for trusted hosts.',
94
+ ),
95
+ proxies: z
96
+ .boolean()
97
+ .optional()
98
+ .describe(
99
+ 'Whether to route the request through Browserbase proxies (default: false).',
100
+ ),
101
+ format: z
102
+ .enum(['raw', 'json', 'markdown'])
103
+ .optional()
104
+ .describe(
105
+ 'Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema.',
106
+ ),
107
+ schema: jsonObjectSchema
108
+ .optional()
109
+ .describe(
110
+ 'JSON Schema for structured extraction. Only use with format set to json.',
111
+ ),
112
+ }),
113
+ ),
114
+ );
115
+
116
+ const browserbaseFetchOutputSchema = lazySchema(() =>
117
+ zodSchema(
118
+ z.union([
119
+ z.object({
120
+ id: z.string(),
121
+ content: z.union([z.string(), jsonObjectSchema]),
122
+ contentType: z.string(),
123
+ encoding: z.string(),
124
+ headers: z.record(z.string(), z.string()),
125
+ statusCode: z.number(),
126
+ }),
127
+ z.object({
128
+ error: z.enum([
129
+ 'api_error',
130
+ 'configuration_error',
131
+ 'execution_error',
132
+ 'invalid_input',
133
+ 'rate_limit',
134
+ 'timeout',
135
+ 'unknown',
136
+ ]),
137
+ statusCode: z.number().optional(),
138
+ message: z.string(),
139
+ }),
140
+ ]),
141
+ ),
142
+ );
143
+
144
+ export const browserbaseFetchToolFactory = createProviderExecutedToolFactory<
145
+ BrowserbaseFetchInput,
146
+ BrowserbaseFetchOutput,
147
+ BrowserbaseFetchConfig
148
+ >({
149
+ id: 'gateway.browserbase_fetch',
150
+ inputSchema: browserbaseFetchInputSchema,
151
+ outputSchema: browserbaseFetchOutputSchema,
152
+ });
153
+
154
+ export const browserbaseFetch = (
155
+ config: BrowserbaseFetchConfig = {},
156
+ ): ReturnType<typeof browserbaseFetchToolFactory> =>
157
+ browserbaseFetchToolFactory(config);