ai 7.0.113 → 7.0.114
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 +9 -0
- package/README.md +6 -6
- package/dist/index.js +64 -44
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +78 -51
- package/dist/internal/index.js.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +3 -0
- package/docs/02-foundations/03-prompts.mdx +1 -1
- package/docs/02-foundations/04-tools.mdx +2 -2
- package/docs/02-foundations/06-provider-options.mdx +11 -11
- package/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
- package/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
- package/docs/02-getting-started/03-nextjs-pages-router.mdx +3 -3
- package/docs/02-getting-started/04-svelte.mdx +7 -7
- package/docs/02-getting-started/05-nuxt.mdx +7 -7
- package/docs/02-getting-started/06-nodejs.mdx +3 -3
- package/docs/02-getting-started/07-expo.mdx +3 -3
- package/docs/02-getting-started/08-tanstack-start.mdx +3 -3
- package/docs/02-getting-started/09-coding-agents.mdx +1 -1
- package/docs/03-agents/03-workflows.mdx +2 -2
- package/docs/03-agents/04-loop-control.mdx +1 -1
- package/docs/03-agents/05-configuring-call-options.mdx +4 -2
- package/docs/03-agents/06-memory.mdx +2 -2
- package/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
- package/docs/03-agents/07-workflow-agent.mdx +11 -11
- package/docs/03-agents/08-terminal-ui.mdx +2 -2
- package/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
- package/docs/03-ai-sdk-core/17-mcp-apps.mdx +1 -1
- package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
- package/docs/03-ai-sdk-core/26-reasoning.mdx +13 -12
- package/docs/03-ai-sdk-core/31-reranking.mdx +12 -10
- package/docs/03-ai-sdk-core/32-evaluation.mdx +1 -1
- package/docs/03-ai-sdk-core/35-image-generation.mdx +2 -2
- package/docs/03-ai-sdk-core/37-speech.mdx +6 -6
- package/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
- package/docs/03-ai-sdk-core/41-skill-uploads.mdx +1 -1
- package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
- package/docs/03-ai-sdk-core/45-provider-management.mdx +21 -21
- package/docs/03-ai-sdk-core/60-telemetry.mdx +1 -1
- package/docs/03-ai-sdk-core/65-devtools.mdx +3 -3
- package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +1 -1
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +3 -3
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +3 -3
- package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +1 -1
- package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +5 -5
- package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
- package/docs/05-ai-sdk-rsc/06-loading-state.mdx +1 -1
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +3 -3
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +5 -3
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -3
- package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +5 -5
- package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +4 -2
- package/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +3 -3
- package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +1 -1
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
- package/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +1 -1
- package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +3 -3
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
- package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +1 -1
- package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
- package/package.json +6 -6
- package/src/evaluate/evaluate.ts +1 -10
- package/src/generate-text/restricted-telemetry-dispatcher.ts +6 -58
- package/src/prompt/standardize-prompt.ts +2 -0
- package/src/telemetry/create-telemetry-dispatcher.ts +58 -6
- package/src/telemetry/filter-included-context.ts +57 -2
|
@@ -13,7 +13,7 @@ Many language models support an internal "reasoning" phase (sometimes also calle
|
|
|
13
13
|
import { generateText } from 'ai';
|
|
14
14
|
|
|
15
15
|
const { text, reasoning, reasoningText } = await generateText({
|
|
16
|
-
model: 'anthropic/claude-sonnet-
|
|
16
|
+
model: 'anthropic/claude-sonnet-5',
|
|
17
17
|
reasoning: 'medium',
|
|
18
18
|
prompt: 'How many people will live in the world in 2040?',
|
|
19
19
|
});
|
|
@@ -39,7 +39,7 @@ The `reasoning` parameter works the same way with `streamText`:
|
|
|
39
39
|
import { streamText } from 'ai';
|
|
40
40
|
|
|
41
41
|
const result = streamText({
|
|
42
|
-
model: 'google/gemini-3-flash
|
|
42
|
+
model: 'google/gemini-3.8-flash',
|
|
43
43
|
reasoning: 'high',
|
|
44
44
|
prompt: 'Explain the Riemann hypothesis in simple terms.',
|
|
45
45
|
});
|
|
@@ -62,7 +62,7 @@ import { generateText } from 'ai';
|
|
|
62
62
|
import { openai } from '@ai-sdk/openai';
|
|
63
63
|
|
|
64
64
|
const { text } = await generateText({
|
|
65
|
-
model: openai.responses('gpt-
|
|
65
|
+
model: openai.responses('gpt-6-astra'),
|
|
66
66
|
reasoning: 'low', // ignored because providerOptions.openai.reasoningEffort is set
|
|
67
67
|
providerOptions: {
|
|
68
68
|
openai: {
|
|
@@ -89,10 +89,11 @@ If you currently control reasoning via `providerOptions`, you can migrate to the
|
|
|
89
89
|
|
|
90
90
|
```ts
|
|
91
91
|
const { text } = await generateText({
|
|
92
|
-
model: anthropic('claude-opus-
|
|
92
|
+
model: anthropic('claude-opus-5-5'),
|
|
93
93
|
providerOptions: {
|
|
94
94
|
anthropic: {
|
|
95
|
-
thinking: { type: 'adaptive'
|
|
95
|
+
thinking: { type: 'adaptive' },
|
|
96
|
+
effort: 'high',
|
|
96
97
|
},
|
|
97
98
|
},
|
|
98
99
|
prompt: 'How many people will live in the world in 2040?',
|
|
@@ -103,7 +104,7 @@ const { text } = await generateText({
|
|
|
103
104
|
|
|
104
105
|
```ts
|
|
105
106
|
const { text } = await generateText({
|
|
106
|
-
model: anthropic('claude-opus-
|
|
107
|
+
model: anthropic('claude-opus-5-5'),
|
|
107
108
|
reasoning: 'high',
|
|
108
109
|
prompt: 'How many people will live in the world in 2040?',
|
|
109
110
|
});
|
|
@@ -139,10 +140,10 @@ If you need to enforce an exact token budget (e.g. exactly 12000 tokens), keep u
|
|
|
139
140
|
|
|
140
141
|
```ts
|
|
141
142
|
const { text } = await generateText({
|
|
142
|
-
model: google('gemini-3-flash
|
|
143
|
+
model: google('gemini-3.8-flash'),
|
|
143
144
|
providerOptions: {
|
|
144
145
|
google: {
|
|
145
|
-
thinkingConfig: {
|
|
146
|
+
thinkingConfig: { thinkingLevel: 'high', includeThoughts: true },
|
|
146
147
|
},
|
|
147
148
|
},
|
|
148
149
|
prompt: 'Explain the Riemann hypothesis in simple terms.',
|
|
@@ -153,8 +154,8 @@ const { text } = await generateText({
|
|
|
153
154
|
|
|
154
155
|
```ts
|
|
155
156
|
const { text } = await generateText({
|
|
156
|
-
model: google('gemini-3-flash
|
|
157
|
-
reasoning: '
|
|
157
|
+
model: google('gemini-3.8-flash'),
|
|
158
|
+
reasoning: 'high',
|
|
158
159
|
providerOptions: {
|
|
159
160
|
google: { thinkingConfig: { includeThoughts: true } },
|
|
160
161
|
},
|
|
@@ -166,7 +167,7 @@ const { text } = await generateText({
|
|
|
166
167
|
|
|
167
168
|
```ts
|
|
168
169
|
const { text } = await generateText({
|
|
169
|
-
model: openai.responses('
|
|
170
|
+
model: openai.responses('gpt-6-astra'),
|
|
170
171
|
providerOptions: {
|
|
171
172
|
openai: { reasoningEffort: 'high', reasoningSummary: 'auto' },
|
|
172
173
|
},
|
|
@@ -178,7 +179,7 @@ const { text } = await generateText({
|
|
|
178
179
|
|
|
179
180
|
```ts
|
|
180
181
|
const { text } = await generateText({
|
|
181
|
-
model: openai.responses('
|
|
182
|
+
model: openai.responses('gpt-6-astra'),
|
|
182
183
|
reasoning: 'high',
|
|
183
184
|
providerOptions: {
|
|
184
185
|
openai: { reasoningSummary: 'auto' },
|
|
@@ -12,7 +12,7 @@ often producing more accurate relevance scores.
|
|
|
12
12
|
## Reranking Documents
|
|
13
13
|
|
|
14
14
|
The AI SDK provides the [`rerank`](/docs/reference/ai-sdk-core/rerank) function to rerank documents based on their relevance to a query.
|
|
15
|
-
You can use it with reranking models, e.g. `cohere.reranking('rerank-
|
|
15
|
+
You can use it with reranking models, e.g. `cohere.reranking('rerank-v4.0-pro')` or `bedrock.reranking('cohere.rerank-v3-5:0')`.
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { rerank } from 'ai';
|
|
@@ -25,7 +25,7 @@ const documents = [
|
|
|
25
25
|
];
|
|
26
26
|
|
|
27
27
|
const { ranking } = await rerank({
|
|
28
|
-
model: cohere.reranking('rerank-
|
|
28
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
29
29
|
documents,
|
|
30
30
|
query: 'talk about rain',
|
|
31
31
|
topN: 2, // Return top 2 most relevant documents
|
|
@@ -60,7 +60,7 @@ const documents = [
|
|
|
60
60
|
];
|
|
61
61
|
|
|
62
62
|
const { ranking, rerankedDocuments } = await rerank({
|
|
63
|
-
model: cohere.reranking('rerank-
|
|
63
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
64
64
|
documents,
|
|
65
65
|
query: 'Which pricing did we get from Oracle?',
|
|
66
66
|
topN: 1,
|
|
@@ -79,7 +79,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
79
79
|
import { rerank } from 'ai';
|
|
80
80
|
|
|
81
81
|
const { ranking, rerankedDocuments, originalDocuments } = await rerank({
|
|
82
|
-
model: cohere.reranking('rerank-
|
|
82
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
83
83
|
documents: ['sunny day at the beach', 'rainy afternoon in the city'],
|
|
84
84
|
query: 'talk about rain',
|
|
85
85
|
});
|
|
@@ -106,7 +106,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
106
106
|
import { rerank } from 'ai';
|
|
107
107
|
|
|
108
108
|
const { ranking } = await rerank({
|
|
109
|
-
model: cohere.reranking('rerank-
|
|
109
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
110
110
|
documents: ['doc1', 'doc2', 'doc3', 'doc4', 'doc5'],
|
|
111
111
|
query: 'relevant information',
|
|
112
112
|
topN: 3, // Return only top 3 most relevant documents
|
|
@@ -122,7 +122,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
122
122
|
import { rerank } from 'ai';
|
|
123
123
|
|
|
124
124
|
const { ranking } = await rerank({
|
|
125
|
-
model: cohere.reranking('rerank-
|
|
125
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
126
126
|
documents: ['sunny day at the beach', 'rainy afternoon in the city'],
|
|
127
127
|
query: 'talk about rain',
|
|
128
128
|
providerOptions: {
|
|
@@ -144,7 +144,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
144
144
|
import { rerank } from 'ai';
|
|
145
145
|
|
|
146
146
|
const { ranking } = await rerank({
|
|
147
|
-
model: cohere.reranking('rerank-
|
|
147
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
148
148
|
documents: ['sunny day at the beach', 'rainy afternoon in the city'],
|
|
149
149
|
query: 'talk about rain',
|
|
150
150
|
maxRetries: 0, // Disable retries
|
|
@@ -162,7 +162,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
162
162
|
import { rerank } from 'ai';
|
|
163
163
|
|
|
164
164
|
const { ranking } = await rerank({
|
|
165
|
-
model: cohere.reranking('rerank-
|
|
165
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
166
166
|
documents: ['sunny day at the beach', 'rainy afternoon in the city'],
|
|
167
167
|
query: 'talk about rain',
|
|
168
168
|
abortSignal: AbortSignal.timeout(5000), // Abort after 5 seconds
|
|
@@ -179,7 +179,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
179
179
|
import { rerank } from 'ai';
|
|
180
180
|
|
|
181
181
|
const { ranking } = await rerank({
|
|
182
|
-
model: cohere.reranking('rerank-
|
|
182
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
183
183
|
documents: ['sunny day at the beach', 'rainy afternoon in the city'],
|
|
184
184
|
query: 'talk about rain',
|
|
185
185
|
headers: { 'X-Custom-Header': 'custom-value' },
|
|
@@ -195,7 +195,7 @@ import { cohere } from '@ai-sdk/cohere';
|
|
|
195
195
|
import { rerank } from 'ai';
|
|
196
196
|
|
|
197
197
|
const { ranking, response } = await rerank({
|
|
198
|
-
model: cohere.reranking('rerank-
|
|
198
|
+
model: cohere.reranking('rerank-v4.0-pro'),
|
|
199
199
|
documents: ['sunny day at the beach', 'rainy afternoon in the city'],
|
|
200
200
|
query: 'talk about rain',
|
|
201
201
|
});
|
|
@@ -209,6 +209,8 @@ Several providers offer reranking models:
|
|
|
209
209
|
|
|
210
210
|
| Provider | Model |
|
|
211
211
|
| ----------------------------------------------------------------------------- | ------------------------------------- |
|
|
212
|
+
| [Cohere](/providers/ai-sdk-providers/cohere#reranking-models) | `rerank-v4.0-pro` |
|
|
213
|
+
| [Cohere](/providers/ai-sdk-providers/cohere#reranking-models) | `rerank-v4.0-fast` |
|
|
212
214
|
| [Cohere](/providers/ai-sdk-providers/cohere#reranking-models) | `rerank-v3.5` |
|
|
213
215
|
| [Cohere](/providers/ai-sdk-providers/cohere#reranking-models) | `rerank-english-v3.0` |
|
|
214
216
|
| [Cohere](/providers/ai-sdk-providers/cohere#reranking-models) | `rerank-multilingual-v3.0` |
|
|
@@ -93,7 +93,7 @@ const registry = createProviderRegistry({
|
|
|
93
93
|
triage: customProvider({
|
|
94
94
|
evaluationModels: {
|
|
95
95
|
native: typeSafeAi.evaluationModel('jev-latest'),
|
|
96
|
-
compact: openai.evaluationModel('gpt-
|
|
96
|
+
compact: openai.evaluationModel('gpt-6-luna'),
|
|
97
97
|
},
|
|
98
98
|
fallbackProvider: typeSafeAi,
|
|
99
99
|
}),
|
|
@@ -286,7 +286,7 @@ const { image } = await generateImage({
|
|
|
286
286
|
|
|
287
287
|
## Generating Images with Language Models
|
|
288
288
|
|
|
289
|
-
Some language models such as Google `gemini-
|
|
289
|
+
Some language models such as Google `gemini-3.1-flash-image-preview` support multi-modal outputs including images.
|
|
290
290
|
With such models, you can access the generated images using the `files` property of the response.
|
|
291
291
|
|
|
292
292
|
```ts
|
|
@@ -294,7 +294,7 @@ import { google } from '@ai-sdk/google';
|
|
|
294
294
|
import { generateText } from 'ai';
|
|
295
295
|
|
|
296
296
|
const result = await generateText({
|
|
297
|
-
model: google('gemini-
|
|
297
|
+
model: google('gemini-3.1-flash-image-preview'),
|
|
298
298
|
prompt: 'Generate an image of a comic cat',
|
|
299
299
|
});
|
|
300
300
|
|
|
@@ -13,7 +13,7 @@ import { generateSpeech } from 'ai';
|
|
|
13
13
|
import { openai } from '@ai-sdk/openai';
|
|
14
14
|
|
|
15
15
|
const audio = await generateSpeech({
|
|
16
|
-
model: openai.speech('tts
|
|
16
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
17
17
|
text: 'Hello, world!',
|
|
18
18
|
voice: 'alloy',
|
|
19
19
|
});
|
|
@@ -38,7 +38,7 @@ import { generateSpeech } from 'ai';
|
|
|
38
38
|
import { openai } from '@ai-sdk/openai';
|
|
39
39
|
|
|
40
40
|
const audio = await generateSpeech({
|
|
41
|
-
model: openai.speech('tts
|
|
41
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
42
42
|
text: 'Hello, world!',
|
|
43
43
|
providerOptions: {
|
|
44
44
|
openai: {
|
|
@@ -59,7 +59,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
59
59
|
import { generateSpeech } from 'ai';
|
|
60
60
|
|
|
61
61
|
const audio = await generateSpeech({
|
|
62
|
-
model: openai.speech('tts
|
|
62
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
63
63
|
text: 'Hello, world!',
|
|
64
64
|
abortSignal: AbortSignal.timeout(1000), // Abort after 1 second
|
|
65
65
|
});
|
|
@@ -75,7 +75,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
75
75
|
import { generateSpeech } from 'ai';
|
|
76
76
|
|
|
77
77
|
const audio = await generateSpeech({
|
|
78
|
-
model: openai.speech('tts
|
|
78
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
79
79
|
text: 'Hello, world!',
|
|
80
80
|
headers: { 'X-Custom-Header': 'custom-value' },
|
|
81
81
|
});
|
|
@@ -90,7 +90,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
90
90
|
import { generateSpeech } from 'ai';
|
|
91
91
|
|
|
92
92
|
const audio = await generateSpeech({
|
|
93
|
-
model: openai.speech('tts
|
|
93
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
94
94
|
text: 'Hello, world!',
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -117,7 +117,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
117
117
|
|
|
118
118
|
try {
|
|
119
119
|
await generateSpeech({
|
|
120
|
-
model: openai.speech('tts
|
|
120
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
121
121
|
text: 'Hello, world!',
|
|
122
122
|
});
|
|
123
123
|
} catch (error) {
|
|
@@ -174,7 +174,7 @@ Pass the `providerReference` inside the `shell` tool's `environment.skills` arra
|
|
|
174
174
|
|
|
175
175
|
```ts
|
|
176
176
|
await generateText({
|
|
177
|
-
model: openai.responses('gpt-
|
|
177
|
+
model: openai.responses('gpt-6-astra'),
|
|
178
178
|
tools: {
|
|
179
179
|
shell: openai.tools.shell({
|
|
180
180
|
environment: {
|
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
export const openai = customProvider({
|
|
39
39
|
languageModels: {
|
|
40
40
|
// replacement model with custom provider options:
|
|
41
|
-
'gpt-
|
|
42
|
-
model: gateway('openai/gpt-
|
|
41
|
+
'gpt-6-astra': wrapLanguageModel({
|
|
42
|
+
model: gateway('openai/gpt-6-astra'),
|
|
43
43
|
middleware: defaultSettingsMiddleware({
|
|
44
44
|
settings: {
|
|
45
45
|
providerOptions: {
|
|
@@ -51,8 +51,8 @@ export const openai = customProvider({
|
|
|
51
51
|
}),
|
|
52
52
|
}),
|
|
53
53
|
// alias model with custom provider options:
|
|
54
|
-
'gpt-
|
|
55
|
-
model: gateway('openai/gpt-
|
|
54
|
+
'gpt-6-astra-high-reasoning': wrapLanguageModel({
|
|
55
|
+
model: gateway('openai/gpt-6-astra'),
|
|
56
56
|
middleware: defaultSettingsMiddleware({
|
|
57
57
|
settings: {
|
|
58
58
|
providerOptions: {
|
|
@@ -78,8 +78,8 @@ import { customProvider, gateway } from 'ai';
|
|
|
78
78
|
// custom provider with alias names:
|
|
79
79
|
export const anthropic = customProvider({
|
|
80
80
|
languageModels: {
|
|
81
|
-
opus: gateway('anthropic/claude-opus-
|
|
82
|
-
sonnet: gateway('anthropic/claude-sonnet-
|
|
81
|
+
opus: gateway('anthropic/claude-opus-5.5'),
|
|
82
|
+
sonnet: gateway('anthropic/claude-sonnet-5'),
|
|
83
83
|
haiku: gateway('anthropic/claude-haiku-4.5'),
|
|
84
84
|
},
|
|
85
85
|
fallbackProvider: gateway,
|
|
@@ -100,10 +100,10 @@ import {
|
|
|
100
100
|
|
|
101
101
|
export const myProvider = customProvider({
|
|
102
102
|
languageModels: {
|
|
103
|
-
'text-medium': gateway('anthropic/claude-
|
|
104
|
-
'text-small': gateway('openai/gpt-
|
|
103
|
+
'text-medium': gateway('anthropic/claude-sonnet-5'),
|
|
104
|
+
'text-small': gateway('openai/gpt-6-luna'),
|
|
105
105
|
'reasoning-medium': wrapLanguageModel({
|
|
106
|
-
model: gateway('openai/gpt-
|
|
106
|
+
model: gateway('openai/gpt-6-astra'),
|
|
107
107
|
middleware: defaultSettingsMiddleware({
|
|
108
108
|
settings: {
|
|
109
109
|
providerOptions: {
|
|
@@ -115,7 +115,7 @@ export const myProvider = customProvider({
|
|
|
115
115
|
}),
|
|
116
116
|
}),
|
|
117
117
|
'reasoning-fast': wrapLanguageModel({
|
|
118
|
-
model: gateway('openai/gpt-
|
|
118
|
+
model: gateway('openai/gpt-6-astra'),
|
|
119
119
|
middleware: defaultSettingsMiddleware({
|
|
120
120
|
settings: {
|
|
121
121
|
providerOptions: {
|
|
@@ -146,7 +146,7 @@ import { customProvider, uploadFile, uploadSkill } from 'ai';
|
|
|
146
146
|
// custom provider with files interface:
|
|
147
147
|
const myOpenAI = customProvider({
|
|
148
148
|
languageModels: {
|
|
149
|
-
'gpt-
|
|
149
|
+
'gpt-6-luna': openai.responses('gpt-6-luna'),
|
|
150
150
|
},
|
|
151
151
|
files: openai.files(),
|
|
152
152
|
});
|
|
@@ -154,7 +154,7 @@ const myOpenAI = customProvider({
|
|
|
154
154
|
// custom provider with skills interface:
|
|
155
155
|
const myAnthropic = customProvider({
|
|
156
156
|
languageModels: {
|
|
157
|
-
sonnet: anthropic('claude-sonnet-
|
|
157
|
+
sonnet: anthropic('claude-sonnet-5'),
|
|
158
158
|
},
|
|
159
159
|
skills: anthropic.skills(),
|
|
160
160
|
});
|
|
@@ -224,9 +224,9 @@ import { generateText } from 'ai';
|
|
|
224
224
|
import { registry } from './registry';
|
|
225
225
|
|
|
226
226
|
const { text } = await generateText({
|
|
227
|
-
model: registry.languageModel('openai:gpt-
|
|
227
|
+
model: registry.languageModel('openai:gpt-6-astra'), // default separator
|
|
228
228
|
// or with custom separator:
|
|
229
|
-
// model: customSeparatorRegistry.languageModel('openai > gpt-
|
|
229
|
+
// model: customSeparatorRegistry.languageModel('openai > gpt-6-astra'),
|
|
230
230
|
prompt: 'Invent a new holiday and describe its traditions.',
|
|
231
231
|
});
|
|
232
232
|
```
|
|
@@ -295,7 +295,7 @@ import {
|
|
|
295
295
|
|
|
296
296
|
const registry = createProviderRegistry({
|
|
297
297
|
openai: customProvider({
|
|
298
|
-
languageModels: { 'gpt-
|
|
298
|
+
languageModels: { 'gpt-6-luna': openai.responses('gpt-6-luna') },
|
|
299
299
|
files: openai.files(),
|
|
300
300
|
}),
|
|
301
301
|
});
|
|
@@ -307,7 +307,7 @@ const { providerReference } = await uploadFile({
|
|
|
307
307
|
});
|
|
308
308
|
|
|
309
309
|
const { text } = await generateText({
|
|
310
|
-
model: registry.languageModel('openai:gpt-
|
|
310
|
+
model: registry.languageModel('openai:gpt-6-luna'),
|
|
311
311
|
messages: [
|
|
312
312
|
{
|
|
313
313
|
role: 'user',
|
|
@@ -330,7 +330,7 @@ import { createProviderRegistry, customProvider, uploadSkill } from 'ai';
|
|
|
330
330
|
|
|
331
331
|
const registry = createProviderRegistry({
|
|
332
332
|
anthropic: customProvider({
|
|
333
|
-
languageModels: { sonnet: anthropic('claude-sonnet-
|
|
333
|
+
languageModels: { sonnet: anthropic('claude-sonnet-5') },
|
|
334
334
|
skills: anthropic.skills(),
|
|
335
335
|
}),
|
|
336
336
|
});
|
|
@@ -356,7 +356,7 @@ Here is an example that implements the following concepts:
|
|
|
356
356
|
- pre-configure model settings (here: `anthropic > reasoning`)
|
|
357
357
|
- validate the provider-specific options (here: `AnthropicLanguageModelOptions`)
|
|
358
358
|
- use a fallback provider (here: `anthropic > *`)
|
|
359
|
-
- limit a provider to certain models without a fallback (here: `groq >
|
|
359
|
+
- limit a provider to certain models without a fallback (here: `groq > llama-3.1-8b-instant`, `groq > qwen/qwen3.6-27b`)
|
|
360
360
|
- define a custom separator for the provider registry (here: `>`)
|
|
361
361
|
|
|
362
362
|
```ts
|
|
@@ -419,8 +419,8 @@ export const registry = createProviderRegistry(
|
|
|
419
419
|
// limit a provider to certain models without a fallback
|
|
420
420
|
groq: customProvider({
|
|
421
421
|
languageModels: {
|
|
422
|
-
'
|
|
423
|
-
'qwen-
|
|
422
|
+
'llama-3.1-8b-instant': groq('llama-3.1-8b-instant'),
|
|
423
|
+
'qwen/qwen3.6-27b': groq('qwen/qwen3.6-27b'),
|
|
424
424
|
},
|
|
425
425
|
}),
|
|
426
426
|
},
|
|
@@ -462,7 +462,7 @@ globalThis.AI_SDK_DEFAULT_PROVIDER = openai;
|
|
|
462
462
|
import { streamText } from 'ai';
|
|
463
463
|
|
|
464
464
|
const result = await streamText({
|
|
465
|
-
model: 'gpt-
|
|
465
|
+
model: 'gpt-6-astra', // Uses OpenAI provider without prefix
|
|
466
466
|
prompt: 'Invent a new holiday and describe its traditions.',
|
|
467
467
|
});
|
|
468
468
|
```
|
|
@@ -235,7 +235,7 @@ import { streamText } from 'ai';
|
|
|
235
235
|
import { DevToolsTelemetry } from '@ai-sdk/devtools';
|
|
236
236
|
|
|
237
237
|
const result = streamText({
|
|
238
|
-
model: openai('gpt-
|
|
238
|
+
model: openai('gpt-6-astra'),
|
|
239
239
|
prompt: 'Hello!',
|
|
240
240
|
telemetry: {
|
|
241
241
|
integrations: [DevToolsTelemetry()],
|
|
@@ -49,7 +49,7 @@ Telemetry is enabled automatically once an integration is registered — no per-
|
|
|
49
49
|
import { generateText } from 'ai';
|
|
50
50
|
|
|
51
51
|
const result = await generateText({
|
|
52
|
-
model: openai('gpt-
|
|
52
|
+
model: openai('gpt-6-astra'),
|
|
53
53
|
prompt: 'What cities are in the United States?',
|
|
54
54
|
});
|
|
55
55
|
```
|
|
@@ -61,7 +61,7 @@ import { streamText } from 'ai';
|
|
|
61
61
|
import { DevToolsTelemetry } from '@ai-sdk/devtools';
|
|
62
62
|
|
|
63
63
|
const result = streamText({
|
|
64
|
-
model: openai('gpt-
|
|
64
|
+
model: openai('gpt-6-astra'),
|
|
65
65
|
prompt: 'Hello!',
|
|
66
66
|
telemetry: {
|
|
67
67
|
integrations: [DevToolsTelemetry()],
|
|
@@ -159,7 +159,7 @@ Telemetry is enabled automatically, but AI SDK 7 excludes raw request and respon
|
|
|
159
159
|
|
|
160
160
|
```ts highlight="4-7"
|
|
161
161
|
const result = await generateText({
|
|
162
|
-
model: openai('gpt-
|
|
162
|
+
model: openai('gpt-6-astra'),
|
|
163
163
|
prompt: 'Hello!',
|
|
164
164
|
include: {
|
|
165
165
|
requestBody: true,
|
|
@@ -543,7 +543,7 @@ return createUIMessageStreamResponse({
|
|
|
543
543
|
if (part.type === 'start') {
|
|
544
544
|
return {
|
|
545
545
|
createdAt: Date.now(),
|
|
546
|
-
model: 'gpt-
|
|
546
|
+
model: 'gpt-6-astra',
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
549
|
|
|
@@ -947,7 +947,7 @@ Check out the [stream protocol guide](/docs/ai-sdk-ui/stream-protocol) for more
|
|
|
947
947
|
## Reasoning
|
|
948
948
|
|
|
949
949
|
Some models such as DeepSeek `deepseek-r1`
|
|
950
|
-
and Anthropic `claude-sonnet-
|
|
950
|
+
and Anthropic `claude-sonnet-5` support reasoning tokens.
|
|
951
951
|
These tokens are typically sent before the message content.
|
|
952
952
|
You can forward them to the client with the `sendReasoning` option:
|
|
953
953
|
|
|
@@ -1074,7 +1074,7 @@ messages.map(message => (
|
|
|
1074
1074
|
|
|
1075
1075
|
## Image Generation
|
|
1076
1076
|
|
|
1077
|
-
Some models such as Google `gemini-
|
|
1077
|
+
Some models such as Google `gemini-3.1-flash-image-preview` support image generation.
|
|
1078
1078
|
When images are generated, they are exposed as files to the client.
|
|
1079
1079
|
On the client side, you can access file parts of the message object
|
|
1080
1080
|
and render them as images.
|
|
@@ -179,7 +179,7 @@ export async function POST(req: Request) {
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
const result = streamText({
|
|
182
|
-
model: 'openai/gpt-
|
|
182
|
+
model: 'openai/gpt-6-luna',
|
|
183
183
|
messages: convertToModelMessages(validatedMessages),
|
|
184
184
|
tools,
|
|
185
185
|
});
|
|
@@ -344,7 +344,7 @@ export async function POST(req: Request) {
|
|
|
344
344
|
await req.json();
|
|
345
345
|
|
|
346
346
|
const result = streamText({
|
|
347
|
-
model: 'openai/gpt-
|
|
347
|
+
model: 'openai/gpt-6-luna',
|
|
348
348
|
messages: await convertToModelMessages(messages),
|
|
349
349
|
});
|
|
350
350
|
|
|
@@ -472,7 +472,7 @@ export async function POST(req: Request) {
|
|
|
472
472
|
});
|
|
473
473
|
|
|
474
474
|
const result = streamText({
|
|
475
|
-
model: 'openai/gpt-
|
|
475
|
+
model: 'openai/gpt-6-luna',
|
|
476
476
|
messages: await convertToModelMessages(messages),
|
|
477
477
|
});
|
|
478
478
|
|
|
@@ -128,7 +128,7 @@ export async function POST(req: Request) {
|
|
|
128
128
|
saveChat({ id, messages, activeStreamId: null });
|
|
129
129
|
|
|
130
130
|
const result = streamText({
|
|
131
|
-
model: 'openai/gpt-
|
|
131
|
+
model: 'openai/gpt-6-luna',
|
|
132
132
|
messages: await convertToModelMessages(messages),
|
|
133
133
|
});
|
|
134
134
|
|
|
@@ -38,14 +38,14 @@ At a high level, the `streamUI` works like other AI SDK Core functions: you can
|
|
|
38
38
|
|
|
39
39
|
```tsx
|
|
40
40
|
const result = await streamUI({
|
|
41
|
-
model: openai('gpt-
|
|
41
|
+
model: openai('gpt-6-astra'),
|
|
42
42
|
prompt: 'Get the weather for San Francisco',
|
|
43
43
|
text: ({ content }) => <div>{content}</div>,
|
|
44
44
|
tools: {},
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
This example calls the `streamUI` function using OpenAI's `gpt-
|
|
48
|
+
This example calls the `streamUI` function using OpenAI's `gpt-6-astra` model, passes a prompt, specifies how the model's plain text response (`content`) should be rendered, and then provides an empty object for tools. Even though this example does not define any tools, it will stream the model's response as a `div` rather than plain text.
|
|
49
49
|
|
|
50
50
|
### Adding A Tool
|
|
51
51
|
|
|
@@ -60,7 +60,7 @@ Let's expand the previous example to add a tool.
|
|
|
60
60
|
|
|
61
61
|
```tsx highlight="6-14"
|
|
62
62
|
const result = await streamUI({
|
|
63
|
-
model: openai('gpt-
|
|
63
|
+
model: openai('gpt-6-astra'),
|
|
64
64
|
prompt: 'Get the weather for San Francisco',
|
|
65
65
|
text: ({ content }) => <div>{content}</div>,
|
|
66
66
|
tools: {
|
|
@@ -138,7 +138,7 @@ const WeatherComponent = (props: WeatherProps) => (
|
|
|
138
138
|
|
|
139
139
|
export async function streamComponent() {
|
|
140
140
|
const result = await streamUI({
|
|
141
|
-
model: openai('gpt-
|
|
141
|
+
model: openai('gpt-6-astra'),
|
|
142
142
|
prompt: 'Get the weather for San Francisco',
|
|
143
143
|
text: ({ content }) => <div>{content}</div>,
|
|
144
144
|
tools: {
|
|
@@ -166,7 +166,7 @@ The `getWeather` tool should look familiar as it is identical to the example in
|
|
|
166
166
|
2. Next, define a `getWeather` function that will timeout for 2 seconds (to simulate fetching the weather externally) before returning the "weather" for a `location`. Note: you could run any asynchronous TypeScript code here.
|
|
167
167
|
3. Finally, define a `WeatherComponent` which takes in `location` and `weather` as props, which are then rendered within a `div`.
|
|
168
168
|
|
|
169
|
-
Your Server Action is an asynchronous function called `streamComponent` that takes no inputs, and returns a `ReactNode`. Within the action, you call the `streamUI` function, specifying the model (`gpt-
|
|
169
|
+
Your Server Action is an asynchronous function called `streamComponent` that takes no inputs, and returns a `ReactNode`. Within the action, you call the `streamUI` function, specifying the model (`gpt-6-astra`), the prompt, the component that should be rendered if the model chooses to return text, and finally, your `getWeather` tool. Last but not least, you return the resulting component generated by the model with `result.value`.
|
|
170
170
|
|
|
171
171
|
To call this Server Action and display the resulting React Component, you will need a page.
|
|
172
172
|
|
|
@@ -82,7 +82,7 @@ export async function submitUserMessage(input: string) {
|
|
|
82
82
|
'use server';
|
|
83
83
|
|
|
84
84
|
const ui = await streamUI({
|
|
85
|
-
model: openai('gpt-
|
|
85
|
+
model: openai('gpt-6-astra'),
|
|
86
86
|
instructions: 'you are a flight booking assistant',
|
|
87
87
|
prompt: input,
|
|
88
88
|
text: async ({ content }) => <div>{content}</div>,
|
|
@@ -214,7 +214,7 @@ import { streamUI } from '@ai-sdk/rsc';
|
|
|
214
214
|
|
|
215
215
|
export async function generateResponse(prompt: string) {
|
|
216
216
|
const result = await streamUI({
|
|
217
|
-
model: openai('gpt-
|
|
217
|
+
model: openai('gpt-6-astra'),
|
|
218
218
|
prompt,
|
|
219
219
|
text: async function* ({ content }) {
|
|
220
220
|
yield <div>loading...</div>;
|
|
@@ -47,7 +47,7 @@ export async function sendMessage(message: string) {
|
|
|
47
47
|
messages.update([...messages.get(), { role: 'user', content: message }]);
|
|
48
48
|
|
|
49
49
|
const { value: stream } = await streamUI({
|
|
50
|
-
model: openai('gpt-
|
|
50
|
+
model: openai('gpt-6-astra'),
|
|
51
51
|
instructions: 'you are a friendly assistant!',
|
|
52
52
|
messages: messages.get(),
|
|
53
53
|
text: async function* ({ content, done }) {
|
|
@@ -187,7 +187,7 @@ import { getWeather } from '@/utils/queries';
|
|
|
187
187
|
import { Weather } from '@/components/weather';
|
|
188
188
|
|
|
189
189
|
const { value: stream } = await streamUI({
|
|
190
|
-
model: openai('gpt-
|
|
190
|
+
model: openai('gpt-6-astra'),
|
|
191
191
|
instructions: 'you are a friendly assistant!',
|
|
192
192
|
messages,
|
|
193
193
|
text: async function* ({ content, done }) {
|
|
@@ -399,7 +399,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
399
399
|
import { streamUI } from '@ai-sdk/rsc';
|
|
400
400
|
|
|
401
401
|
const { value: stream } = await streamUI({
|
|
402
|
-
model: openai('gpt-
|
|
402
|
+
model: openai('gpt-6-astra'),
|
|
403
403
|
instructions: 'you are a friendly assistant!',
|
|
404
404
|
messages,
|
|
405
405
|
initial: <div>Loading...</div>,
|