Skip to content

Commit 8edfb1b

Browse files
Backport: docs: update docs to use gateway pattern (#9684)
This is an automated backport of #9591 to the release-v5.0 branch. Co-authored-by: josh <144584931+dancer@users.noreply.github.com>
1 parent 16ac29e commit 8edfb1b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

content/docs/02-foundations/05-streaming.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ While streaming interfaces can greatly enhance user experiences, especially with
4646
However, regardless of the speed of your model, the AI SDK is designed to make implementing streaming UIs as simple as possible. In the example below, we stream text generation from OpenAI's `gpt-4.1` in under 10 lines of code using the SDK's [`streamText`](/docs/reference/ai-sdk-core/stream-text) function:
4747

4848
```ts
49-
import { openai } from '@ai-sdk/openai';
5049
import { streamText } from 'ai';
5150

5251
const { textStream } = streamText({
53-
model: openai('gpt-4.1'),
52+
model: 'openai/gpt-4.1',
5453
prompt: 'Write a poem about embedding models.',
5554
});
5655

content/docs/03-ai-sdk-core/10-generating-structured-data.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,11 @@ When you use the `array` output strategy, the schema specifies the shape of an a
124124
With `streamObject`, you can also stream the generated array elements using `elementStream`.
125125

126126
```ts highlight="7,18"
127-
import { openai } from '@ai-sdk/openai';
128127
import { streamObject } from 'ai';
129128
import { z } from 'zod';
130129

131130
const { elementStream } = streamObject({
132-
model: openai('gpt-4.1'),
131+
model: 'openai/gpt-4.1',
133132
output: 'array',
134133
schema: z.object({
135134
name: z.string(),
@@ -176,11 +175,10 @@ You can use the `output` setting to set the output format to `no-schema` in thos
176175
and omit the schema parameter.
177176

178177
```ts highlight="6"
179-
import { openai } from '@ai-sdk/openai';
180178
import { generateObject } from 'ai';
181179

182180
const { object } = await generateObject({
183-
model: openai('gpt-4.1'),
181+
model: 'openai/gpt-4.1',
184182
output: 'no-schema',
185183
prompt: 'Generate a lasagna recipe.',
186184
});
@@ -212,12 +210,12 @@ const { object } = await generateObject({
212210
You can access the reasoning used by the language model to generate the object via the `reasoning` property on the result. This property contains a string with the model's thought process, if available.
213211

214212
```ts
215-
import { openai, OpenAIResponsesProviderOptions } from '@ai-sdk/openai';
213+
import { OpenAIResponsesProviderOptions } from '@ai-sdk/openai';
216214
import { generateObject } from 'ai';
217215
import { z } from 'zod';
218216

219217
const result = await generateObject({
220-
model: openai('gpt-5'),
218+
model: 'openai/gpt-5',
221219
schema: z.object({
222220
recipe: z.object({
223221
name: z.string(),

0 commit comments

Comments
 (0)