@mastra/mcp-docs-server 1.2.14-alpha.3 → 1.2.14-alpha.4

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.
Files changed (70) hide show
  1. package/.docs/docs/agents/processors.md +25 -1
  2. package/.docs/docs/workflows/agents-and-tools.md +29 -0
  3. package/.docs/docs/workflows/stored-workflows.md +146 -0
  4. package/.docs/models/environment-variables.md +1 -1
  5. package/.docs/models/gateways/neon.md +71 -0
  6. package/.docs/models/gateways/netlify.md +6 -6
  7. package/.docs/models/gateways/openrouter.md +6 -6
  8. package/.docs/models/gateways/vercel.md +6 -6
  9. package/.docs/models/gateways.md +1 -0
  10. package/.docs/models/index.md +95 -96
  11. package/.docs/models/providers/alibaba-cn.md +23 -25
  12. package/.docs/models/providers/alibaba-token-plan-cn.md +24 -24
  13. package/.docs/models/providers/alibaba-token-plan.md +23 -25
  14. package/.docs/models/providers/alibaba.md +23 -25
  15. package/.docs/models/providers/ambient.md +23 -25
  16. package/.docs/models/providers/baseten.md +23 -25
  17. package/.docs/models/providers/chutes.md +23 -25
  18. package/.docs/models/providers/cortecs.md +23 -25
  19. package/.docs/models/providers/crof.md +23 -25
  20. package/.docs/models/providers/crossmodel.md +23 -25
  21. package/.docs/models/providers/deepinfra.md +22 -24
  22. package/.docs/models/providers/digitalocean.md +23 -25
  23. package/.docs/models/providers/empiriolabs.md +23 -25
  24. package/.docs/models/providers/fireworks-ai.md +24 -24
  25. package/.docs/models/providers/greenpt.md +23 -25
  26. package/.docs/models/providers/groq.md +23 -25
  27. package/.docs/models/providers/huggingface.md +23 -25
  28. package/.docs/models/providers/hyper.md +23 -25
  29. package/.docs/models/providers/impossibl.md +23 -25
  30. package/.docs/models/providers/infomaniak.md +24 -24
  31. package/.docs/models/providers/kilo.md +23 -25
  32. package/.docs/models/providers/llmgateway.md +23 -25
  33. package/.docs/models/providers/mistral.md +23 -25
  34. package/.docs/models/providers/modal.md +23 -25
  35. package/.docs/models/providers/modelis.md +23 -25
  36. package/.docs/models/providers/nano-gpt.md +23 -25
  37. package/.docs/models/providers/neuralwatt.md +23 -25
  38. package/.docs/models/providers/ofox.md +23 -25
  39. package/.docs/models/providers/ollama-cloud.md +23 -25
  40. package/.docs/models/providers/opencode-go.md +23 -25
  41. package/.docs/models/providers/opencode.md +23 -25
  42. package/.docs/models/providers/pioneer.md +23 -25
  43. package/.docs/models/providers/requesty.md +23 -25
  44. package/.docs/models/providers/routing-run.md +23 -25
  45. package/.docs/models/providers/scx.md +23 -25
  46. package/.docs/models/providers/tensorx.md +23 -25
  47. package/.docs/models/providers/togetherai.md +22 -24
  48. package/.docs/models/providers/umans-ai-coding-plan.md +24 -24
  49. package/.docs/models/providers/umans-ai.md +23 -25
  50. package/.docs/models/providers/wandb.md +23 -25
  51. package/.docs/models/providers/xai.md +26 -28
  52. package/.docs/models/providers/zai-coding-plan.md +23 -25
  53. package/.docs/models/providers/zhipuai-coding-plan.md +23 -25
  54. package/.docs/models/providers.md +0 -1
  55. package/.docs/reference/client-js/workflows.md +92 -0
  56. package/.docs/reference/core/addStoredWorkflow.md +62 -0
  57. package/.docs/reference/core/addStoredWorkflows.md +40 -0
  58. package/.docs/reference/index.md +5 -0
  59. package/.docs/reference/processors/processor-interface.md +121 -10
  60. package/.docs/reference/server/routes.md +13 -0
  61. package/.docs/reference/storage/overview.md +9 -8
  62. package/.docs/reference/streaming/workflows/observeStream.md +1 -1
  63. package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
  64. package/.docs/reference/streaming/workflows/stream.md +1 -1
  65. package/.docs/reference/workflows/stored-workflow-definition.md +292 -0
  66. package/.docs/reference/workflows/workflow-methods/agent.md +62 -0
  67. package/.docs/reference/workflows/workflow-methods/tool.md +43 -0
  68. package/CHANGELOG.md +7 -0
  69. package/package.json +5 -5
  70. package/.docs/models/providers/neon.md +0 -109
@@ -23,65 +23,65 @@ Mastra reads the relevant environment variable (e.g. `ANTHROPIC_API_KEY`) and ro
23
23
  **OpenAI**:
24
24
 
25
25
  ```typescript
26
- import { Agent } from "@mastra/core/agent";
26
+ import { Agent } from '@mastra/core/agent'
27
27
 
28
28
  const agent = new Agent({
29
- id: "my-agent",
30
- name: "My Agent",
31
- instructions: "You are a helpful assistant",
32
- model: "openai/gpt-5.6-sol"
29
+ id: 'my-agent',
30
+ name: 'My Agent',
31
+ instructions: 'You are a helpful assistant',
32
+ model: 'openai/gpt-5.6-sol',
33
33
  })
34
34
  ```
35
35
 
36
36
  **Anthropic**:
37
37
 
38
38
  ```typescript
39
- import { Agent } from "@mastra/core/agent";
39
+ import { Agent } from '@mastra/core/agent'
40
40
 
41
41
  const agent = new Agent({
42
- id: "my-agent",
43
- name: "My Agent",
44
- instructions: "You are a helpful assistant",
45
- model: "anthropic/claude-sonnet-4-6"
42
+ id: 'my-agent',
43
+ name: 'My Agent',
44
+ instructions: 'You are a helpful assistant',
45
+ model: 'anthropic/claude-sonnet-4-6',
46
46
  })
47
47
  ```
48
48
 
49
49
  **Google Gemini**:
50
50
 
51
51
  ```typescript
52
- import { Agent } from "@mastra/core/agent";
52
+ import { Agent } from '@mastra/core/agent'
53
53
 
54
54
  const agent = new Agent({
55
- id: "my-agent",
56
- name: "My Agent",
57
- instructions: "You are a helpful assistant",
58
- model: "google/gemini-2.5-flash"
55
+ id: 'my-agent',
56
+ name: 'My Agent',
57
+ instructions: 'You are a helpful assistant',
58
+ model: 'google/gemini-2.5-flash',
59
59
  })
60
60
  ```
61
61
 
62
62
  **xAI**:
63
63
 
64
64
  ```typescript
65
- import { Agent } from "@mastra/core/agent";
65
+ import { Agent } from '@mastra/core/agent'
66
66
 
67
67
  const agent = new Agent({
68
- id: "my-agent",
69
- name: "My Agent",
70
- instructions: "You are a helpful assistant",
71
- model: "xai/grok-4.3"
68
+ id: 'my-agent',
69
+ name: 'My Agent',
70
+ instructions: 'You are a helpful assistant',
71
+ model: 'xai/grok-4.3',
72
72
  })
73
73
  ```
74
74
 
75
75
  **OpenRouter**:
76
76
 
77
77
  ```typescript
78
- import { Agent } from "@mastra/core/agent";
78
+ import { Agent } from '@mastra/core/agent'
79
79
 
80
80
  const agent = new Agent({
81
- id: "my-agent",
82
- name: "My Agent",
83
- instructions: "You are a helpful assistant",
84
- model: "openrouter/anthropic/claude-haiku-4.5"
81
+ id: 'my-agent',
82
+ name: 'My Agent',
83
+ instructions: 'You are a helpful assistant',
84
+ model: 'openrouter/anthropic/claude-haiku-4.5',
85
85
  })
86
86
  ```
87
87
 
@@ -103,22 +103,22 @@ Alternatively, browse and test models in [Studio](https://mastra.ai/docs/studio/
103
103
  Some models are faster but less capable, while others offer larger context windows or stronger reasoning skills. Use different models from the same provider, or mix and match across providers to fit each task.
104
104
 
105
105
  ```typescript
106
- import { Agent } from "@mastra/core/agent";
106
+ import { Agent } from '@mastra/core/agent'
107
107
 
108
108
  // Use a cost-effective model for document processing
109
109
  const documentProcessor = new Agent({
110
- id: "document-processor",
111
- name: "Document Processor",
112
- instructions: "Extract and summarize key information from documents",
113
- model: "openai/gpt-5.6-sol"
110
+ id: 'document-processor',
111
+ name: 'Document Processor',
112
+ instructions: 'Extract and summarize key information from documents',
113
+ model: 'openai/gpt-5.6-sol',
114
114
  })
115
115
 
116
116
  // Use a powerful reasoning model for complex analysis
117
117
  const reasoningAgent = new Agent({
118
- id: "reasoning-agent",
119
- name: "Reasoning Agent",
120
- instructions: "Analyze data and provide strategic recommendations",
121
- model: "anthropic/claude-opus-4-7"
118
+ id: 'reasoning-agent',
119
+ name: 'Reasoning Agent',
120
+ instructions: 'Analyze data and provide strategic recommendations',
121
+ model: 'anthropic/claude-opus-4-7',
122
122
  })
123
123
  ```
124
124
 
@@ -128,14 +128,14 @@ Since models are just strings, you can select them dynamically based on [request
128
128
 
129
129
  ```typescript
130
130
  const agent = new Agent({
131
- id: "dynamic-assistant",
132
- name: "Dynamic Assistant",
131
+ id: 'dynamic-assistant',
132
+ name: 'Dynamic Assistant',
133
133
  model: ({ requestContext }) => {
134
- const provider = requestContext.get("provider-id");
135
- const model = requestContext.get("model-id");
136
- return `${provider}/${model}`;
134
+ const provider = requestContext.get('provider-id')
135
+ const model = requestContext.get('model-id')
136
+ return `${provider}/${model}`
137
137
  },
138
- });
138
+ })
139
139
  ```
140
140
 
141
141
  This enables powerful patterns:
@@ -151,31 +151,30 @@ Different model providers expose their own configuration options. With OpenAI, y
151
151
  ```typescript
152
152
  // Agent level (apply to all future messages)
153
153
  const planner = new Agent({
154
- id: "planner",
155
- name: "Planner",
154
+ id: 'planner',
155
+ name: 'Planner',
156
156
  instructions: {
157
- role: "system",
158
- content: "You are a helpful assistant.",
157
+ role: 'system',
158
+ content: 'You are a helpful assistant.',
159
159
  providerOptions: {
160
- openai: { reasoningEffort: "low" }
161
- }
160
+ openai: { reasoningEffort: 'low' },
161
+ },
162
162
  },
163
- model: "openai/gpt-5.6-sol",
164
- });
163
+ model: 'openai/gpt-5.6-sol',
164
+ })
165
165
 
166
- const lowEffort =
167
- await planner.generate("Plan a simple 3 item dinner menu");
166
+ const lowEffort = await planner.generate('Plan a simple 3 item dinner menu')
168
167
 
169
168
  // Message level (apply only to this message)
170
169
  const highEffort = await planner.generate([
171
170
  {
172
- role: "user",
173
- content: "Plan a simple 3 item dinner menu for a celiac",
171
+ role: 'user',
172
+ content: 'Plan a simple 3 item dinner menu for a celiac',
174
173
  providerOptions: {
175
- openai: { reasoningEffort: "high" }
176
- }
177
- }
178
- ]);
174
+ openai: { reasoningEffort: 'high' },
175
+ },
176
+ },
177
+ ])
179
178
  ```
180
179
 
181
180
  ## Custom headers
@@ -184,16 +183,16 @@ If you need to specify custom headers, such as an organization ID or other provi
184
183
 
185
184
  ```typescript
186
185
  const agent = new Agent({
187
- id: "custom-agent",
188
- name: "Custom Agent",
186
+ id: 'custom-agent',
187
+ name: 'Custom Agent',
189
188
  model: {
190
- id: "openai/gpt-5.6-sol",
189
+ id: 'openai/gpt-5.6-sol',
191
190
  apiKey: process.env.OPENAI_API_KEY,
192
191
  headers: {
193
- "OpenAI-Organization": "org-abc123"
194
- }
195
- }
196
- });
192
+ 'OpenAI-Organization': 'org-abc123',
193
+ },
194
+ },
195
+ })
197
196
  ```
198
197
 
199
198
  > **Info:** Configuration differs by provider. See the provider pages in the left navigation for details on custom headers.
@@ -203,7 +202,7 @@ const agent = new Agent({
203
202
  Relying on a single model creates a single point of failure for your application. Model fallbacks provide automatic failover between models and providers. If the primary model becomes unavailable, requests are retried against the next configured fallback until one succeeds.
204
203
 
205
204
  ```typescript
206
- import { Agent } from '@mastra/core/agent';
205
+ import { Agent } from '@mastra/core/agent'
207
206
 
208
207
  const agent = new Agent({
209
208
  id: 'resilient-assistant',
@@ -211,19 +210,19 @@ const agent = new Agent({
211
210
  instructions: 'You are a helpful assistant.',
212
211
  model: [
213
212
  {
214
- model: "openai/gpt-5.6-sol",
213
+ model: 'openai/gpt-5.6-sol',
215
214
  maxRetries: 3,
216
215
  },
217
216
  {
218
- model: "anthropic/claude-sonnet-4-6",
217
+ model: 'anthropic/claude-sonnet-4-6',
219
218
  maxRetries: 2,
220
219
  },
221
220
  {
222
- model: "google/gemini-2.5-pro",
221
+ model: 'google/gemini-2.5-pro',
223
222
  maxRetries: 2,
224
223
  },
225
224
  ],
226
- });
225
+ })
227
226
  ```
228
227
 
229
228
  Mastra tries your primary model first. If it encounters a 500 error, rate limit, or timeout, it automatically switches to your first fallback. If that fails too, it moves to the next. Each model gets its own retry count before moving on.
@@ -235,7 +234,7 @@ Your users never experience the disruption - the response comes back with the sa
235
234
  Each fallback entry can carry its own `modelSettings`, `providerOptions`, and `headers` — useful when models in the chain need different temperatures or provider-specific knobs to produce comparable output.
236
235
 
237
236
  ```typescript
238
- import { Agent } from '@mastra/core/agent';
237
+ import { Agent } from '@mastra/core/agent'
239
238
 
240
239
  const agent = new Agent({
241
240
  id: 'tuned-resilient',
@@ -255,7 +254,7 @@ const agent = new Agent({
255
254
  providerOptions: { openai: { reasoningEffort: 'low' } },
256
255
  },
257
256
  ],
258
- });
257
+ })
259
258
  ```
260
259
 
261
260
  **Precedence:**
@@ -278,32 +277,32 @@ Use `gateway/provider/model` when the remote behaves like a model gateway and th
278
277
  For the `url` it's **important** that you use the base URL of the OpenAI-compatible endpoint with Mastra's `model` setting and not the individual chat endpoints.
279
278
 
280
279
  ```typescript
281
- import { Agent } from "@mastra/core/agent";
280
+ import { Agent } from '@mastra/core/agent'
282
281
 
283
282
  const agent = new Agent({
284
- id: "my-agent",
285
- name: "My Agent",
286
- instructions: "You are a helpful assistant",
283
+ id: 'my-agent',
284
+ name: 'My Agent',
285
+ instructions: 'You are a helpful assistant',
287
286
  model: {
288
- id: "custom/my-qwen3-model",
289
- url: "http://your-custom-openai-compatible-endpoint.com/v1"
290
- }
287
+ id: 'custom/my-qwen3-model',
288
+ url: 'http://your-custom-openai-compatible-endpoint.com/v1',
289
+ },
291
290
  })
292
291
  ```
293
292
 
294
293
  If the remote behaves like a model gateway, include the gateway prefix in `id`:
295
294
 
296
295
  ```typescript
297
- import { Agent } from "@mastra/core/agent";
296
+ import { Agent } from '@mastra/core/agent'
298
297
 
299
298
  const agent = new Agent({
300
- id: "my-agent",
301
- name: "My Agent",
302
- instructions: "You are a helpful assistant",
299
+ id: 'my-agent',
300
+ name: 'My Agent',
301
+ instructions: 'You are a helpful assistant',
303
302
  model: {
304
- id: "mastra/google/gemini-2.5-flash",
305
- url: "http://your-custom-openai-compatible-endpoint.com/v1"
306
- }
303
+ id: 'mastra/google/gemini-2.5-flash',
304
+ url: 'http://your-custom-openai-compatible-endpoint.com/v1',
305
+ },
307
306
  })
308
307
  ```
309
308
 
@@ -312,16 +311,16 @@ const agent = new Agent({
312
311
  After starting the LMStudio server, the local server is available at `http://localhost:1234` and it provides endpoints like `/v1/models`, `/v1/chat/completions`, etc. The `url` will be `http://localhost:1234/v1`. For the `id` you can use (`lmstudio/${modelId}`) which will be displayed in the LMStudio interface.
313
312
 
314
313
  ```typescript
315
- import { Agent } from "@mastra/core/agent";
314
+ import { Agent } from '@mastra/core/agent'
316
315
 
317
316
  const agent = new Agent({
318
- id: "my-agent",
319
- name: "My Agent",
320
- instructions: "You are a helpful assistant",
317
+ id: 'my-agent',
318
+ name: 'My Agent',
319
+ instructions: 'You are a helpful assistant',
321
320
  model: {
322
- id: "lmstudio/qwen/qwen3-30b-a3b-2507",
323
- url: "http://localhost:1234/v1"
324
- }
321
+ id: 'lmstudio/qwen/qwen3-30b-a3b-2507',
322
+ url: 'http://localhost:1234/v1',
323
+ },
325
324
  })
326
325
  ```
327
326
 
@@ -330,13 +329,13 @@ const agent = new Agent({
330
329
  Mastra supports AI SDK provider modules, should you need to use them directly.
331
330
 
332
331
  ```typescript
333
- import { groq } from '@ai-sdk/groq';
334
- import { Agent } from "@mastra/core/agent";
332
+ import { groq } from '@ai-sdk/groq'
333
+ import { Agent } from '@mastra/core/agent'
335
334
 
336
335
  const agent = new Agent({
337
- id: "my-agent",
338
- name: "My Agent",
339
- model: groq('gemma2-9b-it')
336
+ id: 'my-agent',
337
+ name: 'My Agent',
338
+ model: groq('gemma2-9b-it'),
340
339
  })
341
340
  ```
342
341
 
@@ -11,22 +11,22 @@ DASHSCOPE_API_KEY=your-api-key
11
11
  ```
12
12
 
13
13
  ```typescript
14
- import { Agent } from "@mastra/core/agent";
14
+ import { Agent } from '@mastra/core/agent'
15
15
 
16
16
  const agent = new Agent({
17
- id: "my-agent",
18
- name: "My Agent",
19
- instructions: "You are a helpful assistant",
20
- model: "alibaba-cn/MiniMax-M2.5"
21
- });
17
+ id: 'my-agent',
18
+ name: 'My Agent',
19
+ instructions: 'You are a helpful assistant',
20
+ model: 'alibaba-cn/MiniMax-M2.5',
21
+ })
22
22
 
23
23
  // Generate a response
24
- const response = await agent.generate("Hello!");
24
+ const response = await agent.generate('Hello!')
25
25
 
26
26
  // Stream a response
27
- const stream = await agent.stream("Tell me a story");
27
+ const stream = await agent.stream('Tell me a story')
28
28
  for await (const chunk of stream) {
29
- console.log(chunk);
29
+ console.log(chunk)
30
30
  }
31
31
  ```
32
32
 
@@ -129,30 +129,28 @@ for await (const chunk of stream) {
129
129
 
130
130
  ```typescript
131
131
  const agent = new Agent({
132
- id: "custom-agent",
133
- name: "custom-agent",
132
+ id: 'custom-agent',
133
+ name: 'custom-agent',
134
134
  model: {
135
- url: "https://dashscope.aliyuncs.com/compatible-mode/v1",
136
- id: "alibaba-cn/MiniMax-M2.5",
135
+ url: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
136
+ id: 'alibaba-cn/MiniMax-M2.5',
137
137
  apiKey: process.env.DASHSCOPE_API_KEY,
138
138
  headers: {
139
- "X-Custom-Header": "value"
140
- }
141
- }
142
- });
139
+ 'X-Custom-Header': 'value',
140
+ },
141
+ },
142
+ })
143
143
  ```
144
144
 
145
145
  ### Dynamic model selection
146
146
 
147
147
  ```typescript
148
148
  const agent = new Agent({
149
- id: "dynamic-agent",
150
- name: "Dynamic Agent",
149
+ id: 'dynamic-agent',
150
+ name: 'Dynamic Agent',
151
151
  model: ({ requestContext }) => {
152
- const useAdvanced = requestContext.task === "complex";
153
- return useAdvanced
154
- ? "alibaba-cn/tongyi-intent-detect-v3"
155
- : "alibaba-cn/MiniMax-M2.5";
156
- }
157
- });
152
+ const useAdvanced = requestContext.task === 'complex'
153
+ return useAdvanced ? 'alibaba-cn/tongyi-intent-detect-v3' : 'alibaba-cn/MiniMax-M2.5'
154
+ },
155
+ })
158
156
  ```
@@ -11,22 +11,22 @@ ALIBABA_TOKEN_PLAN_API_KEY=your-api-key
11
11
  ```
12
12
 
13
13
  ```typescript
14
- import { Agent } from "@mastra/core/agent";
14
+ import { Agent } from '@mastra/core/agent'
15
15
 
16
16
  const agent = new Agent({
17
- id: "my-agent",
18
- name: "My Agent",
19
- instructions: "You are a helpful assistant",
20
- model: "alibaba-token-plan-cn/MiniMax-M2.5"
21
- });
17
+ id: 'my-agent',
18
+ name: 'My Agent',
19
+ instructions: 'You are a helpful assistant',
20
+ model: 'alibaba-token-plan-cn/MiniMax-M2.5',
21
+ })
22
22
 
23
23
  // Generate a response
24
- const response = await agent.generate("Hello!");
24
+ const response = await agent.generate('Hello!')
25
25
 
26
26
  // Stream a response
27
- const stream = await agent.stream("Tell me a story");
27
+ const stream = await agent.stream('Tell me a story')
28
28
  for await (const chunk of stream) {
29
- console.log(chunk);
29
+ console.log(chunk)
30
30
  }
31
31
  ```
32
32
 
@@ -67,30 +67,30 @@ for await (const chunk of stream) {
67
67
 
68
68
  ```typescript
69
69
  const agent = new Agent({
70
- id: "custom-agent",
71
- name: "custom-agent",
70
+ id: 'custom-agent',
71
+ name: 'custom-agent',
72
72
  model: {
73
- url: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
74
- id: "alibaba-token-plan-cn/MiniMax-M2.5",
73
+ url: 'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1',
74
+ id: 'alibaba-token-plan-cn/MiniMax-M2.5',
75
75
  apiKey: process.env.ALIBABA_TOKEN_PLAN_API_KEY,
76
76
  headers: {
77
- "X-Custom-Header": "value"
78
- }
79
- }
80
- });
77
+ 'X-Custom-Header': 'value',
78
+ },
79
+ },
80
+ })
81
81
  ```
82
82
 
83
83
  ### Dynamic model selection
84
84
 
85
85
  ```typescript
86
86
  const agent = new Agent({
87
- id: "dynamic-agent",
88
- name: "Dynamic Agent",
87
+ id: 'dynamic-agent',
88
+ name: 'Dynamic Agent',
89
89
  model: ({ requestContext }) => {
90
- const useAdvanced = requestContext.task === "complex";
90
+ const useAdvanced = requestContext.task === 'complex'
91
91
  return useAdvanced
92
- ? "alibaba-token-plan-cn/wan2.7-image-pro"
93
- : "alibaba-token-plan-cn/MiniMax-M2.5";
94
- }
95
- });
92
+ ? 'alibaba-token-plan-cn/wan2.7-image-pro'
93
+ : 'alibaba-token-plan-cn/MiniMax-M2.5'
94
+ },
95
+ })
96
96
  ```
@@ -11,22 +11,22 @@ ALIBABA_TOKEN_PLAN_API_KEY=your-api-key
11
11
  ```
12
12
 
13
13
  ```typescript
14
- import { Agent } from "@mastra/core/agent";
14
+ import { Agent } from '@mastra/core/agent'
15
15
 
16
16
  const agent = new Agent({
17
- id: "my-agent",
18
- name: "My Agent",
19
- instructions: "You are a helpful assistant",
20
- model: "alibaba-token-plan/MiniMax-M2.5"
21
- });
17
+ id: 'my-agent',
18
+ name: 'My Agent',
19
+ instructions: 'You are a helpful assistant',
20
+ model: 'alibaba-token-plan/MiniMax-M2.5',
21
+ })
22
22
 
23
23
  // Generate a response
24
- const response = await agent.generate("Hello!");
24
+ const response = await agent.generate('Hello!')
25
25
 
26
26
  // Stream a response
27
- const stream = await agent.stream("Tell me a story");
27
+ const stream = await agent.stream('Tell me a story')
28
28
  for await (const chunk of stream) {
29
- console.log(chunk);
29
+ console.log(chunk)
30
30
  }
31
31
  ```
32
32
 
@@ -67,30 +67,28 @@ for await (const chunk of stream) {
67
67
 
68
68
  ```typescript
69
69
  const agent = new Agent({
70
- id: "custom-agent",
71
- name: "custom-agent",
70
+ id: 'custom-agent',
71
+ name: 'custom-agent',
72
72
  model: {
73
- url: "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
74
- id: "alibaba-token-plan/MiniMax-M2.5",
73
+ url: 'https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1',
74
+ id: 'alibaba-token-plan/MiniMax-M2.5',
75
75
  apiKey: process.env.ALIBABA_TOKEN_PLAN_API_KEY,
76
76
  headers: {
77
- "X-Custom-Header": "value"
78
- }
79
- }
80
- });
77
+ 'X-Custom-Header': 'value',
78
+ },
79
+ },
80
+ })
81
81
  ```
82
82
 
83
83
  ### Dynamic model selection
84
84
 
85
85
  ```typescript
86
86
  const agent = new Agent({
87
- id: "dynamic-agent",
88
- name: "Dynamic Agent",
87
+ id: 'dynamic-agent',
88
+ name: 'Dynamic Agent',
89
89
  model: ({ requestContext }) => {
90
- const useAdvanced = requestContext.task === "complex";
91
- return useAdvanced
92
- ? "alibaba-token-plan/wan2.7-image-pro"
93
- : "alibaba-token-plan/MiniMax-M2.5";
94
- }
95
- });
90
+ const useAdvanced = requestContext.task === 'complex'
91
+ return useAdvanced ? 'alibaba-token-plan/wan2.7-image-pro' : 'alibaba-token-plan/MiniMax-M2.5'
92
+ },
93
+ })
96
94
  ```
@@ -11,22 +11,22 @@ DASHSCOPE_API_KEY=your-api-key
11
11
  ```
12
12
 
13
13
  ```typescript
14
- import { Agent } from "@mastra/core/agent";
14
+ import { Agent } from '@mastra/core/agent'
15
15
 
16
16
  const agent = new Agent({
17
- id: "my-agent",
18
- name: "My Agent",
19
- instructions: "You are a helpful assistant",
20
- model: "alibaba/qvq-max"
21
- });
17
+ id: 'my-agent',
18
+ name: 'My Agent',
19
+ instructions: 'You are a helpful assistant',
20
+ model: 'alibaba/qvq-max',
21
+ })
22
22
 
23
23
  // Generate a response
24
- const response = await agent.generate("Hello!");
24
+ const response = await agent.generate('Hello!')
25
25
 
26
26
  // Stream a response
27
- const stream = await agent.stream("Tell me a story");
27
+ const stream = await agent.stream('Tell me a story')
28
28
  for await (const chunk of stream) {
29
- console.log(chunk);
29
+ console.log(chunk)
30
30
  }
31
31
  ```
32
32
 
@@ -95,30 +95,28 @@ for await (const chunk of stream) {
95
95
 
96
96
  ```typescript
97
97
  const agent = new Agent({
98
- id: "custom-agent",
99
- name: "custom-agent",
98
+ id: 'custom-agent',
99
+ name: 'custom-agent',
100
100
  model: {
101
- url: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
102
- id: "alibaba/qvq-max",
101
+ url: 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1',
102
+ id: 'alibaba/qvq-max',
103
103
  apiKey: process.env.DASHSCOPE_API_KEY,
104
104
  headers: {
105
- "X-Custom-Header": "value"
106
- }
107
- }
108
- });
105
+ 'X-Custom-Header': 'value',
106
+ },
107
+ },
108
+ })
109
109
  ```
110
110
 
111
111
  ### Dynamic model selection
112
112
 
113
113
  ```typescript
114
114
  const agent = new Agent({
115
- id: "dynamic-agent",
116
- name: "Dynamic Agent",
115
+ id: 'dynamic-agent',
116
+ name: 'Dynamic Agent',
117
117
  model: ({ requestContext }) => {
118
- const useAdvanced = requestContext.task === "complex";
119
- return useAdvanced
120
- ? "alibaba/qwq-plus"
121
- : "alibaba/qvq-max";
122
- }
123
- });
118
+ const useAdvanced = requestContext.task === 'complex'
119
+ return useAdvanced ? 'alibaba/qwq-plus' : 'alibaba/qvq-max'
120
+ },
121
+ })
124
122
  ```