ai 7.0.113 → 7.0.116
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 +32 -0
- package/README.md +6 -6
- package/dist/index.js +1010 -1289
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +231 -257
- 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 +14 -10
- package/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +6 -1
- 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/03-ai-sdk-harnesses/02-harness-agent.mdx +97 -107
- package/docs/03-ai-sdk-harnesses/03-tools.mdx +1 -22
- package/docs/03-ai-sdk-harnesses/04-skills.mdx +0 -4
- package/docs/03-ai-sdk-harnesses/06-workflow-utilities.mdx +43 -9
- package/docs/03-ai-sdk-harnesses/07-ui.mdx +33 -30
- package/docs/03-ai-sdk-harnesses/08-terminal-ui.mdx +8 -6
- 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/06-advanced/11-secure-url-fetching.mdx +39 -0
- 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 +13 -9
- 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 +12 -12
- package/src/evaluate/evaluate.ts +1 -10
- package/src/generate-text/restricted-telemetry-dispatcher.ts +6 -58
- package/src/prompt/file-part-data.ts +9 -3
- 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
- package/src/util/download/download.ts +2 -2
|
@@ -117,12 +117,15 @@ Here are the capabilities of popular models:
|
|
|
117
117
|
|
|
118
118
|
| Provider | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
|
|
119
119
|
| -------------------------------------------------- | ------------------------------------------- | ----------- | ----------------- | ---------- | -------------- |
|
|
120
|
+
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4.7` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
120
121
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4.6` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
121
122
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4.5` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
122
123
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
123
124
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
124
125
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3-mini` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
125
126
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6-astra` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
127
|
+
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6-luna` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
128
|
+
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6-sol` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
126
129
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
127
130
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-luna` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
128
131
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-sol` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
@@ -122,7 +122,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
122
122
|
import { generateText } from 'ai';
|
|
123
123
|
|
|
124
124
|
const result = await generateText({
|
|
125
|
-
model: openai('gpt-
|
|
125
|
+
model: openai('gpt-6-astra'),
|
|
126
126
|
tools: {
|
|
127
127
|
web_search: openai.tools.webSearch(),
|
|
128
128
|
},
|
|
@@ -183,7 +183,7 @@ import { generateText, tool } from 'ai';
|
|
|
183
183
|
import { z } from 'zod';
|
|
184
184
|
|
|
185
185
|
const result = await generateText({
|
|
186
|
-
model: 'openai/gpt-
|
|
186
|
+
model: 'openai/gpt-6-luna',
|
|
187
187
|
tools: {
|
|
188
188
|
search: tool({
|
|
189
189
|
inputSchema: z.object({
|
|
@@ -9,7 +9,7 @@ Provider options let you pass provider-specific configuration that goes beyond t
|
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
const result = await generateText({
|
|
12
|
-
model: openai('gpt-
|
|
12
|
+
model: openai('gpt-6-astra'),
|
|
13
13
|
prompt: 'Explain quantum entanglement.',
|
|
14
14
|
providerOptions: {
|
|
15
15
|
openai: {
|
|
@@ -42,7 +42,7 @@ The sections below cover the most frequently used provider options, focusing on
|
|
|
42
42
|
|
|
43
43
|
### Reasoning Effort
|
|
44
44
|
|
|
45
|
-
For reasoning models (e.g. `
|
|
45
|
+
For reasoning models (e.g. `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`), `reasoningEffort` controls how much internal reasoning the model performs before responding. Lower values are faster and cheaper; higher values produce more thorough answers.
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
48
|
import {
|
|
@@ -52,11 +52,11 @@ import {
|
|
|
52
52
|
import { generateText } from 'ai';
|
|
53
53
|
|
|
54
54
|
const result = await generateText({
|
|
55
|
-
model: openai('gpt-
|
|
55
|
+
model: openai('gpt-6-astra'),
|
|
56
56
|
prompt: 'Invent a new holiday and describe its traditions.',
|
|
57
57
|
providerOptions: {
|
|
58
58
|
openai: {
|
|
59
|
-
reasoningEffort: 'low', // '
|
|
59
|
+
reasoningEffort: 'low', // 'low' | 'medium' | 'high' | 'xhigh' | 'max'
|
|
60
60
|
} satisfies OpenAILanguageModelResponsesOptions,
|
|
61
61
|
},
|
|
62
62
|
});
|
|
@@ -99,7 +99,7 @@ import {
|
|
|
99
99
|
import { streamText } from 'ai';
|
|
100
100
|
|
|
101
101
|
const result = streamText({
|
|
102
|
-
model: openai('gpt-
|
|
102
|
+
model: openai('gpt-6-astra'),
|
|
103
103
|
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
|
|
104
104
|
providerOptions: {
|
|
105
105
|
openai: {
|
|
@@ -127,7 +127,7 @@ import {
|
|
|
127
127
|
import { generateText } from 'ai';
|
|
128
128
|
|
|
129
129
|
const result = await generateText({
|
|
130
|
-
model: openai('gpt-
|
|
130
|
+
model: openai('gpt-6-astra'),
|
|
131
131
|
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
|
|
132
132
|
providerOptions: {
|
|
133
133
|
openai: {
|
|
@@ -156,7 +156,7 @@ import {
|
|
|
156
156
|
import { generateText } from 'ai';
|
|
157
157
|
|
|
158
158
|
const result = await generateText({
|
|
159
|
-
model: openai('gpt-
|
|
159
|
+
model: openai('gpt-6-luna'),
|
|
160
160
|
prompt: 'Write a poem about a boy and his first pet dog.',
|
|
161
161
|
providerOptions: {
|
|
162
162
|
openai: {
|
|
@@ -214,7 +214,7 @@ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
|
214
214
|
import { generateText } from 'ai';
|
|
215
215
|
|
|
216
216
|
const { text, usage } = await generateText({
|
|
217
|
-
model: anthropic('claude-opus-
|
|
217
|
+
model: anthropic('claude-opus-5-5'),
|
|
218
218
|
prompt: 'How many people will live in the world in 2040?',
|
|
219
219
|
providerOptions: {
|
|
220
220
|
anthropic: {
|
|
@@ -239,7 +239,7 @@ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
|
239
239
|
import { generateText } from 'ai';
|
|
240
240
|
|
|
241
241
|
const { text } = await generateText({
|
|
242
|
-
model: anthropic('claude-opus-
|
|
242
|
+
model: anthropic('claude-opus-5-5'),
|
|
243
243
|
prompt: 'Write a short poem about the sea.',
|
|
244
244
|
providerOptions: {
|
|
245
245
|
anthropic: {
|
|
@@ -263,7 +263,7 @@ import {
|
|
|
263
263
|
import { generateText } from 'ai';
|
|
264
264
|
|
|
265
265
|
const result = await generateText({
|
|
266
|
-
model: openai('gpt-
|
|
266
|
+
model: openai('gpt-6-astra'),
|
|
267
267
|
prompt: 'What are the implications of quantum computing for cryptography?',
|
|
268
268
|
providerOptions: {
|
|
269
269
|
openai: {
|
|
@@ -301,7 +301,7 @@ import type { OpenAILanguageModelResponsesOptions } from '@ai-sdk/openai';
|
|
|
301
301
|
import { generateText } from 'ai';
|
|
302
302
|
|
|
303
303
|
const result = await generateText({
|
|
304
|
-
model: 'openai/gpt-
|
|
304
|
+
model: 'openai/gpt-6-astra', // AI Gateway model string
|
|
305
305
|
prompt: 'What are the implications of quantum computing for cryptography?',
|
|
306
306
|
providerOptions: {
|
|
307
307
|
openai: {
|
|
@@ -45,7 +45,7 @@ The AI Gateway is the default [global provider](/docs/ai-sdk-core/provider-manag
|
|
|
45
45
|
import { generateText } from 'ai';
|
|
46
46
|
|
|
47
47
|
const { text } = await generateText({
|
|
48
|
-
model: 'anthropic/claude-sonnet-
|
|
48
|
+
model: 'anthropic/claude-sonnet-5',
|
|
49
49
|
prompt: 'What is love?',
|
|
50
50
|
});
|
|
51
51
|
```
|
|
@@ -55,11 +55,11 @@ You can also explicitly import and use the gateway provider:
|
|
|
55
55
|
```ts
|
|
56
56
|
// Option 1: Import from 'ai' package (included by default)
|
|
57
57
|
import { gateway } from 'ai';
|
|
58
|
-
model: gateway('anthropic/claude-sonnet-
|
|
58
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
59
59
|
|
|
60
60
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
61
61
|
import { gateway } from '@ai-sdk/gateway';
|
|
62
|
-
model: gateway('anthropic/claude-sonnet-
|
|
62
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
## Using Dedicated Providers
|
|
@@ -71,7 +71,7 @@ You can also use [first-party](/providers/ai-sdk-providers), [OpenAI-compatible]
|
|
|
71
71
|
```ts
|
|
72
72
|
import { anthropic } from '@ai-sdk/anthropic';
|
|
73
73
|
|
|
74
|
-
model: anthropic('claude-sonnet-
|
|
74
|
+
model: anthropic('claude-sonnet-5');
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
You can change the default global provider so string model references use your preferred provider everywhere in your application. Learn more about [provider management](/docs/ai-sdk-core/provider-management#global-provider-configuration).
|
|
@@ -122,11 +122,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
122
122
|
```ts
|
|
123
123
|
// Option 1: Import from 'ai' package (included by default)
|
|
124
124
|
import { gateway } from 'ai';
|
|
125
|
-
model: gateway('anthropic/claude-sonnet-
|
|
125
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
126
126
|
|
|
127
127
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
128
128
|
import { gateway } from '@ai-sdk/gateway';
|
|
129
|
-
model: gateway('anthropic/claude-sonnet-
|
|
129
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
### Using other providers
|
|
@@ -138,7 +138,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
138
138
|
```ts
|
|
139
139
|
import { openai } from '@ai-sdk/openai';
|
|
140
140
|
|
|
141
|
-
model: openai('gpt-
|
|
141
|
+
model: openai('gpt-6-astra');
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
#### Updating the global provider
|
|
@@ -126,11 +126,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
126
126
|
```ts
|
|
127
127
|
// Option 1: Import from 'ai' package (included by default)
|
|
128
128
|
import { gateway } from 'ai';
|
|
129
|
-
model: gateway('anthropic/claude-sonnet-
|
|
129
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
130
130
|
|
|
131
131
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
132
132
|
import { gateway } from '@ai-sdk/gateway';
|
|
133
|
-
model: gateway('anthropic/claude-sonnet-
|
|
133
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
### Using other providers
|
|
@@ -142,7 +142,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
142
142
|
```ts
|
|
143
143
|
import { openai } from '@ai-sdk/openai';
|
|
144
144
|
|
|
145
|
-
model: openai('gpt-
|
|
145
|
+
model: openai('gpt-6-astra');
|
|
146
146
|
```
|
|
147
147
|
|
|
148
148
|
#### Updating the global provider
|
|
@@ -87,7 +87,7 @@ export async function POST({ request }) {
|
|
|
87
87
|
const { messages }: { messages: UIMessage[] } = await request.json();
|
|
88
88
|
|
|
89
89
|
const result = streamText({
|
|
90
|
-
model: gateway('anthropic/claude-sonnet-
|
|
90
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
91
91
|
messages: await convertToModelMessages(messages),
|
|
92
92
|
});
|
|
93
93
|
|
|
@@ -125,11 +125,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
125
125
|
```ts
|
|
126
126
|
// Option 1: Import from 'ai' package (included by default)
|
|
127
127
|
import { gateway } from 'ai';
|
|
128
|
-
model: gateway('anthropic/claude-sonnet-
|
|
128
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
129
129
|
|
|
130
130
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
131
131
|
import { gateway } from '@ai-sdk/gateway';
|
|
132
|
-
model: gateway('anthropic/claude-sonnet-
|
|
132
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### Using other providers
|
|
@@ -141,7 +141,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
141
141
|
```ts
|
|
142
142
|
import { openai } from '@ai-sdk/openai';
|
|
143
143
|
|
|
144
|
-
model: openai('gpt-
|
|
144
|
+
model: openai('gpt-6-astra');
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
#### Updating the global provider
|
|
@@ -247,7 +247,7 @@ export async function POST({ request }) {
|
|
|
247
247
|
const { messages }: { messages: UIMessage[] } = await request.json();
|
|
248
248
|
|
|
249
249
|
const result = streamText({
|
|
250
|
-
model: gateway('anthropic/claude-sonnet-
|
|
250
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
251
251
|
messages: await convertToModelMessages(messages),
|
|
252
252
|
tools: {
|
|
253
253
|
weather: tool({
|
|
@@ -371,7 +371,7 @@ export async function POST({ request }) {
|
|
|
371
371
|
const { messages }: { messages: UIMessage[] } = await request.json();
|
|
372
372
|
|
|
373
373
|
const result = streamText({
|
|
374
|
-
model: gateway('anthropic/claude-sonnet-
|
|
374
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
375
375
|
messages: await convertToModelMessages(messages),
|
|
376
376
|
stopWhen: isStepCount(5),
|
|
377
377
|
tools: {
|
|
@@ -428,7 +428,7 @@ export async function POST({ request }) {
|
|
|
428
428
|
const { messages }: { messages: UIMessage[] } = await request.json();
|
|
429
429
|
|
|
430
430
|
const result = streamText({
|
|
431
|
-
model: gateway('anthropic/claude-sonnet-
|
|
431
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
432
432
|
messages: await convertToModelMessages(messages),
|
|
433
433
|
stopWhen: isStepCount(5),
|
|
434
434
|
tools: {
|
|
@@ -99,7 +99,7 @@ export default defineLazyEventHandler(async () => {
|
|
|
99
99
|
const { messages }: { messages: UIMessage[] } = await readBody(event);
|
|
100
100
|
|
|
101
101
|
const result = streamText({
|
|
102
|
-
model: gateway('anthropic/claude-sonnet-
|
|
102
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
103
103
|
messages: await convertToModelMessages(messages),
|
|
104
104
|
});
|
|
105
105
|
|
|
@@ -133,11 +133,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
133
133
|
```ts
|
|
134
134
|
// Option 1: Import from 'ai' package (included by default)
|
|
135
135
|
import { gateway } from 'ai';
|
|
136
|
-
model: gateway('anthropic/claude-sonnet-
|
|
136
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
137
137
|
|
|
138
138
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
139
139
|
import { gateway } from '@ai-sdk/gateway';
|
|
140
|
-
model: gateway('anthropic/claude-sonnet-
|
|
140
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
### Using other providers
|
|
@@ -149,7 +149,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
149
149
|
```ts
|
|
150
150
|
import { openai } from '@ai-sdk/openai';
|
|
151
151
|
|
|
152
|
-
model: openai('gpt-
|
|
152
|
+
model: openai('gpt-6-astra');
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
## Wire up the UI
|
|
@@ -251,7 +251,7 @@ export default defineLazyEventHandler(async () => {
|
|
|
251
251
|
const { messages }: { messages: UIMessage[] } = await readBody(event);
|
|
252
252
|
|
|
253
253
|
const result = streamText({
|
|
254
|
-
model: gateway('anthropic/claude-sonnet-
|
|
254
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
255
255
|
messages: await convertToModelMessages(messages),
|
|
256
256
|
tools: {
|
|
257
257
|
weather: tool({
|
|
@@ -376,7 +376,7 @@ export default defineLazyEventHandler(async () => {
|
|
|
376
376
|
const { messages }: { messages: UIMessage[] } = await readBody(event);
|
|
377
377
|
|
|
378
378
|
const result = streamText({
|
|
379
|
-
model: gateway('anthropic/claude-sonnet-
|
|
379
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
380
380
|
messages: await convertToModelMessages(messages),
|
|
381
381
|
stopWhen: isStepCount(5),
|
|
382
382
|
tools: {
|
|
@@ -437,7 +437,7 @@ export default defineLazyEventHandler(async () => {
|
|
|
437
437
|
const { messages }: { messages: UIMessage[] } = await readBody(event);
|
|
438
438
|
|
|
439
439
|
const result = streamText({
|
|
440
|
-
model: gateway('anthropic/claude-sonnet-
|
|
440
|
+
model: gateway('anthropic/claude-sonnet-5'),
|
|
441
441
|
messages: await convertToModelMessages(messages),
|
|
442
442
|
stopWhen: isStepCount(5),
|
|
443
443
|
tools: {
|
|
@@ -146,11 +146,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
146
146
|
```ts
|
|
147
147
|
// Option 1: Import from 'ai' package (included by default)
|
|
148
148
|
import { gateway } from 'ai';
|
|
149
|
-
model: gateway('anthropic/claude-sonnet-
|
|
149
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
150
150
|
|
|
151
151
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
152
152
|
import { gateway } from '@ai-sdk/gateway';
|
|
153
|
-
model: gateway('anthropic/claude-sonnet-
|
|
153
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
### Using other providers
|
|
@@ -162,7 +162,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
162
162
|
```ts
|
|
163
163
|
import { openai } from '@ai-sdk/openai';
|
|
164
164
|
|
|
165
|
-
model: openai('gpt-
|
|
165
|
+
model: openai('gpt-6-astra');
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
## Enhance Your Agent with Tools
|
|
@@ -125,11 +125,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
125
125
|
```ts
|
|
126
126
|
// Option 1: Import from 'ai' package (included by default)
|
|
127
127
|
import { gateway } from 'ai';
|
|
128
|
-
model: gateway('anthropic/claude-sonnet-
|
|
128
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
129
129
|
|
|
130
130
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
131
131
|
import { gateway } from '@ai-sdk/gateway';
|
|
132
|
-
model: gateway('anthropic/claude-sonnet-
|
|
132
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### Using other providers
|
|
@@ -141,7 +141,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
141
141
|
```ts
|
|
142
142
|
import { openai } from '@ai-sdk/openai';
|
|
143
143
|
|
|
144
|
-
model: openai('gpt-
|
|
144
|
+
model: openai('gpt-6-astra');
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
#### Updating the global provider
|
|
@@ -121,11 +121,11 @@ You can also explicitly import and use the gateway provider in two other equival
|
|
|
121
121
|
```ts
|
|
122
122
|
// Option 1: Import from 'ai' package (included by default)
|
|
123
123
|
import { gateway } from 'ai';
|
|
124
|
-
model: gateway('anthropic/claude-sonnet-
|
|
124
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
125
125
|
|
|
126
126
|
// Option 2: Install and import from '@ai-sdk/gateway' package
|
|
127
127
|
import { gateway } from '@ai-sdk/gateway';
|
|
128
|
-
model: gateway('anthropic/claude-sonnet-
|
|
128
|
+
model: gateway('anthropic/claude-sonnet-5');
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
### Using other providers
|
|
@@ -137,7 +137,7 @@ To use a different provider, install its package and create a provider instance.
|
|
|
137
137
|
```ts
|
|
138
138
|
import { openai } from '@ai-sdk/openai';
|
|
139
139
|
|
|
140
|
-
model: openai('gpt-
|
|
140
|
+
model: openai('gpt-6-astra');
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
#### Updating the global provider
|
|
@@ -74,7 +74,7 @@ Once an integration is registered, [telemetry](/docs/ai-sdk-core/telemetry) is e
|
|
|
74
74
|
import { generateText } from 'ai';
|
|
75
75
|
|
|
76
76
|
const result = await generateText({
|
|
77
|
-
model: openai('gpt-
|
|
77
|
+
model: openai('gpt-6-astra'),
|
|
78
78
|
prompt: 'What cities are in the United States?',
|
|
79
79
|
});
|
|
80
80
|
```
|
|
@@ -129,8 +129,8 @@ async function handleCustomerQuery(query: string) {
|
|
|
129
129
|
const { text: response } = await generateText({
|
|
130
130
|
model:
|
|
131
131
|
classification.complexity === 'simple'
|
|
132
|
-
? 'openai/gpt-
|
|
133
|
-
: 'openai/
|
|
132
|
+
? 'openai/gpt-6-luna'
|
|
133
|
+
: 'openai/gpt-6-astra',
|
|
134
134
|
instructions: {
|
|
135
135
|
general:
|
|
136
136
|
'You are an expert customer service agent handling general inquiries.',
|
|
@@ -87,7 +87,9 @@ const agent = new ToolLoopAgent({
|
|
|
87
87
|
prepareCall: ({ options, ...settings }) => ({
|
|
88
88
|
...settings,
|
|
89
89
|
model:
|
|
90
|
-
options.complexity === 'simple'
|
|
90
|
+
options.complexity === 'simple'
|
|
91
|
+
? 'openai/gpt-6-luna'
|
|
92
|
+
: 'openai/gpt-6-astra',
|
|
91
93
|
}),
|
|
92
94
|
});
|
|
93
95
|
|
|
@@ -158,7 +160,7 @@ import { ToolLoopAgent } from 'ai';
|
|
|
158
160
|
import { z } from 'zod';
|
|
159
161
|
|
|
160
162
|
const agent = new ToolLoopAgent({
|
|
161
|
-
model: 'openai/
|
|
163
|
+
model: 'openai/gpt-6-astra',
|
|
162
164
|
callOptionsSchema: z.object({
|
|
163
165
|
taskDifficulty: z.enum(['low', 'medium', 'high']),
|
|
164
166
|
}),
|
|
@@ -129,7 +129,7 @@ const mem0 = createMem0({
|
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
const agent = new ToolLoopAgent({
|
|
132
|
-
model: mem0('gpt-
|
|
132
|
+
model: mem0('gpt-6-astra', { user_id: 'user-123' }),
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
const { text } = await agent.generate({
|
|
@@ -240,7 +240,7 @@ const mongodbMemory = createMongoDBMemory({
|
|
|
240
240
|
|
|
241
241
|
// Scope to a user and session per request
|
|
242
242
|
const agent = new ToolLoopAgent({
|
|
243
|
-
model: openai('gpt-
|
|
243
|
+
model: openai('gpt-6-astra'),
|
|
244
244
|
tools: mongodbMemory({ userId: 'alice', sessionId: 'sess-001' }),
|
|
245
245
|
stopWhen: isLoopFinished(),
|
|
246
246
|
});
|
|
@@ -80,7 +80,7 @@ const toolApproval = opaPolicy({
|
|
|
80
80
|
|
|
81
81
|
// 3. Pass it to generateText (or streamText / ToolLoopAgent). Everything else is normal.
|
|
82
82
|
const result = await generateText({
|
|
83
|
-
model: anthropic('claude-sonnet-
|
|
83
|
+
model: anthropic('claude-sonnet-5'),
|
|
84
84
|
tools: { git, bash, queryLogs },
|
|
85
85
|
toolApproval,
|
|
86
86
|
prompt: 'find the failing test and push the fix',
|
|
@@ -291,7 +291,7 @@ import { wasmPolicyClient, opaCapabilityMiddleware } from '@ai-sdk/policy-opa';
|
|
|
291
291
|
const client = await wasmPolicyClient({ wasm });
|
|
292
292
|
|
|
293
293
|
const wrappedModel = wrapLanguageModel({
|
|
294
|
-
model: anthropic('claude-sonnet-
|
|
294
|
+
model: anthropic('claude-sonnet-5'),
|
|
295
295
|
middleware: opaCapabilityMiddleware({ client, path: 'agent/tools/allowed' }),
|
|
296
296
|
});
|
|
297
297
|
```
|
|
@@ -51,7 +51,7 @@ import { tool } from 'ai';
|
|
|
51
51
|
import { z } from 'zod';
|
|
52
52
|
|
|
53
53
|
const agent = new WorkflowAgent({
|
|
54
|
-
model: 'anthropic/claude-sonnet-
|
|
54
|
+
model: 'anthropic/claude-sonnet-5',
|
|
55
55
|
instructions: 'You are a helpful assistant.',
|
|
56
56
|
tools: {
|
|
57
57
|
weather: tool({
|
|
@@ -74,11 +74,11 @@ The `model` parameter accepts two forms:
|
|
|
74
74
|
|
|
75
75
|
```ts
|
|
76
76
|
// String — AI Gateway model ID
|
|
77
|
-
new WorkflowAgent({ model: 'anthropic/claude-sonnet-
|
|
77
|
+
new WorkflowAgent({ model: 'anthropic/claude-sonnet-5' });
|
|
78
78
|
|
|
79
79
|
// Provider instance
|
|
80
80
|
import { openai } from '@ai-sdk/openai';
|
|
81
|
-
new WorkflowAgent({ model: openai('gpt-
|
|
81
|
+
new WorkflowAgent({ model: openai('gpt-6-astra') });
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
## Using the Agent in a Workflow
|
|
@@ -103,7 +103,7 @@ export async function chat(messages: UIMessage[]) {
|
|
|
103
103
|
const modelMessages = await convertToModelMessages(messages);
|
|
104
104
|
|
|
105
105
|
const agent = new WorkflowAgent({
|
|
106
|
-
model: 'anthropic/claude-sonnet-
|
|
106
|
+
model: 'anthropic/claude-sonnet-5',
|
|
107
107
|
instructions: 'You are a flight booking assistant.',
|
|
108
108
|
tools: {
|
|
109
109
|
searchFlights: tool({
|
|
@@ -328,7 +328,7 @@ the writable stream. The workflow suspends until the user approves or denies:
|
|
|
328
328
|
|
|
329
329
|
```ts
|
|
330
330
|
const agent = new WorkflowAgent({
|
|
331
|
-
model: 'anthropic/claude-sonnet-
|
|
331
|
+
model: 'anthropic/claude-sonnet-5',
|
|
332
332
|
tools: {
|
|
333
333
|
bookFlight: tool({
|
|
334
334
|
description: 'Book a flight',
|
|
@@ -362,7 +362,7 @@ workflow. For tools that perform sensitive operations, configure
|
|
|
362
362
|
|
|
363
363
|
```ts highlight="4"
|
|
364
364
|
const agent = new WorkflowAgent({
|
|
365
|
-
model: 'anthropic/claude-sonnet-
|
|
365
|
+
model: 'anthropic/claude-sonnet-5',
|
|
366
366
|
experimental_toolApprovalSecret: {
|
|
367
367
|
environmentVariable: 'TOOL_APPROVAL_SECRET',
|
|
368
368
|
},
|
|
@@ -526,7 +526,7 @@ current step:
|
|
|
526
526
|
|
|
527
527
|
```ts
|
|
528
528
|
const agent = new WorkflowAgent({
|
|
529
|
-
model: 'anthropic/claude-sonnet-
|
|
529
|
+
model: 'anthropic/claude-sonnet-5',
|
|
530
530
|
tools: {
|
|
531
531
|
shell: tool({
|
|
532
532
|
description: 'Run a shell command in the sandbox.',
|
|
@@ -561,7 +561,7 @@ Called once before the agent loop starts. Use it to transform model, instruction
|
|
|
561
561
|
|
|
562
562
|
```ts
|
|
563
563
|
const agent = new WorkflowAgent({
|
|
564
|
-
model: 'anthropic/claude-sonnet-
|
|
564
|
+
model: 'anthropic/claude-sonnet-5',
|
|
565
565
|
prepareCall: async ({ model, tools, messages }) => {
|
|
566
566
|
return {
|
|
567
567
|
instructions: `Current time: ${new Date().toISOString()}`,
|
|
@@ -597,7 +597,7 @@ Agents provide lifecycle callbacks for logging, observability, and custom teleme
|
|
|
597
597
|
|
|
598
598
|
```ts
|
|
599
599
|
const agent = new WorkflowAgent({
|
|
600
|
-
model: 'anthropic/claude-sonnet-
|
|
600
|
+
model: 'anthropic/claude-sonnet-5',
|
|
601
601
|
|
|
602
602
|
onStart({ messages }) {
|
|
603
603
|
console.log(`Agent started with ${messages.length} messages`);
|
|
@@ -682,7 +682,7 @@ export type MyAgentUIMessage = InferWorkflowAgentUIMessage<typeof myAgent>;
|
|
|
682
682
|
|
|
683
683
|
- const agent = new DurableAgent({
|
|
684
684
|
+ const agent = new WorkflowAgent({
|
|
685
|
-
model: 'anthropic/claude-sonnet-
|
|
685
|
+
model: 'anthropic/claude-sonnet-5',
|
|
686
686
|
instructions: 'You are a helpful assistant.',
|
|
687
687
|
tools: { /* ... */ },
|
|
688
688
|
});
|
|
@@ -795,7 +795,7 @@ For persistence, store `UIMessage[]` as your source of truth and call [`convertT
|
|
|
795
795
|
|
|
796
796
|
```diff
|
|
797
797
|
const agent = new WorkflowAgent({
|
|
798
|
-
model: 'anthropic/claude-sonnet-
|
|
798
|
+
model: 'anthropic/claude-sonnet-5',
|
|
799
799
|
tools: { weather: weatherTool },
|
|
800
800
|
- experimental_context: { tenantId: 'tenant_123', apiKey: 'sk-...' },
|
|
801
801
|
+ runtimeContext: { tenantId: 'tenant_123' },
|
|
@@ -30,7 +30,7 @@ import { ToolLoopAgent, tool } from 'ai';
|
|
|
30
30
|
import { z } from 'zod';
|
|
31
31
|
|
|
32
32
|
const agent = new ToolLoopAgent({
|
|
33
|
-
model: openai('gpt-
|
|
33
|
+
model: openai('gpt-6-astra'),
|
|
34
34
|
instructions:
|
|
35
35
|
'You are a helpful terminal assistant. Answer in markdown and use tools when they help.',
|
|
36
36
|
tools: {
|
|
@@ -82,17 +82,21 @@ Pass a sandbox session with the `sandbox` option when your agent tools need an
|
|
|
82
82
|
execution environment:
|
|
83
83
|
|
|
84
84
|
```ts
|
|
85
|
-
import {
|
|
85
|
+
import { createJustBashNetworkSandboxSession } from '@ai-sdk/sandbox-just-bash';
|
|
86
86
|
|
|
87
|
-
const sandboxSession = await
|
|
87
|
+
const sandboxSession = await createJustBashNetworkSandboxSession({
|
|
88
88
|
cwd: '/home/user',
|
|
89
|
-
}).createSession();
|
|
90
|
-
|
|
91
|
-
await runAgentTUI({
|
|
92
|
-
title: 'Sandbox Agent',
|
|
93
|
-
agent,
|
|
94
|
-
sandbox: sandboxSession.restricted(),
|
|
95
89
|
});
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
await runAgentTUI({
|
|
93
|
+
title: 'Sandbox Agent',
|
|
94
|
+
agent,
|
|
95
|
+
sandbox: sandboxSession.restricted(),
|
|
96
|
+
});
|
|
97
|
+
} finally {
|
|
98
|
+
await sandboxSession.destroy();
|
|
99
|
+
}
|
|
96
100
|
```
|
|
97
101
|
|
|
98
102
|
The terminal UI forwards the sandbox to every agent call as
|
|
@@ -140,7 +144,7 @@ tool call before the agent continues.
|
|
|
140
144
|
|
|
141
145
|
```ts
|
|
142
146
|
const agent = new ToolLoopAgent({
|
|
143
|
-
model: openai('gpt-
|
|
147
|
+
model: openai('gpt-6-astra'),
|
|
144
148
|
tools: { weather },
|
|
145
149
|
toolApproval: {
|
|
146
150
|
weather: ({ location }) =>
|
|
@@ -717,7 +717,7 @@ When you use `generateText`, you can access the sources using the `sources` prop
|
|
|
717
717
|
|
|
718
718
|
```ts
|
|
719
719
|
const result = await generateText({
|
|
720
|
-
model: 'google/gemini-
|
|
720
|
+
model: 'google/gemini-3.8-flash',
|
|
721
721
|
tools: {
|
|
722
722
|
google_search: google.tools.googleSearch({}),
|
|
723
723
|
},
|
|
@@ -739,7 +739,7 @@ When you use `streamText`, you can access the sources using the `stream` propert
|
|
|
739
739
|
|
|
740
740
|
```tsx
|
|
741
741
|
const result = streamText({
|
|
742
|
-
model: 'google/gemini-
|
|
742
|
+
model: 'google/gemini-3.8-flash',
|
|
743
743
|
tools: {
|
|
744
744
|
google_search: google.tools.googleSearch({}),
|
|
745
745
|
},
|