@mastra/mcp-docs-server 1.2.1-alpha.2 → 1.2.1-alpha.5
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/.docs/docs/agent-builder/overview.md +2 -0
- package/.docs/docs/agents/background-tasks.md +89 -14
- package/.docs/docs/agents/durable-agents.md +231 -0
- package/.docs/docs/agents/skills.md +186 -0
- package/.docs/docs/agents/using-tools.md +52 -0
- package/.docs/docs/evals/datasets/running-experiments.md +76 -0
- package/.docs/docs/getting-started/build-with-ai.md +273 -8
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/workflows/overview.md +71 -0
- package/.docs/docs/workspace/skills.md +9 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +3 -3
- package/.docs/guides/concepts/streaming.md +317 -0
- package/.docs/guides/getting-started/quickstart.md +1 -1
- package/.docs/models/gateways/openrouter.md +2 -2
- package/.docs/models/gateways/vercel.md +10 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/friendli.md +3 -2
- package/.docs/models/providers/lilac.md +7 -7
- package/.docs/models/providers/opencode.md +2 -1
- package/.docs/models/providers/siliconflow-cn.md +2 -1
- package/.docs/models/providers/wafer.ai.md +2 -1
- package/.docs/reference/agents/createSkill.md +78 -0
- package/.docs/reference/agents/durable-agent.md +30 -1
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/getSkill.md +58 -0
- package/.docs/reference/agents/inngest-agent.md +339 -0
- package/.docs/reference/agents/listSkills.md +53 -0
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/index.md +4 -0
- package/.docs/reference/processors/stream-error-retry-processor.md +32 -0
- package/.docs/reference/streaming/workflows/timeTravelStream.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/workflows/run.md +1 -1
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
- package/.docs/docs/build-with-ai/mcp-docs-server.md +0 -238
- package/.docs/docs/build-with-ai/skills.md +0 -63
- package/.docs/docs/streaming/background-task-streaming.md +0 -80
- package/.docs/docs/streaming/events.md +0 -148
- package/.docs/docs/streaming/overview.md +0 -136
- package/.docs/docs/streaming/tool-streaming.md +0 -189
- package/.docs/docs/streaming/workflow-streaming.md +0 -109
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Streaming
|
|
2
|
+
|
|
3
|
+
Mastra supports real-time, incremental responses from agents and workflows, allowing users to see output as it’s generated instead of waiting for completion. This is useful for chat, long-form content, multi-step workflows, or any scenario where immediate feedback matters.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
Mastra's streaming API adapts based on your model version:
|
|
8
|
+
|
|
9
|
+
- **`.stream()`**: For V2 models, supports **AI SDK v5** and later (`LanguageModelV2`).
|
|
10
|
+
- **`.streamLegacy()`**: For V1 models, supports **AI SDK v4** (`LanguageModelV1`).
|
|
11
|
+
|
|
12
|
+
## Streaming with agents
|
|
13
|
+
|
|
14
|
+
You can pass a single string for basic prompts, an array of strings when providing multiple pieces of context, or an array of message objects with `role` and `content` for precise control over roles and conversational flows.
|
|
15
|
+
|
|
16
|
+
### Using `Agent.stream()`
|
|
17
|
+
|
|
18
|
+
A `textStream` breaks the response into chunks as it's generated, allowing output to stream progressively instead of arriving all at once. Iterate over the `textStream` using a `for await` loop to inspect each stream chunk.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
const testAgent = mastra.getAgent('testAgent')
|
|
22
|
+
|
|
23
|
+
const stream = await testAgent.stream([{ role: 'user', content: 'Help me organize my day' }])
|
|
24
|
+
|
|
25
|
+
for await (const chunk of stream.textStream) {
|
|
26
|
+
process.stdout.write(chunk)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
> **Info:** Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
|
|
31
|
+
|
|
32
|
+
> **Tip:** For agents that dispatch [background tasks](https://mastra.ai/docs/agents/background-tasks), use [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle) to keep the stream open until those tasks complete and the agent has had a chance to respond to their results.
|
|
33
|
+
|
|
34
|
+
### Output from `Agent.stream()`
|
|
35
|
+
|
|
36
|
+
The output streams the generated response from the agent.
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
Of course!
|
|
40
|
+
To help you organize your day effectively, I need a bit more information.
|
|
41
|
+
Here are some questions to consider:
|
|
42
|
+
...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Agent stream properties
|
|
46
|
+
|
|
47
|
+
An agent stream provides access to various response properties:
|
|
48
|
+
|
|
49
|
+
- **`stream.textStream`**: A readable stream that emits text chunks.
|
|
50
|
+
- **`stream.text`**: Promise that resolves to the full text response.
|
|
51
|
+
- **`stream.finishReason`**: The reason the agent stopped streaming.
|
|
52
|
+
- **`stream.usage`**: Token usage information.
|
|
53
|
+
|
|
54
|
+
### AI SDK v5+ Compatibility
|
|
55
|
+
|
|
56
|
+
AI SDK v5 (and later) uses `LanguageModelV2` for the model providers. If you are getting an error that you are using an AI SDK v4 model you will need to upgrade your model package to the next major version.
|
|
57
|
+
|
|
58
|
+
For integration with AI SDK v5+, use the `toAISdkV5Stream()` utility from `@mastra/ai-sdk` to convert Mastra streams to AI SDK-compatible format:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { toAISdkV5Stream } from '@mastra/ai-sdk'
|
|
62
|
+
|
|
63
|
+
const testAgent = mastra.getAgent('testAgent')
|
|
64
|
+
|
|
65
|
+
const stream = await testAgent.stream([{ role: 'user', content: 'Help me organize my day' }])
|
|
66
|
+
|
|
67
|
+
// Convert to AI SDK v5+ compatible stream
|
|
68
|
+
const aiSDKStream = toAISdkV5Stream(stream, { from: 'agent' })
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For converting messages to AI SDK v5+ format, use the `toAISdkV5Messages()` utility from `@mastra/ai-sdk/ui`:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { toAISdkV5Messages } from '@mastra/ai-sdk/ui'
|
|
75
|
+
|
|
76
|
+
const messages = [{ role: 'user', content: 'Hello' }]
|
|
77
|
+
const aiSDKMessages = toAISdkV5Messages(messages)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Streaming with workflows
|
|
81
|
+
|
|
82
|
+
Streaming from a workflow returns a sequence of structured events describing the run lifecycle, rather than incremental text chunks. This event-based format makes it possible to track and respond to workflow progress in real time once a run is created using `.createRun()`.
|
|
83
|
+
|
|
84
|
+
### Using `Run.stream()`
|
|
85
|
+
|
|
86
|
+
The `stream()` method returns a `ReadableStream` of events directly.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const run = await testWorkflow.createRun()
|
|
90
|
+
|
|
91
|
+
const stream = await run.stream({
|
|
92
|
+
inputData: {
|
|
93
|
+
value: 'initial data',
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
for await (const chunk of stream) {
|
|
98
|
+
console.log(chunk)
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
> **Info:** Visit [Run.stream()](https://mastra.ai/reference/streaming/workflows/stream) for more information.
|
|
103
|
+
|
|
104
|
+
### Output from `Run.stream()`
|
|
105
|
+
|
|
106
|
+
The event structure includes `runId` and `from` at the top level, making it easier to identify and track workflow runs without digging into the payload.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
{
|
|
110
|
+
type: 'workflow-start',
|
|
111
|
+
runId: '1eeaf01a-d2bf-4e3f-8d1b-027795ccd3df',
|
|
112
|
+
from: 'WORKFLOW',
|
|
113
|
+
payload: {
|
|
114
|
+
stepName: 'step-1',
|
|
115
|
+
args: { value: 'initial data' },
|
|
116
|
+
stepCallId: '8e15e618-be0e-4215-a5d6-08e58c152068',
|
|
117
|
+
startedAt: 1755121710066,
|
|
118
|
+
status: 'running'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Workflow stream properties
|
|
124
|
+
|
|
125
|
+
A workflow stream provides access to various response properties:
|
|
126
|
+
|
|
127
|
+
- **`stream.status`**: The status of the workflow run.
|
|
128
|
+
- **`stream.result`**: The result of the workflow run.
|
|
129
|
+
- **`stream.usage`**: The total token usage of the workflow run.
|
|
130
|
+
|
|
131
|
+
Streaming from agents or workflows provides real-time visibility into either the LLM’s output or the status of a workflow run. This feedback can be passed directly to the user, or used within applications to handle workflow status more effectively, creating a smoother and more responsive experience.
|
|
132
|
+
|
|
133
|
+
Events emitted from agents or workflows represent different stages of generation and execution, such as when a run starts, when text is produced, or when a tool is invoked.
|
|
134
|
+
|
|
135
|
+
## Event types
|
|
136
|
+
|
|
137
|
+
Below is a complete list of events emitted from `.stream()`. Depending on whether you’re streaming from an **agent** or a **workflow**, only a subset of these events will occur:
|
|
138
|
+
|
|
139
|
+
- **start**: Marks the beginning of an agent or workflow run.
|
|
140
|
+
- **step-start**: Indicates a workflow step has begun execution.
|
|
141
|
+
- **text-delta**: Incremental text chunks as they're generated by the LLM.
|
|
142
|
+
- **tool-call**: When the agent decides to use a tool, including the tool name and arguments.
|
|
143
|
+
- **tool-result**: The result returned from tool execution.
|
|
144
|
+
- **step-finish**: Confirms that a specific step has fully finalized, and may include metadata like the finish reason for that step.
|
|
145
|
+
- **finish**: When the agent or workflow completes, including usage statistics.
|
|
146
|
+
|
|
147
|
+
## Inspecting agent streams
|
|
148
|
+
|
|
149
|
+
Iterate over the `stream` with a `for await` loop to inspect all emitted event chunks.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const testAgent = mastra.getAgent('testAgent')
|
|
153
|
+
|
|
154
|
+
const stream = await testAgent.stream([{ role: 'user', content: 'Help me organize my day' }])
|
|
155
|
+
|
|
156
|
+
for await (const chunk of stream) {
|
|
157
|
+
console.log(chunk)
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> **Info:** Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
|
|
162
|
+
|
|
163
|
+
### Example agent output
|
|
164
|
+
|
|
165
|
+
Below is an example of events that may be emitted. Each event always includes a `type` and can include additional fields like `from` and `payload`.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
{
|
|
169
|
+
type: 'start',
|
|
170
|
+
from: 'AGENT',
|
|
171
|
+
// ..
|
|
172
|
+
}
|
|
173
|
+
{
|
|
174
|
+
type: 'step-start',
|
|
175
|
+
from: 'AGENT',
|
|
176
|
+
payload: {
|
|
177
|
+
messageId: 'msg-cdUrkirvXw8A6oE4t5lzDuxi',
|
|
178
|
+
// ...
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
{
|
|
182
|
+
type: 'tool-call',
|
|
183
|
+
from: 'AGENT',
|
|
184
|
+
payload: {
|
|
185
|
+
toolCallId: 'call_jbhi3s1qvR6Aqt9axCfTBMsA',
|
|
186
|
+
toolName: 'testTool'
|
|
187
|
+
// ..
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Writer API
|
|
193
|
+
|
|
194
|
+
The `writer` API is shared by tools and workflow steps — see the Tools and Workflows docs for feature-specific examples.
|
|
195
|
+
|
|
196
|
+
## Agent using tool
|
|
197
|
+
|
|
198
|
+
Agent streaming can be combined with tool calls, allowing tool outputs to be written directly into the agent’s streaming response. This makes it possible to surface tool activity as part of the overall interaction.
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import { Agent } from '@mastra/core/agent'
|
|
202
|
+
import { testTool } from '../tools/test-tool'
|
|
203
|
+
|
|
204
|
+
export const testAgent = new Agent({
|
|
205
|
+
id: 'test-agent',
|
|
206
|
+
name: 'Test Agent',
|
|
207
|
+
instructions: 'You are a weather agent.',
|
|
208
|
+
model: 'openai/gpt-5.5',
|
|
209
|
+
tools: { testTool },
|
|
210
|
+
})
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Using `context.writer`
|
|
214
|
+
|
|
215
|
+
The `context.writer` object is available in a tool's `execute()` function and can be used to emit custom events, data, or values into the active stream. This enables tools to provide intermediate results or status updates while execution is still in progress.
|
|
216
|
+
|
|
217
|
+
> **Warning:** You must `await` the call to `writer.write()` or else you will lock the stream and get a `WritableStream is locked` error.
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { createTool } from '@mastra/core/tools'
|
|
221
|
+
|
|
222
|
+
export const testTool = createTool({
|
|
223
|
+
execute: async (inputData, context) => {
|
|
224
|
+
const { value } = inputData
|
|
225
|
+
|
|
226
|
+
await context?.writer?.write({
|
|
227
|
+
type: 'custom-event',
|
|
228
|
+
status: 'pending',
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
const response = await fetch()
|
|
232
|
+
|
|
233
|
+
await context?.writer?.write({
|
|
234
|
+
type: 'custom-event',
|
|
235
|
+
status: 'success',
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
value: '',
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
})
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
You can also use `writer.custom()` to emit top-level stream chunks. This is useful when integrating with UI frameworks.
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { createTool } from '@mastra/core/tools'
|
|
249
|
+
|
|
250
|
+
export const testTool = createTool({
|
|
251
|
+
execute: async (inputData, context) => {
|
|
252
|
+
const { value } = inputData
|
|
253
|
+
|
|
254
|
+
await context?.writer?.custom({
|
|
255
|
+
type: 'data-tool-progress',
|
|
256
|
+
status: 'pending',
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
const response = await fetch()
|
|
260
|
+
|
|
261
|
+
await context?.writer?.custom({
|
|
262
|
+
type: 'data-tool-progress',
|
|
263
|
+
status: 'success',
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
value: '',
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
})
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Transient data chunks
|
|
274
|
+
|
|
275
|
+
By default, `data-*` chunks emitted with `writer.custom()` are persisted to storage as part of the message history. For chunks that are only needed during live streaming — such as progress updates or verbose log output — set `transient: true` to skip storage persistence. Transient chunks are still streamed to the client in real time but aren't saved to the database.
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
await context?.writer?.custom({
|
|
279
|
+
type: 'data-build-log',
|
|
280
|
+
data: { line: 'Compiling module 3 of 12...' },
|
|
281
|
+
transient: true,
|
|
282
|
+
})
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Use transient chunks when the data is large or high-frequency and only relevant during the live session. After a page refresh, transient chunks are no longer available — only the tool's return value and any non-transient chunks are loaded from storage.
|
|
286
|
+
|
|
287
|
+
## Using the `writer` argument
|
|
288
|
+
|
|
289
|
+
The `writer` argument is passed to a workflow step's `execute` function and can be used to emit custom events, data, or values into the active stream. This enables workflow steps to provide intermediate results or status updates while execution is still in progress.
|
|
290
|
+
|
|
291
|
+
> **Warning:** You must `await` the call to `writer.write(...)` or else you will lock the stream and get a `WritableStream is locked` error.
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { createStep } from "@mastra/core/workflows";
|
|
295
|
+
|
|
296
|
+
export const testStep = createStep({
|
|
297
|
+
execute: async ({ inputData, writer }) => {
|
|
298
|
+
const { value } = inputData;
|
|
299
|
+
|
|
300
|
+
await writer?.write({
|
|
301
|
+
type: "custom-event",
|
|
302
|
+
status: "pending"
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
const response = await fetch(...);
|
|
306
|
+
|
|
307
|
+
await writer?.write({
|
|
308
|
+
type: "custom-event",
|
|
309
|
+
status: "success"
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
value: ""
|
|
314
|
+
};
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
```
|
|
@@ -46,7 +46,7 @@ The wizard creates a new directory for your project with a `src/mastra` folder c
|
|
|
46
46
|
- `workflows/weather-workflow.ts`: A workflow that runs the weather agent
|
|
47
47
|
- `scorers/weather-scorer.ts`: A scorer to evaluate the weather agent's responses
|
|
48
48
|
|
|
49
|
-
Depending on your choices, you'll also end up with [Mastra Skills](https://mastra.ai/docs/build-with-ai
|
|
49
|
+
Depending on your choices, you'll also end up with [Mastra Skills](https://mastra.ai/docs/getting-started/build-with-ai) or the [MCP Docs Server](https://mastra.ai/docs/getting-started/build-with-ai) installed.
|
|
50
50
|
|
|
51
51
|
> **Tip:** You can use [flags](https://mastra.ai/reference/cli/create-mastra) with `create mastra` like `--no-example` to skip the example weather agent or `--template` to start from a specific [template](https://mastra.ai/templates).
|
|
52
52
|
|
|
@@ -284,7 +284,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
284
284
|
| `poolside/laguna-m.1:free` |
|
|
285
285
|
| `poolside/laguna-xs.2` |
|
|
286
286
|
| `poolside/laguna-xs.2:free` |
|
|
287
|
-
| `prime-intellect/intellect-3` |
|
|
288
287
|
| `qwen/qwen-2.5-72b-instruct` |
|
|
289
288
|
| `qwen/qwen-2.5-7b-instruct` |
|
|
290
289
|
| `qwen/qwen-2.5-coder-32b-instruct` |
|
|
@@ -370,4 +369,5 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
370
369
|
| `z-ai/glm-5` |
|
|
371
370
|
| `z-ai/glm-5-turbo` |
|
|
372
371
|
| `z-ai/glm-5.1` |
|
|
373
|
-
| `z-ai/glm-5.2` |
|
|
372
|
+
| `z-ai/glm-5.2` |
|
|
373
|
+
| `z-ai/glm-5v-turbo` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vercel
|
|
2
2
|
|
|
3
|
-
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 288 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Vercel documentation](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
6
6
|
|
|
@@ -216,6 +216,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
216
216
|
| `openai/gpt-4o` |
|
|
217
217
|
| `openai/gpt-4o-mini` |
|
|
218
218
|
| `openai/gpt-4o-mini-search-preview` |
|
|
219
|
+
| `openai/gpt-4o-mini-transcribe` |
|
|
220
|
+
| `openai/gpt-4o-transcribe` |
|
|
219
221
|
| `openai/gpt-5` |
|
|
220
222
|
| `openai/gpt-5-chat` |
|
|
221
223
|
| `openai/gpt-5-codex` |
|
|
@@ -246,6 +248,9 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
246
248
|
| `openai/gpt-oss-120b` |
|
|
247
249
|
| `openai/gpt-oss-20b` |
|
|
248
250
|
| `openai/gpt-oss-safeguard-20b` |
|
|
251
|
+
| `openai/gpt-realtime-1.5` |
|
|
252
|
+
| `openai/gpt-realtime-2` |
|
|
253
|
+
| `openai/gpt-realtime-mini` |
|
|
249
254
|
| `openai/o1` |
|
|
250
255
|
| `openai/o3` |
|
|
251
256
|
| `openai/o3-deep-research` |
|
|
@@ -255,6 +260,9 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
255
260
|
| `openai/text-embedding-3-large` |
|
|
256
261
|
| `openai/text-embedding-3-small` |
|
|
257
262
|
| `openai/text-embedding-ada-002` |
|
|
263
|
+
| `openai/tts-1` |
|
|
264
|
+
| `openai/tts-1-hd` |
|
|
265
|
+
| `openai/whisper-1` |
|
|
258
266
|
| `perplexity/sonar` |
|
|
259
267
|
| `perplexity/sonar-pro` |
|
|
260
268
|
| `perplexity/sonar-reasoning-pro` |
|
|
@@ -295,6 +303,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
295
303
|
| `xai/grok-imagine-image` |
|
|
296
304
|
| `xai/grok-imagine-video` |
|
|
297
305
|
| `xai/grok-imagine-video-1.5-preview` |
|
|
306
|
+
| `xai/grok-voice-think-fast-1.0` |
|
|
298
307
|
| `xiaomi/mimo-v2-flash` |
|
|
299
308
|
| `xiaomi/mimo-v2-pro` |
|
|
300
309
|
| `xiaomi/mimo-v2.5` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 4575 models from 133 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ for await (const chunk of stream) {
|
|
|
44
44
|
| `baseten/zai-org/GLM-4.7` | 200K | | | | | | $0.60 | $2 |
|
|
45
45
|
| `baseten/zai-org/GLM-5` | 203K | | | | | | $0.95 | $3 |
|
|
46
46
|
| `baseten/zai-org/GLM-5.1` | 203K | | | | | | $1 | $4 |
|
|
47
|
-
| `baseten/zai-org/GLM-5.2` |
|
|
47
|
+
| `baseten/zai-org/GLM-5.2` | 262K | | | | | | $1 | $4 |
|
|
48
48
|
|
|
49
49
|
## Advanced configuration
|
|
50
50
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Friendli
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 7 Friendli models through Mastra's model router. Authentication is handled automatically using the `FRIENDLI_TOKEN` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Friendli documentation](https://friendli.ai/docs/guides/serverless_endpoints/introduction).
|
|
6
6
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `friendli/Qwen/Qwen3-235B-A22B-Instruct-2507` | 262K | | | | | | $0.20 | $0.80 |
|
|
41
41
|
| `friendli/zai-org/GLM-5` | 203K | | | | | | $1 | $3 |
|
|
42
42
|
| `friendli/zai-org/GLM-5.1` | 203K | | | | | | $1 | $4 |
|
|
43
|
+
| `friendli/zai-org/GLM-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
43
44
|
|
|
44
45
|
## Advanced configuration
|
|
45
46
|
|
|
@@ -69,7 +70,7 @@ const agent = new Agent({
|
|
|
69
70
|
model: ({ requestContext }) => {
|
|
70
71
|
const useAdvanced = requestContext.task === "complex";
|
|
71
72
|
return useAdvanced
|
|
72
|
-
? "friendli/zai-org/GLM-5.
|
|
73
|
+
? "friendli/zai-org/GLM-5.2"
|
|
73
74
|
: "friendli/MiniMaxAI/MiniMax-M2.5";
|
|
74
75
|
}
|
|
75
76
|
});
|
|
@@ -32,12 +32,12 @@ for await (const chunk of stream) {
|
|
|
32
32
|
|
|
33
33
|
## Models
|
|
34
34
|
|
|
35
|
-
| Model
|
|
36
|
-
|
|
|
37
|
-
| `lilac/google/gemma-4-31b-it`
|
|
38
|
-
| `lilac/minimaxai/minimax-
|
|
39
|
-
| `lilac/moonshotai/kimi-k2.6`
|
|
40
|
-
| `lilac/zai-org/glm-5.
|
|
35
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
|
+
| ----------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
+
| `lilac/google/gemma-4-31b-it` | 262K | | | | | | $0.11 | $0.35 |
|
|
38
|
+
| `lilac/minimaxai/minimax-m3` | 1.0M | | | | | | $0.28 | $1 |
|
|
39
|
+
| `lilac/moonshotai/kimi-k2.6` | 262K | | | | | | $0.70 | $4 |
|
|
40
|
+
| `lilac/zai-org/glm-5.2` | 524K | | | | | | $0.90 | $3 |
|
|
41
41
|
|
|
42
42
|
## Advanced configuration
|
|
43
43
|
|
|
@@ -67,7 +67,7 @@ const agent = new Agent({
|
|
|
67
67
|
model: ({ requestContext }) => {
|
|
68
68
|
const useAdvanced = requestContext.task === "complex";
|
|
69
69
|
return useAdvanced
|
|
70
|
-
? "lilac/zai-org/glm-5.
|
|
70
|
+
? "lilac/zai-org/glm-5.2"
|
|
71
71
|
: "lilac/google/gemma-4-31b-it";
|
|
72
72
|
}
|
|
73
73
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenCode Zen
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 46 OpenCode Zen models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenCode Zen documentation](https://opencode.ai/docs/zen).
|
|
6
6
|
|
|
@@ -52,6 +52,7 @@ for await (const chunk of stream) {
|
|
|
52
52
|
| `opencode/gemini-3.5-flash` | 1.0M | | | | | | $2 | $9 |
|
|
53
53
|
| `opencode/glm-5` | 205K | | | | | | $1 | $3 |
|
|
54
54
|
| `opencode/glm-5.1` | 205K | | | | | | $1 | $4 |
|
|
55
|
+
| `opencode/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
55
56
|
| `opencode/gpt-5` | 400K | | | | | | $1 | $9 |
|
|
56
57
|
| `opencode/gpt-5-codex` | 400K | | | | | | $1 | $9 |
|
|
57
58
|
| `opencode/gpt-5-nano` | 400K | | | | | | $0.05 | $0.40 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SiliconFlow (China)
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 75 SiliconFlow (China) models through Mastra's model router. Authentication is handled automatically using the `SILICONFLOW_CN_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [SiliconFlow (China) documentation](https://cloud.siliconflow.com/models).
|
|
6
6
|
|
|
@@ -43,6 +43,7 @@ for await (const chunk of stream) {
|
|
|
43
43
|
| `siliconflow-cn/deepseek-ai/DeepSeek-V3` | 164K | | | | | | $0.25 | $1 |
|
|
44
44
|
| `siliconflow-cn/deepseek-ai/DeepSeek-V3.1-Terminus` | 164K | | | | | | $0.27 | $1 |
|
|
45
45
|
| `siliconflow-cn/deepseek-ai/DeepSeek-V3.2` | 164K | | | | | | $0.27 | $0.42 |
|
|
46
|
+
| `siliconflow-cn/deepseek-ai/DeepSeek-V4-Flash` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
46
47
|
| `siliconflow-cn/deepseek-ai/DeepSeek-V4-Pro` | 1.0M | | | | | | $2 | $3 |
|
|
47
48
|
| `siliconflow-cn/deepseek-ai/deepseek-vl2` | 4K | | | | | | $0.15 | $0.15 |
|
|
48
49
|
| `siliconflow-cn/inclusionAI/Ling-flash-2.0` | 131K | | | | | | $0.14 | $0.57 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Wafer
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 8 Wafer models through Mastra's model router. Authentication is handled automatically using the `WAFER_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Wafer documentation](https://docs.wafer.ai/wafer-pass).
|
|
6
6
|
|
|
@@ -37,6 +37,7 @@ for await (const chunk of stream) {
|
|
|
37
37
|
| `wafer.ai/deepseek-v4-flash` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
38
38
|
| `wafer.ai/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
39
39
|
| `wafer.ai/GLM-5.1` | 203K | | | | | | $1 | $3 |
|
|
40
|
+
| `wafer.ai/GLM-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
40
41
|
| `wafer.ai/Kimi-K2.6` | 262K | | | | | | $0.68 | $3 |
|
|
41
42
|
| `wafer.ai/Qwen3.5-397B-A17B` | 262K | | | | | | $0.43 | $3 |
|
|
42
43
|
| `wafer.ai/Qwen3.6-35B-A3B` | 256K | | | | | | $0.15 | $1 |
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# `createSkill()`
|
|
2
|
+
|
|
3
|
+
Creates an inline skill that can be passed directly to an agent's `skills` config without a filesystem or workspace.
|
|
4
|
+
|
|
5
|
+
The returned object implements the `Skill` interface and works anywhere a filesystem-discovered skill works.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { createSkill } from '@mastra/core/skills'
|
|
11
|
+
|
|
12
|
+
const reviewSkill = createSkill({
|
|
13
|
+
name: 'code-review',
|
|
14
|
+
description: 'Use when reviewing code changes.',
|
|
15
|
+
instructions: `
|
|
16
|
+
When reviewing code:
|
|
17
|
+
1. Check for correctness
|
|
18
|
+
2. Check for style consistency
|
|
19
|
+
3. Look for potential bugs
|
|
20
|
+
`,
|
|
21
|
+
references: {
|
|
22
|
+
'checklist.md': '# Review Checklist\n- No unused imports\n- Error handling present',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
**name** (`string`): Unique skill name. Used as the identifier when agents activate the skill. Must be a valid slug (lowercase, hyphens allowed).
|
|
30
|
+
|
|
31
|
+
**description** (`string`): Short description shown to the agent in the system message. Helps the agent decide when to use the skill.
|
|
32
|
+
|
|
33
|
+
**instructions** (`string`): The full skill instructions in markdown. Loaded into the conversation when the agent activates the skill.
|
|
34
|
+
|
|
35
|
+
**references** (`Record<string, string>`): Supporting documents the agent can read with the \`skill\_read\` tool. Keys are filenames, values are file contents.
|
|
36
|
+
|
|
37
|
+
**license** (`string`): SPDX license identifier for the skill.
|
|
38
|
+
|
|
39
|
+
**compatibility** (`unknown`): Compatibility requirements. The Agent Skills spec leaves this flexible — can be a string array, object, or any structure your tooling expects.
|
|
40
|
+
|
|
41
|
+
**user-invocable** (`boolean`): Whether end users can invoke this skill directly. Defaults to \`undefined\` (agent decides).
|
|
42
|
+
|
|
43
|
+
**metadata** (`Record<string, unknown>`): Arbitrary metadata attached to the skill.
|
|
44
|
+
|
|
45
|
+
## Return value
|
|
46
|
+
|
|
47
|
+
Returns an `InlineSkill` object that implements the `Skill` interface:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
interface InlineSkill extends Skill {
|
|
51
|
+
__inline: true
|
|
52
|
+
__referenceContents: Record<string, string>
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The skill is assigned a synthetic path of `inline/<name>` (e.g., `inline/code-review`).
|
|
57
|
+
|
|
58
|
+
## Validation
|
|
59
|
+
|
|
60
|
+
`createSkill()` validates inputs using the same rules as filesystem skills:
|
|
61
|
+
|
|
62
|
+
- `name` is required and must be a valid slug
|
|
63
|
+
- `description` is required
|
|
64
|
+
- `instructions` is required and non-empty
|
|
65
|
+
|
|
66
|
+
If validation fails, an `Error` is thrown with details about the invalid fields.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// Throws: Invalid skill "": name is required
|
|
70
|
+
createSkill({ name: '', description: 'test', instructions: 'test' })
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Related
|
|
74
|
+
|
|
75
|
+
- [Agent skills](https://mastra.ai/docs/agents/skills)
|
|
76
|
+
- [Workspace skills](https://mastra.ai/docs/workspace/skills)
|
|
77
|
+
- [`.getSkill()` reference](https://mastra.ai/reference/agents/getSkill)
|
|
78
|
+
- [`.listSkills()` reference](https://mastra.ai/reference/agents/listSkills)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`DurableAgent` wraps an existing [`Agent`](https://mastra.ai/reference/agents/agent) with durable execution and resumable streams. It runs the agentic loop so that a client can disconnect and reconnect without missing events, and it streams those events over [PubSub](https://mastra.ai/docs/server/pubsub). Use it when a run must outlive a single request or survive a dropped connection.
|
|
4
4
|
|
|
5
|
-
Create one with the [`createDurableAgent`](#createdurableagentoptions) factory, or use [`createEventedAgent`](#createeventedagentoptions) for fire-and-forget execution on the built-in workflow engine. For Inngest-powered execution, use `createInngestAgent` from `@mastra/inngest`.
|
|
5
|
+
Create one with the [`createDurableAgent`](#createdurableagentoptions) factory, or use [`createEventedAgent`](#createeventedagentoptions) for fire-and-forget execution on the built-in workflow engine. For Inngest-powered execution, use [`createInngestAgent`](https://mastra.ai/reference/agents/inngest-agent) from `@mastra/inngest`.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -153,6 +153,32 @@ Returns: `Promise<DurableAgentStreamResult>`
|
|
|
153
153
|
|
|
154
154
|
> **Warning:** The `cleanup()` returned by `observe()` destroys the run's registry entries and cached events. Only call it when you are done with the run. If the run is suspended and you intend to resume later, don't call `cleanup()` — let the auto-cleanup timer handle it after the run finishes or errors. Auto-cleanup doesn't fire on suspended events.
|
|
155
155
|
|
|
156
|
+
#### `prepare(messages, options?)`
|
|
157
|
+
|
|
158
|
+
Prepares a run for durable execution without starting it. Registers the run in the internal registry and returns the serialized workflow input. Use this when you need to control when and how the workflow is triggered.
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
const { runId, messageId, workflowInput, threadId, resourceId } = await durableAgent.prepare(
|
|
162
|
+
'Summarize the document',
|
|
163
|
+
{
|
|
164
|
+
memory: { threadId: 'thread-1', resourceId: 'user-1' },
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
interface PrepareResult {
|
|
173
|
+
runId: string
|
|
174
|
+
messageId: string
|
|
175
|
+
workflowInput: any
|
|
176
|
+
registryEntry: object
|
|
177
|
+
threadId?: string
|
|
178
|
+
resourceId?: string
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
156
182
|
## Stream options
|
|
157
183
|
|
|
158
184
|
`stream()` accepts a `DurableAgentStreamOptions` object. It supports the agent execution options below, plus lifecycle callbacks.
|
|
@@ -191,6 +217,8 @@ Returns: `Promise<DurableAgentStreamResult>`
|
|
|
191
217
|
|
|
192
218
|
**structuredOutput** (`object`): Structured output configuration.
|
|
193
219
|
|
|
220
|
+
**untilIdle** (`boolean | { maxIdleMs?: number }`): When set, keeps the stream open across background-task continuations until the agent is idle. Pass \`true\` for the default 5-minute idle timeout, or \`{ maxIdleMs }\` to customise. Equivalent to the deprecated \`streamUntilIdle()\` method.
|
|
221
|
+
|
|
194
222
|
**versions** (`object`): Version overrides for sub-agent delegation.
|
|
195
223
|
|
|
196
224
|
**onChunk** (`(chunk: ChunkType) => void | Promise<void>`): Called for each streamed chunk.
|
|
@@ -234,6 +262,7 @@ interface DurableAgentStreamResult<OUTPUT = undefined> {
|
|
|
234
262
|
|
|
235
263
|
## Related
|
|
236
264
|
|
|
265
|
+
- [`createInngestAgent()`](https://mastra.ai/reference/agents/inngest-agent)
|
|
237
266
|
- [Agent class](https://mastra.ai/reference/agents/agent)
|
|
238
267
|
- [PubSub](https://mastra.ai/docs/server/pubsub)
|
|
239
268
|
- [`.getMemory()`](https://mastra.ai/reference/agents/getMemory)
|
|
@@ -28,5 +28,5 @@ await agent.getDefaultOptions({
|
|
|
28
28
|
|
|
29
29
|
## Related
|
|
30
30
|
|
|
31
|
-
- [Streaming with agents](https://mastra.ai/
|
|
31
|
+
- [Streaming with agents](https://mastra.ai/guides/concepts/streaming)
|
|
32
32
|
- [Request Context](https://mastra.ai/docs/server/request-context)
|
|
@@ -30,5 +30,5 @@ await agent.getDefaultStreamOptionsLegacy({
|
|
|
30
30
|
|
|
31
31
|
## Related
|
|
32
32
|
|
|
33
|
-
- [Streaming with agents](https://mastra.ai/
|
|
33
|
+
- [Streaming with agents](https://mastra.ai/guides/concepts/streaming)
|
|
34
34
|
- [Request Context](https://mastra.ai/docs/server/request-context)
|