Skip to content

Commit 95e3f35

Browse files
authored
chore: update readme (#10015)
Use gateway in readme
1 parent 9eab6a3 commit 95e3f35

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

packages/ai/README.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# AI SDK
44

5-
The [AI SDK](https://ai-sdk.dev/docs) is a TypeScript toolkit designed to help you build AI-powered applications using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
5+
The [AI SDK](https://ai-sdk.dev/docs) is a TypeScript toolkit designed to help you build AI-powered applications and agents using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
66

77
To learn more about how to use the AI SDK, check out our [API Reference](https://ai-sdk.dev/docs/reference) and [Documentation](https://ai-sdk.dev/docs).
88

@@ -14,38 +14,63 @@ You will need Node.js 18+ and npm (or another package manager) installed on your
1414
npm install ai
1515
```
1616

17-
## Usage
18-
19-
### AI SDK Core
20-
21-
The [AI SDK Core](https://ai-sdk.dev/docs/ai-sdk-core/overview) module provides a unified API to interact with model providers like [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai), [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic), [Google](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai), and more.
17+
## Unified Provider Architecture
2218

23-
You will then install the model provider of your choice.
19+
The AI SDK provides a [unified API](https://ai-sdk.dev/docs/foundations/providers-and-models) to interact with model providers like [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai), [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic), [Google](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai), and [more](https://ai-sdk.dev/providers/ai-sdk-providers).
2420

2521
```shell
26-
npm install @ai-sdk/openai
22+
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
2723
```
2824

29-
###### @/index.ts (Node.js Runtime)
25+
Alternatively you can use the [Vercel AI Gateway](https://vercel.com/docs/ai-gateway).
26+
27+
## Usage
28+
29+
### Generating Text
30+
31+
```ts
32+
import { generateText } from 'ai';
33+
34+
const { text } = await generateText({
35+
model: 'openai/gpt-5', // use Vercel AI Gateway
36+
prompt: 'What is an agent?',
37+
});
38+
```
3039

3140
```ts
3241
import { generateText } from 'ai';
33-
import { openai } from '@ai-sdk/openai'; // Ensure OPENAI_API_KEY environment variable is set
42+
import { openai } from '@ai-sdk/openai';
3443

3544
const { text } = await generateText({
36-
model: openai('gpt-4o'),
37-
system: 'You are a friendly assistant!',
38-
prompt: 'Why is the sky blue?',
45+
model: openai('gpt-5'), // use OpenAI Responses API directly
46+
prompt: 'What is an agent?',
3947
});
48+
```
49+
50+
### Generating Structured Data
4051

41-
console.log(text);
52+
```ts
53+
import { generateObject } from 'ai';
54+
import { z } from 'zod';
55+
56+
const { object } = await generateObject({
57+
model: 'openai/gpt-5',
58+
schema: z.object({
59+
recipe: z.object({
60+
name: z.string(),
61+
ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
62+
steps: z.array(z.string()),
63+
}),
64+
}),
65+
prompt: 'Generate a lasagna recipe.',
66+
});
4267
```
4368

44-
### AI SDK UI
69+
### UI Integration
4570

4671
The [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, and Vue.
4772

48-
You need to install the package for your framework:
73+
You need to install the package for your framework, e.g.:
4974

5075
```shell
5176
npm install @ai-sdk/react

0 commit comments

Comments
 (0)