@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.
- package/.docs/docs/agents/processors.md +25 -1
- package/.docs/docs/workflows/agents-and-tools.md +29 -0
- package/.docs/docs/workflows/stored-workflows.md +146 -0
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/neon.md +71 -0
- package/.docs/models/gateways/netlify.md +6 -6
- package/.docs/models/gateways/openrouter.md +6 -6
- package/.docs/models/gateways/vercel.md +6 -6
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +95 -96
- package/.docs/models/providers/alibaba-cn.md +23 -25
- package/.docs/models/providers/alibaba-token-plan-cn.md +24 -24
- package/.docs/models/providers/alibaba-token-plan.md +23 -25
- package/.docs/models/providers/alibaba.md +23 -25
- package/.docs/models/providers/ambient.md +23 -25
- package/.docs/models/providers/baseten.md +23 -25
- package/.docs/models/providers/chutes.md +23 -25
- package/.docs/models/providers/cortecs.md +23 -25
- package/.docs/models/providers/crof.md +23 -25
- package/.docs/models/providers/crossmodel.md +23 -25
- package/.docs/models/providers/deepinfra.md +22 -24
- package/.docs/models/providers/digitalocean.md +23 -25
- package/.docs/models/providers/empiriolabs.md +23 -25
- package/.docs/models/providers/fireworks-ai.md +24 -24
- package/.docs/models/providers/greenpt.md +23 -25
- package/.docs/models/providers/groq.md +23 -25
- package/.docs/models/providers/huggingface.md +23 -25
- package/.docs/models/providers/hyper.md +23 -25
- package/.docs/models/providers/impossibl.md +23 -25
- package/.docs/models/providers/infomaniak.md +24 -24
- package/.docs/models/providers/kilo.md +23 -25
- package/.docs/models/providers/llmgateway.md +23 -25
- package/.docs/models/providers/mistral.md +23 -25
- package/.docs/models/providers/modal.md +23 -25
- package/.docs/models/providers/modelis.md +23 -25
- package/.docs/models/providers/nano-gpt.md +23 -25
- package/.docs/models/providers/neuralwatt.md +23 -25
- package/.docs/models/providers/ofox.md +23 -25
- package/.docs/models/providers/ollama-cloud.md +23 -25
- package/.docs/models/providers/opencode-go.md +23 -25
- package/.docs/models/providers/opencode.md +23 -25
- package/.docs/models/providers/pioneer.md +23 -25
- package/.docs/models/providers/requesty.md +23 -25
- package/.docs/models/providers/routing-run.md +23 -25
- package/.docs/models/providers/scx.md +23 -25
- package/.docs/models/providers/tensorx.md +23 -25
- package/.docs/models/providers/togetherai.md +22 -24
- package/.docs/models/providers/umans-ai-coding-plan.md +24 -24
- package/.docs/models/providers/umans-ai.md +23 -25
- package/.docs/models/providers/wandb.md +23 -25
- package/.docs/models/providers/xai.md +26 -28
- package/.docs/models/providers/zai-coding-plan.md +23 -25
- package/.docs/models/providers/zhipuai-coding-plan.md +23 -25
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/client-js/workflows.md +92 -0
- package/.docs/reference/core/addStoredWorkflow.md +62 -0
- package/.docs/reference/core/addStoredWorkflows.md +40 -0
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/processors/processor-interface.md +121 -10
- package/.docs/reference/server/routes.md +13 -0
- package/.docs/reference/storage/overview.md +9 -8
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/workflows/stored-workflow-definition.md +292 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +62 -0
- package/.docs/reference/workflows/workflow-methods/tool.md +43 -0
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
- package/.docs/models/providers/neon.md +0 -109
|
@@ -11,22 +11,22 @@ OLLAMA_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'ollama-cloud/deepseek-v4-flash',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -63,30 +63,28 @@ for await (const chunk of stream) {
|
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
65
|
const agent = new Agent({
|
|
66
|
-
id:
|
|
67
|
-
name:
|
|
66
|
+
id: 'custom-agent',
|
|
67
|
+
name: 'custom-agent',
|
|
68
68
|
model: {
|
|
69
|
-
url:
|
|
70
|
-
id:
|
|
69
|
+
url: 'https://ollama.com/v1',
|
|
70
|
+
id: 'ollama-cloud/deepseek-v4-flash',
|
|
71
71
|
apiKey: process.env.OLLAMA_API_KEY,
|
|
72
72
|
headers: {
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
})
|
|
73
|
+
'X-Custom-Header': 'value',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Dynamic model selection
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
82
|
const agent = new Agent({
|
|
83
|
-
id:
|
|
84
|
-
name:
|
|
83
|
+
id: 'dynamic-agent',
|
|
84
|
+
name: 'Dynamic Agent',
|
|
85
85
|
model: ({ requestContext }) => {
|
|
86
|
-
const useAdvanced = requestContext.task ===
|
|
87
|
-
return useAdvanced
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
});
|
|
86
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
87
|
+
return useAdvanced ? 'ollama-cloud/qwen3.5:397b' : 'ollama-cloud/deepseek-v4-flash'
|
|
88
|
+
},
|
|
89
|
+
})
|
|
92
90
|
```
|
|
@@ -11,22 +11,22 @@ OPENCODE_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'opencode-go/deepseek-v4-flash',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -61,30 +61,28 @@ for await (const chunk of stream) {
|
|
|
61
61
|
|
|
62
62
|
```typescript
|
|
63
63
|
const agent = new Agent({
|
|
64
|
-
id:
|
|
65
|
-
name:
|
|
64
|
+
id: 'custom-agent',
|
|
65
|
+
name: 'custom-agent',
|
|
66
66
|
model: {
|
|
67
|
-
url:
|
|
68
|
-
id:
|
|
67
|
+
url: 'https://opencode.ai/zen/go/v1',
|
|
68
|
+
id: 'opencode-go/deepseek-v4-flash',
|
|
69
69
|
apiKey: process.env.OPENCODE_API_KEY,
|
|
70
70
|
headers: {
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
})
|
|
71
|
+
'X-Custom-Header': 'value',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
### Dynamic model selection
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
80
|
const agent = new Agent({
|
|
81
|
-
id:
|
|
82
|
-
name:
|
|
81
|
+
id: 'dynamic-agent',
|
|
82
|
+
name: 'Dynamic Agent',
|
|
83
83
|
model: ({ requestContext }) => {
|
|
84
|
-
const useAdvanced = requestContext.task ===
|
|
85
|
-
return useAdvanced
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
});
|
|
84
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
85
|
+
return useAdvanced ? 'opencode-go/qwen3.8-max' : 'opencode-go/deepseek-v4-flash'
|
|
86
|
+
},
|
|
87
|
+
})
|
|
90
88
|
```
|
|
@@ -11,22 +11,22 @@ OPENCODE_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'opencode/big-pickle',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -104,30 +104,28 @@ for await (const chunk of stream) {
|
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
106
|
const agent = new Agent({
|
|
107
|
-
id:
|
|
108
|
-
name:
|
|
107
|
+
id: 'custom-agent',
|
|
108
|
+
name: 'custom-agent',
|
|
109
109
|
model: {
|
|
110
|
-
url:
|
|
111
|
-
id:
|
|
110
|
+
url: 'https://opencode.ai/zen/v1',
|
|
111
|
+
id: 'opencode/big-pickle',
|
|
112
112
|
apiKey: process.env.OPENCODE_API_KEY,
|
|
113
113
|
headers: {
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
})
|
|
114
|
+
'X-Custom-Header': 'value',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### Dynamic model selection
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
const agent = new Agent({
|
|
124
|
-
id:
|
|
125
|
-
name:
|
|
124
|
+
id: 'dynamic-agent',
|
|
125
|
+
name: 'Dynamic Agent',
|
|
126
126
|
model: ({ requestContext }) => {
|
|
127
|
-
const useAdvanced = requestContext.task ===
|
|
128
|
-
return useAdvanced
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
});
|
|
127
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
128
|
+
return useAdvanced ? 'opencode/trinity-large-preview-free' : 'opencode/big-pickle'
|
|
129
|
+
},
|
|
130
|
+
})
|
|
133
131
|
```
|
|
@@ -11,22 +11,22 @@ PIONEER_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'pioneer/HuggingFaceTB/SmolLM3-3B-Base',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -119,30 +119,28 @@ for await (const chunk of stream) {
|
|
|
119
119
|
|
|
120
120
|
```typescript
|
|
121
121
|
const agent = new Agent({
|
|
122
|
-
id:
|
|
123
|
-
name:
|
|
122
|
+
id: 'custom-agent',
|
|
123
|
+
name: 'custom-agent',
|
|
124
124
|
model: {
|
|
125
|
-
url:
|
|
126
|
-
id:
|
|
125
|
+
url: 'https://api.pioneer.ai/v1',
|
|
126
|
+
id: 'pioneer/HuggingFaceTB/SmolLM3-3B-Base',
|
|
127
127
|
apiKey: process.env.PIONEER_API_KEY,
|
|
128
128
|
headers: {
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})
|
|
129
|
+
'X-Custom-Header': 'value',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### Dynamic model selection
|
|
136
136
|
|
|
137
137
|
```typescript
|
|
138
138
|
const agent = new Agent({
|
|
139
|
-
id:
|
|
140
|
-
name:
|
|
139
|
+
id: 'dynamic-agent',
|
|
140
|
+
name: 'Dynamic Agent',
|
|
141
141
|
model: ({ requestContext }) => {
|
|
142
|
-
const useAdvanced = requestContext.task ===
|
|
143
|
-
return useAdvanced
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
});
|
|
142
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
143
|
+
return useAdvanced ? 'pioneer/zai-org/GLM-5.2' : 'pioneer/HuggingFaceTB/SmolLM3-3B-Base'
|
|
144
|
+
},
|
|
145
|
+
})
|
|
148
146
|
```
|
|
@@ -11,22 +11,22 @@ REQUESTY_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'requesty/claude-fable-5',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -90,30 +90,28 @@ for await (const chunk of stream) {
|
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
const agent = new Agent({
|
|
93
|
-
id:
|
|
94
|
-
name:
|
|
93
|
+
id: 'custom-agent',
|
|
94
|
+
name: 'custom-agent',
|
|
95
95
|
model: {
|
|
96
|
-
url:
|
|
97
|
-
id:
|
|
96
|
+
url: 'https://router.requesty.ai/v1',
|
|
97
|
+
id: 'requesty/claude-fable-5',
|
|
98
98
|
apiKey: process.env.REQUESTY_API_KEY,
|
|
99
99
|
headers: {
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})
|
|
100
|
+
'X-Custom-Header': 'value',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
### Dynamic model selection
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
109
|
const agent = new Agent({
|
|
110
|
-
id:
|
|
111
|
-
name:
|
|
110
|
+
id: 'dynamic-agent',
|
|
111
|
+
name: 'Dynamic Agent',
|
|
112
112
|
model: ({ requestContext }) => {
|
|
113
|
-
const useAdvanced = requestContext.task ===
|
|
114
|
-
return useAdvanced
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
});
|
|
113
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
114
|
+
return useAdvanced ? 'requesty/o4-mini@eu' : 'requesty/claude-fable-5'
|
|
115
|
+
},
|
|
116
|
+
})
|
|
119
117
|
```
|
|
@@ -11,22 +11,22 @@ ROUTING_RUN_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'routing-run/claude-opus-4-8',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -58,30 +58,28 @@ for await (const chunk of stream) {
|
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
60
|
const agent = new Agent({
|
|
61
|
-
id:
|
|
62
|
-
name:
|
|
61
|
+
id: 'custom-agent',
|
|
62
|
+
name: 'custom-agent',
|
|
63
63
|
model: {
|
|
64
|
-
url:
|
|
65
|
-
id:
|
|
64
|
+
url: 'https://api.routing.run/v1',
|
|
65
|
+
id: 'routing-run/claude-opus-4-8',
|
|
66
66
|
apiKey: process.env.ROUTING_RUN_API_KEY,
|
|
67
67
|
headers: {
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})
|
|
68
|
+
'X-Custom-Header': 'value',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
### Dynamic model selection
|
|
75
75
|
|
|
76
76
|
```typescript
|
|
77
77
|
const agent = new Agent({
|
|
78
|
-
id:
|
|
79
|
-
name:
|
|
78
|
+
id: 'dynamic-agent',
|
|
79
|
+
name: 'Dynamic Agent',
|
|
80
80
|
model: ({ requestContext }) => {
|
|
81
|
-
const useAdvanced = requestContext.task ===
|
|
82
|
-
return useAdvanced
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
});
|
|
81
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
82
|
+
return useAdvanced ? 'routing-run/qwen3.5-9b' : 'routing-run/claude-opus-4-8'
|
|
83
|
+
},
|
|
84
|
+
})
|
|
87
85
|
```
|
|
@@ -11,22 +11,22 @@ SCX_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'scx/MiniMax-M2.7',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -45,30 +45,28 @@ for await (const chunk of stream) {
|
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
47
|
const agent = new Agent({
|
|
48
|
-
id:
|
|
49
|
-
name:
|
|
48
|
+
id: 'custom-agent',
|
|
49
|
+
name: 'custom-agent',
|
|
50
50
|
model: {
|
|
51
|
-
url:
|
|
52
|
-
id:
|
|
51
|
+
url: 'https://api.scx.ai/v1',
|
|
52
|
+
id: 'scx/MiniMax-M2.7',
|
|
53
53
|
apiKey: process.env.SCX_API_KEY,
|
|
54
54
|
headers: {
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
})
|
|
55
|
+
'X-Custom-Header': 'value',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### Dynamic model selection
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
const agent = new Agent({
|
|
65
|
-
id:
|
|
66
|
-
name:
|
|
65
|
+
id: 'dynamic-agent',
|
|
66
|
+
name: 'Dynamic Agent',
|
|
67
67
|
model: ({ requestContext }) => {
|
|
68
|
-
const useAdvanced = requestContext.task ===
|
|
69
|
-
return useAdvanced
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
});
|
|
68
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
69
|
+
return useAdvanced ? 'scx/gpt-oss-120b' : 'scx/MiniMax-M2.7'
|
|
70
|
+
},
|
|
71
|
+
})
|
|
74
72
|
```
|
|
@@ -11,22 +11,22 @@ TENSORX_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'tensorx/deepseek/deepseek-chat-v3.1',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
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
|
|
|
@@ -68,30 +68,28 @@ for await (const chunk of stream) {
|
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
70
|
const agent = new Agent({
|
|
71
|
-
id:
|
|
72
|
-
name:
|
|
71
|
+
id: 'custom-agent',
|
|
72
|
+
name: 'custom-agent',
|
|
73
73
|
model: {
|
|
74
|
-
url:
|
|
75
|
-
id:
|
|
74
|
+
url: 'https://api.tensorx.ai/v1',
|
|
75
|
+
id: 'tensorx/deepseek/deepseek-chat-v3.1',
|
|
76
76
|
apiKey: process.env.TENSORX_API_KEY,
|
|
77
77
|
headers: {
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
})
|
|
78
|
+
'X-Custom-Header': 'value',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
### Dynamic model selection
|
|
85
85
|
|
|
86
86
|
```typescript
|
|
87
87
|
const agent = new Agent({
|
|
88
|
-
id:
|
|
89
|
-
name:
|
|
88
|
+
id: 'dynamic-agent',
|
|
89
|
+
name: 'Dynamic Agent',
|
|
90
90
|
model: ({ requestContext }) => {
|
|
91
|
-
const useAdvanced = requestContext.task ===
|
|
92
|
-
return useAdvanced
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
});
|
|
91
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
92
|
+
return useAdvanced ? 'tensorx/z-ai/glm-5v-turbo' : 'tensorx/deepseek/deepseek-chat-v3.1'
|
|
93
|
+
},
|
|
94
|
+
})
|
|
97
95
|
```
|