@ai-sdk/gateway 4.0.0-beta.26 → 4.0.0-beta.27
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 +6 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/00-ai-gateway.mdx +52 -30
- package/package.json +1 -1
- package/src/gateway-provider-options.ts +6 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -549,6 +549,7 @@ declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
549
549
|
models?: string[] | undefined;
|
|
550
550
|
byok?: Record<string, Record<string, unknown>[]> | undefined;
|
|
551
551
|
zeroDataRetention?: boolean | undefined;
|
|
552
|
+
disallowPromptTraining?: boolean | undefined;
|
|
552
553
|
providerTimeouts?: {
|
|
553
554
|
byok?: Record<string, number> | undefined;
|
|
554
555
|
} | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -549,6 +549,7 @@ declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
549
549
|
models?: string[] | undefined;
|
|
550
550
|
byok?: Record<string, Record<string, unknown>[]> | undefined;
|
|
551
551
|
zeroDataRetention?: boolean | undefined;
|
|
552
|
+
disallowPromptTraining?: boolean | undefined;
|
|
552
553
|
providerTimeouts?: {
|
|
553
554
|
byok?: Record<string, number> | undefined;
|
|
554
555
|
} | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1525,7 +1525,7 @@ async function getVercelRequestId() {
|
|
|
1525
1525
|
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
1526
1526
|
|
|
1527
1527
|
// src/version.ts
|
|
1528
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1528
|
+
var VERSION = true ? "4.0.0-beta.27" : "0.0.0-test";
|
|
1529
1529
|
|
|
1530
1530
|
// src/gateway-provider.ts
|
|
1531
1531
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
package/dist/index.mjs
CHANGED
|
@@ -1559,7 +1559,7 @@ async function getVercelRequestId() {
|
|
|
1559
1559
|
import { withUserAgentSuffix } from "@ai-sdk/provider-utils";
|
|
1560
1560
|
|
|
1561
1561
|
// src/version.ts
|
|
1562
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1562
|
+
var VERSION = true ? "4.0.0-beta.27" : "0.0.0-test";
|
|
1563
1563
|
|
|
1564
1564
|
// src/gateway-provider.ts
|
|
1565
1565
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
package/docs/00-ai-gateway.mdx
CHANGED
|
@@ -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',
|
|
32
|
+
model: 'openai/gpt-5.4',
|
|
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'),
|
|
42
|
+
model: gateway('openai/gpt-5.4'),
|
|
43
43
|
prompt: 'Hello world',
|
|
44
44
|
});
|
|
45
45
|
```
|
|
@@ -169,7 +169,7 @@ You can create language models using a provider instance. The first argument is
|
|
|
169
169
|
import { generateText } from 'ai';
|
|
170
170
|
|
|
171
171
|
const { text } = await generateText({
|
|
172
|
-
model: 'openai/gpt-5',
|
|
172
|
+
model: 'openai/gpt-5.4',
|
|
173
173
|
prompt: 'Explain quantum computing in simple terms',
|
|
174
174
|
});
|
|
175
175
|
```
|
|
@@ -215,7 +215,7 @@ availableModels.models.forEach(model => {
|
|
|
215
215
|
|
|
216
216
|
// Use any discovered model with plain string
|
|
217
217
|
const { text } = await generateText({
|
|
218
|
-
model: availableModels.models[0].id, // e.g., 'openai/gpt-
|
|
218
|
+
model: availableModels.models[0].id, // e.g., 'openai/gpt-5.4'
|
|
219
219
|
prompt: 'Hello world',
|
|
220
220
|
});
|
|
221
221
|
```
|
|
@@ -326,7 +326,7 @@ It returns a `GatewayGenerationInfo` object with the following fields:
|
|
|
326
326
|
import { generateText } from 'ai';
|
|
327
327
|
|
|
328
328
|
const { text } = await generateText({
|
|
329
|
-
model: 'anthropic/claude-sonnet-4',
|
|
329
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
330
330
|
prompt: 'Write a haiku about programming',
|
|
331
331
|
});
|
|
332
332
|
|
|
@@ -339,7 +339,7 @@ console.log(text);
|
|
|
339
339
|
import { streamText } from 'ai';
|
|
340
340
|
|
|
341
341
|
const { textStream } = await streamText({
|
|
342
|
-
model: 'openai/gpt-5',
|
|
342
|
+
model: 'openai/gpt-5.4',
|
|
343
343
|
prompt: 'Explain the benefits of serverless architecture',
|
|
344
344
|
});
|
|
345
345
|
|
|
@@ -377,13 +377,13 @@ const { text } = await generateText({
|
|
|
377
377
|
Some providers offer tools that are executed by the provider itself, such as [OpenAI's web search tool](/providers/ai-sdk-providers/openai#web-search-tool). To use these tools through AI Gateway, import the provider to access the tool definitions:
|
|
378
378
|
|
|
379
379
|
```ts
|
|
380
|
-
import { generateText,
|
|
380
|
+
import { generateText, isStepCount } from 'ai';
|
|
381
381
|
import { openai } from '@ai-sdk/openai';
|
|
382
382
|
|
|
383
383
|
const result = await generateText({
|
|
384
|
-
model: 'openai/gpt-5-mini',
|
|
384
|
+
model: 'openai/gpt-5.4-mini',
|
|
385
385
|
prompt: 'What is the Vercel AI Gateway?',
|
|
386
|
-
stopWhen:
|
|
386
|
+
stopWhen: isStepCount(10),
|
|
387
387
|
tools: {
|
|
388
388
|
web_search: openai.tools.webSearch({}),
|
|
389
389
|
},
|
|
@@ -410,7 +410,7 @@ The Perplexity Search tool enables models to search the web using [Perplexity's
|
|
|
410
410
|
import { gateway, generateText } from 'ai';
|
|
411
411
|
|
|
412
412
|
const result = await generateText({
|
|
413
|
-
model: 'openai/gpt-5-nano',
|
|
413
|
+
model: 'openai/gpt-5.4-nano',
|
|
414
414
|
prompt: 'Search for news about AI regulations in January 2025.',
|
|
415
415
|
tools: {
|
|
416
416
|
perplexity_search: gateway.tools.perplexitySearch(),
|
|
@@ -428,7 +428,7 @@ You can also configure the search with optional parameters:
|
|
|
428
428
|
import { gateway, generateText } from 'ai';
|
|
429
429
|
|
|
430
430
|
const result = await generateText({
|
|
431
|
-
model: 'openai/gpt-5-nano',
|
|
431
|
+
model: 'openai/gpt-5.4-nano',
|
|
432
432
|
prompt:
|
|
433
433
|
'Search for news about AI regulations from the first week of January 2025.',
|
|
434
434
|
tools: {
|
|
@@ -482,7 +482,7 @@ The tool works with both `generateText` and `streamText`:
|
|
|
482
482
|
import { gateway, streamText } from 'ai';
|
|
483
483
|
|
|
484
484
|
const result = streamText({
|
|
485
|
-
model: 'openai/gpt-5-nano',
|
|
485
|
+
model: 'openai/gpt-5.4-nano',
|
|
486
486
|
prompt: 'Search for the latest news about AI regulations.',
|
|
487
487
|
tools: {
|
|
488
488
|
perplexity_search: gateway.tools.perplexitySearch(),
|
|
@@ -512,7 +512,7 @@ The Parallel Search tool enables models to search the web using [Parallel AI's S
|
|
|
512
512
|
import { gateway, generateText } from 'ai';
|
|
513
513
|
|
|
514
514
|
const result = await generateText({
|
|
515
|
-
model: 'openai/gpt-5-nano',
|
|
515
|
+
model: 'openai/gpt-5.4-nano',
|
|
516
516
|
prompt: 'Research the latest developments in quantum computing.',
|
|
517
517
|
tools: {
|
|
518
518
|
parallel_search: gateway.tools.parallelSearch(),
|
|
@@ -530,7 +530,7 @@ You can also configure the search with optional parameters:
|
|
|
530
530
|
import { gateway, generateText } from 'ai';
|
|
531
531
|
|
|
532
532
|
const result = await generateText({
|
|
533
|
-
model: 'openai/gpt-5-nano',
|
|
533
|
+
model: 'openai/gpt-5.4-nano',
|
|
534
534
|
prompt: 'Find detailed information about TypeScript 5.0 features.',
|
|
535
535
|
tools: {
|
|
536
536
|
parallel_search: gateway.tools.parallelSearch({
|
|
@@ -591,7 +591,7 @@ The tool works with both `generateText` and `streamText`:
|
|
|
591
591
|
import { gateway, streamText } from 'ai';
|
|
592
592
|
|
|
593
593
|
const result = streamText({
|
|
594
|
-
model: 'openai/gpt-5-nano',
|
|
594
|
+
model: 'openai/gpt-5.4-nano',
|
|
595
595
|
prompt: 'Research the latest AI safety guidelines.',
|
|
596
596
|
tools: {
|
|
597
597
|
parallel_search: gateway.tools.parallelSearch(),
|
|
@@ -624,7 +624,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
|
624
624
|
import { generateText } from 'ai';
|
|
625
625
|
|
|
626
626
|
const { text } = await generateText({
|
|
627
|
-
model: 'openai/gpt-5',
|
|
627
|
+
model: 'openai/gpt-5.4',
|
|
628
628
|
prompt: 'Summarize this document...',
|
|
629
629
|
providerOptions: {
|
|
630
630
|
gateway: {
|
|
@@ -725,7 +725,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
|
725
725
|
import { generateText } from 'ai';
|
|
726
726
|
|
|
727
727
|
const { text } = await generateText({
|
|
728
|
-
model: 'anthropic/claude-sonnet-4',
|
|
728
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
729
729
|
prompt: 'Explain quantum computing',
|
|
730
730
|
providerOptions: {
|
|
731
731
|
gateway: {
|
|
@@ -754,7 +754,7 @@ The following gateway provider options are available:
|
|
|
754
754
|
|
|
755
755
|
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.
|
|
756
756
|
|
|
757
|
-
Example: `models: ['openai/gpt-5-nano', 'gemini-
|
|
757
|
+
Example: `models: ['openai/gpt-5.4-nano', 'gemini-3-flash-preview']` will try the fallback models in order if the primary model fails.
|
|
758
758
|
|
|
759
759
|
- **user** _string_
|
|
760
760
|
|
|
@@ -782,7 +782,12 @@ The following gateway provider options are available:
|
|
|
782
782
|
|
|
783
783
|
- **zeroDataRetention** _boolean_
|
|
784
784
|
|
|
785
|
-
Restricts routing requests to providers that have zero data retention
|
|
785
|
+
Restricts routing requests to providers that have zero data retention agreements with Vercel for AI Gateway. If there are no providers available for the model with zero data retention, the request will fail. BYOK credentials are skipped when `zeroDataRetention` is set to `true` to ensure that requests are only routed to providers that support ZDR compliance. Request-level ZDR is only available for Vercel Pro and Enterprise plans.
|
|
786
|
+
|
|
787
|
+
- **disallowPromptTraining** _boolean_
|
|
788
|
+
|
|
789
|
+
Restricts routing requests to providers that have agreements with Vercel for AI Gateway to not use prompts for model training. If there are no providers available for the model that disallow prompt training, the request will fail. BYOK credentials are skipped when `disallowPromptTraining` is set to `true` to ensure that requests are only routed to providers that do not train on prompt data.
|
|
790
|
+
|
|
786
791
|
|
|
787
792
|
- **providerTimeouts** _object_
|
|
788
793
|
|
|
@@ -799,7 +804,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
|
799
804
|
import { generateText } from 'ai';
|
|
800
805
|
|
|
801
806
|
const { text } = await generateText({
|
|
802
|
-
model: 'anthropic/claude-sonnet-4',
|
|
807
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
803
808
|
prompt: 'Write a haiku about programming',
|
|
804
809
|
providerOptions: {
|
|
805
810
|
gateway: {
|
|
@@ -819,34 +824,32 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
|
819
824
|
import { generateText } from 'ai';
|
|
820
825
|
|
|
821
826
|
const { text } = await generateText({
|
|
822
|
-
model: 'openai/gpt-
|
|
827
|
+
model: 'openai/gpt-5.4', // Primary model
|
|
823
828
|
prompt: 'Write a TypeScript haiku',
|
|
824
829
|
providerOptions: {
|
|
825
830
|
gateway: {
|
|
826
|
-
models: ['openai/gpt-5-nano', 'gemini-
|
|
831
|
+
models: ['openai/gpt-5.4-nano', 'gemini-3-flash-preview'], // Fallback models
|
|
827
832
|
} satisfies GatewayProviderOptions,
|
|
828
833
|
},
|
|
829
834
|
});
|
|
830
835
|
|
|
831
836
|
// This will:
|
|
832
|
-
// 1. Try openai/gpt-
|
|
833
|
-
// 2. If it fails, try openai/gpt-5-nano
|
|
834
|
-
// 3. If that fails, try gemini-
|
|
837
|
+
// 1. Try openai/gpt-5.4 first
|
|
838
|
+
// 2. If it fails, try openai/gpt-5.4-nano
|
|
839
|
+
// 3. If that fails, try gemini-3-flash-preview
|
|
835
840
|
// 4. Return the result from the first model that succeeds
|
|
836
841
|
```
|
|
837
842
|
|
|
838
843
|
#### Zero Data Retention Example
|
|
839
844
|
|
|
840
|
-
Set `zeroDataRetention` to true to ensure requests are only routed to providers
|
|
841
|
-
that have zero data retention policies. When `zeroDataRetention` is `false` or not
|
|
842
|
-
specified, there is no enforcement of restricting routing.
|
|
845
|
+
Set `zeroDataRetention` to true to route requests to providers that have zero data retention agreements with Vercel for AI Gateway. If there are no providers available for the model with zero data retention, the request will fail. When `zeroDataRetention` is `false` or not specified, there is no enforcement of restricting routing. BYOK credentials are skipped when `zeroDataRetention` is set to `true` to ensure that requests are only routed to providers that support ZDR compliance. Request-level ZDR is only available for Vercel Pro and Enterprise plans.
|
|
843
846
|
|
|
844
847
|
```ts
|
|
845
848
|
import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
846
849
|
import { generateText } from 'ai';
|
|
847
850
|
|
|
848
851
|
const { text } = await generateText({
|
|
849
|
-
model: 'anthropic/claude-sonnet-4.
|
|
852
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
850
853
|
prompt: 'Analyze this sensitive document...',
|
|
851
854
|
providerOptions: {
|
|
852
855
|
gateway: {
|
|
@@ -856,6 +859,25 @@ const { text } = await generateText({
|
|
|
856
859
|
});
|
|
857
860
|
```
|
|
858
861
|
|
|
862
|
+
#### Disallow Prompt Training Example
|
|
863
|
+
|
|
864
|
+
Set `disallowPromptTraining` to true to route requests to providers that have agreements with Vercel for AI Gateway to not use prompts for model training. If there are no providers available for the model that disallow prompt training, the request will fail. When `disallowPromptTraining` is `false` or not specified, there is no enforcement of restricting routing. BYOK credentials are skipped when `disallowPromptTraining` is set to `true` to ensure that requests are only routed to providers that do not train on prompt data.
|
|
865
|
+
|
|
866
|
+
```ts
|
|
867
|
+
import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
868
|
+
import { generateText } from 'ai';
|
|
869
|
+
|
|
870
|
+
const { text } = await generateText({
|
|
871
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
872
|
+
prompt: 'Analyze this proprietary business data...',
|
|
873
|
+
providerOptions: {
|
|
874
|
+
gateway: {
|
|
875
|
+
disallowPromptTraining: true,
|
|
876
|
+
} satisfies GatewayProviderOptions,
|
|
877
|
+
},
|
|
878
|
+
});
|
|
879
|
+
```
|
|
880
|
+
|
|
859
881
|
### Provider-Specific Options
|
|
860
882
|
|
|
861
883
|
When using provider-specific options through AI Gateway, use the actual provider name (e.g. `anthropic`, `openai`, not `gateway`) as the key:
|
|
@@ -866,7 +888,7 @@ import type { GatewayProviderOptions } from '@ai-sdk/gateway';
|
|
|
866
888
|
import { generateText } from 'ai';
|
|
867
889
|
|
|
868
890
|
const { text } = await generateText({
|
|
869
|
-
model: 'anthropic/claude-sonnet-4',
|
|
891
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
870
892
|
prompt: 'Explain quantum computing',
|
|
871
893
|
providerOptions: {
|
|
872
894
|
gateway: {
|
package/package.json
CHANGED
|
@@ -59,6 +59,12 @@ const gatewayProviderOptions = lazySchema(() =>
|
|
|
59
59
|
* used.
|
|
60
60
|
*/
|
|
61
61
|
zeroDataRetention: z.boolean().optional(),
|
|
62
|
+
/**
|
|
63
|
+
* Whether to filter by only providers that do not train on prompt data.
|
|
64
|
+
* When enabled, only providers that have agreements with Vercel AI Gateway
|
|
65
|
+
* to not use prompts for model training will be used.
|
|
66
|
+
*/
|
|
67
|
+
disallowPromptTraining: z.boolean().optional(),
|
|
62
68
|
/**
|
|
63
69
|
* Per-provider timeouts for BYOK credentials in milliseconds.
|
|
64
70
|
* Controls how long to wait for a provider to start responding
|