@@ -18,23 +18,7 @@ The [AI Gateway](https://vercel.com/docs/ai-gateway) provider connects you to mo
18
18
19
19
## Setup
20
20
21
- The AI Gateway provider is available in the ` @ai-sdk/gateway ` module. You can install it with
22
-
23
- <Tabs items = { [' pnpm' , ' npm' , ' yarn' , ' bun' ]} >
24
- <Tab >
25
- <Snippet text = " pnpm add @ai-sdk/gateway" dark />
26
- </Tab >
27
- <Tab >
28
- <Snippet text = " npm install @ai-sdk/gateway" dark />
29
- </Tab >
30
- <Tab >
31
- <Snippet text = " yarn add @ai-sdk/gateway" dark />
32
- </Tab >
33
-
34
- <Tab >
35
- <Snippet text = " bun add @ai-sdk/gateway" dark />
36
- </Tab >
37
- </Tabs >
21
+ The Vercel AI Gateway provider is part of the AI SDK.
38
22
39
23
## Basic Usage
40
24
@@ -52,8 +36,7 @@ const { text } = await generateText({
52
36
53
37
``` ts
54
38
// use provider instance
55
- import { generateText } from ' ai' ;
56
- import { gateway } from ' @ai-sdk/gateway' ;
39
+ import { generateText , gateway } from ' ai' ;
57
40
58
41
const { text } = await generateText ({
59
42
model: gateway (' openai/gpt-5' ),
@@ -65,10 +48,10 @@ The AI SDK automatically uses the AI Gateway when you pass a model string in the
65
48
66
49
## Provider Instance
67
50
68
- You can also import the default provider instance ` gateway ` from ` @ai-sdk/gateway ` :
51
+ You can also import the default provider instance ` gateway ` from ` ai ` :
69
52
70
53
``` ts
71
- import { gateway } from ' @ai-sdk/gateway ' ;
54
+ import { gateway } from ' ai ' ;
72
55
```
73
56
74
57
You may want to create a custom provider instance when you need to:
@@ -78,10 +61,10 @@ You may want to create a custom provider instance when you need to:
78
61
- Wrap the provider with [ middleware] ( /docs/ai-sdk-core/middleware )
79
62
- Use different settings for different parts of your application
80
63
81
- To create a custom provider instance, import ` createGateway ` from ` @ai-sdk/gateway ` :
64
+ To create a custom provider instance, import ` createGateway ` from ` ai ` :
82
65
83
66
``` ts
84
- import { createGateway } from ' @ai-sdk/gateway ' ;
67
+ import { createGateway } from ' ai ' ;
85
68
86
69
const gateway = createGateway ({
87
70
apiKey: process .env .AI_GATEWAY_API_KEY ?? ' ' ,
@@ -129,7 +112,7 @@ AI_GATEWAY_API_KEY=your_api_key_here
129
112
Or pass it directly to the provider:
130
113
131
114
``` ts
132
- import { createGateway } from ' @ai-sdk/gateway ' ;
115
+ import { createGateway } from ' ai ' ;
133
116
134
117
const gateway = createGateway ({
135
118
apiKey: ' your_api_key_here' ,
@@ -191,8 +174,7 @@ For the complete list of available models, see the [AI Gateway documentation](ht
191
174
You can discover available models programmatically:
192
175
193
176
``` ts
194
- import { gateway } from ' @ai-sdk/gateway' ;
195
- import { generateText } from ' ai' ;
177
+ import { gateway , generateText } from ' ai' ;
196
178
197
179
const availableModels = await gateway .getAvailableModels ();
198
180
@@ -300,8 +282,7 @@ const { text } = await generateText({
300
282
301
283
``` ts
302
284
// with provider instance
303
- import { generateText } from ' ai' ;
304
- import { gateway } from ' @ai-sdk/gateway' ;
285
+ import { gateway , generateText } from ' ai' ;
305
286
306
287
const { text } = await generateText ({
307
288
model: gateway (' anthropic/claude-sonnet-4' ),
0 commit comments