Skip to content

Commit 4bbb1f6

Browse files
nicoalbaneseclaude
andauthored
skill: add gateway instructions (#11995)
Agents often mistake how to use AI Gateway. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 52fc8fb commit 4bbb1f6

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

skills/use-ai-sdk/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Use these resources for current API details, examples, and usage patterns.
3636

3737
For common errors and troubleshooting, see [Common Errors Reference](references/common-errors.md).
3838

39+
For using Vercel AI Gateway, see [AI Gateway Reference](references/ai-gateway.md).
40+
3941
## Provider-Specific Information (ai@6.0.34+)
4042

4143
For questions about specific providers (OpenAI, Anthropic, Google, etc.), search their dedicated packages:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Vercel AI Gateway
3+
description: Reference for using Vercel AI Gateway with the AI SDK.
4+
---
5+
6+
# Vercel AI Gateway
7+
8+
The Vercel AI Gateway is the fastest way to get started with the AI SDK. It provides access to models from OpenAI, Anthropic, Google, and other providers through a single API.
9+
10+
## Authentication
11+
12+
Authenticate with OIDC (for Vercel deployments) or an [AI Gateway API key](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Fapi-keys&title=AI+Gateway+API+Keys):
13+
14+
```env filename=".env.local"
15+
AI_GATEWAY_API_KEY=your_api_key_here
16+
```
17+
18+
## Usage
19+
20+
The AI Gateway is the default global provider, so you can access models using a simple string:
21+
22+
```ts
23+
import { generateText } from 'ai';
24+
25+
const { text } = await generateText({
26+
model: 'anthropic/claude-sonnet-4.5',
27+
prompt: 'What is love?',
28+
});
29+
```
30+
31+
You can also explicitly import and use the gateway provider:
32+
33+
```ts
34+
// Option 1: Import from 'ai' package (included by default)
35+
import { gateway } from 'ai';
36+
model: gateway('anthropic/claude-sonnet-4.5');
37+
38+
// Option 2: Install and import from '@ai-sdk/gateway' package
39+
import { gateway } from '@ai-sdk/gateway';
40+
model: gateway('anthropic/claude-sonnet-4.5');
41+
```

0 commit comments

Comments
 (0)