@mastra/mcp-docs-server 1.2.13-alpha.4 → 1.2.13-alpha.8
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/agent-approval.md +2 -2
- package/.docs/docs/deployment/workers.md +14 -14
- package/.docs/docs/evals/datasets/running-experiments.md +1 -1
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/long-running-agents/durable-agents.md +2 -2
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/{workspace.md → workspaces.md} +48 -7
- package/.docs/docs/memory/observational-memory.md +30 -13
- package/.docs/docs/memory/overview.md +14 -0
- package/.docs/docs/server/auth/workers.md +7 -5
- package/.docs/docs/server/mastra-client.md +60 -0
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/what-is-mastra.md +10 -10
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +1 -0
- package/.docs/guides/deployment/kubernetes.md +2 -0
- package/.docs/guides/deployment/mastra-workers.md +350 -6
- package/.docs/guides/deployment/vercel.md +2 -0
- package/.docs/models/gateways/openrouter.md +1 -4
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/hyper.md +2 -1
- package/.docs/models/providers/minimax.md +1 -1
- package/.docs/models/providers/openai.md +2 -2
- package/.docs/models/providers/opencode-go.md +2 -1
- package/.docs/models/providers/opencode.md +1 -1
- package/.docs/models/providers/perplexity-agent.md +3 -1
- package/.docs/reference/agents/durable-agent.md +12 -1
- package/.docs/reference/cli/mastra.md +30 -14
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/evals/summarization.md +203 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/observational-memory.md +74 -24
- package/.docs/reference/observability/tracing/interfaces.md +3 -0
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/vectors/mongodb.md +13 -13
- package/.docs/reference/workers/overview.md +10 -8
- package/.docs/reference/workspace/platform-filesystem.md +5 -2
- package/.docs/reference/workspace/platform-sandbox.md +80 -4
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Deploy Mastra workers
|
|
4
4
|
|
|
5
|
-
Run [Mastra workers](https://mastra.ai/docs/deployment/workers) as separate processes so you can scale orchestration, scheduling, and background tasks independently from the API. This guide walks through a fully split deployment using Docker Compose.
|
|
5
|
+
Run [Mastra workers](https://mastra.ai/docs/deployment/workers) as separate processes so you can scale orchestration, scheduling, and background tasks independently from the API. This guide walks through a fully split deployment using Docker Compose or Kubernetes.
|
|
6
6
|
|
|
7
7
|
> **Info:** This guide covers splitting workers into their own containers. If you only need workers to run in-process alongside the API, see [Workers](https://mastra.ai/docs/deployment/workers). No extra setup is required.
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Run [Mastra workers](https://mastra.ai/docs/deployment/workers) as separate proc
|
|
|
11
11
|
You'll need:
|
|
12
12
|
|
|
13
13
|
- A [Mastra application](https://mastra.ai/guides/getting-started/quickstart)
|
|
14
|
-
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/)
|
|
14
|
+
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/), or a [Kubernetes](https://kubernetes.io/docs/setup/) cluster with [`kubectl`](https://kubernetes.io/docs/tasks/tools/)
|
|
15
15
|
- A distributed PubSub backend: [Redis](https://redis.io/) for [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), or a [Google Cloud](https://cloud.google.com/) project for [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)
|
|
16
16
|
- A shared database reachable from every container. See [supported storage backends](https://mastra.ai/reference/workers/overview) for the full list.
|
|
17
17
|
|
|
@@ -83,9 +83,13 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
83
83
|
CMD ["node", "index.mjs"]
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
3.
|
|
86
|
+
3. Define the fully split topology. The setup runs six services: a database, a PubSub backend, the API server, and three workers. Each worker runs the same image with a different `MASTRA_WORKERS` value to control which worker starts.
|
|
87
87
|
|
|
88
|
-
The API
|
|
88
|
+
The API sets `MASTRA_WORKERS: "false"` to disable all event processing. The orchestration worker sets `MASTRA_STEP_EXECUTION_URL` to point step execution requests at the API's internal URL. See [step execution URL](#step-execution-url) for details.
|
|
89
|
+
|
|
90
|
+
All services share a `MASTRA_WORKER_AUTH_TOKEN`. Workers include this token in requests to the API so the API can verify the caller is a trusted internal service. See [worker authentication](https://mastra.ai/docs/server/auth/workers) for details.
|
|
91
|
+
|
|
92
|
+
**Docker Compose**:
|
|
89
93
|
|
|
90
94
|
```yaml
|
|
91
95
|
services:
|
|
@@ -123,6 +127,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
123
127
|
DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
|
|
124
128
|
REDIS_URL: redis://redis:6379
|
|
125
129
|
MASTRA_WORKERS: 'false'
|
|
130
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
126
131
|
depends_on:
|
|
127
132
|
postgres:
|
|
128
133
|
condition: service_healthy
|
|
@@ -141,6 +146,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
141
146
|
REDIS_URL: redis://redis:6379
|
|
142
147
|
MASTRA_WORKERS: orchestration
|
|
143
148
|
MASTRA_STEP_EXECUTION_URL: http://api:4111/api
|
|
149
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
144
150
|
depends_on:
|
|
145
151
|
api:
|
|
146
152
|
condition: service_healthy
|
|
@@ -151,6 +157,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
151
157
|
DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
|
|
152
158
|
REDIS_URL: redis://redis:6379
|
|
153
159
|
MASTRA_WORKERS: scheduler
|
|
160
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
154
161
|
depends_on:
|
|
155
162
|
api:
|
|
156
163
|
condition: service_healthy
|
|
@@ -161,6 +168,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
161
168
|
DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
|
|
162
169
|
REDIS_URL: redis://redis:6379
|
|
163
170
|
MASTRA_WORKERS: backgroundTasks
|
|
171
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
164
172
|
depends_on:
|
|
165
173
|
api:
|
|
166
174
|
condition: service_healthy
|
|
@@ -173,11 +181,296 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
173
181
|
|
|
174
182
|
```bash
|
|
175
183
|
POSTGRES_PASSWORD=your-secure-password
|
|
184
|
+
MASTRA_WORKER_AUTH_TOKEN=your-shared-secret-token
|
|
176
185
|
```
|
|
177
186
|
|
|
178
187
|
> **Note:** Remember to set any other environment variables your application needs (e.g., your [model provider](https://mastra.ai/models/providers) API key).
|
|
179
188
|
|
|
180
|
-
|
|
189
|
+
**Kubernetes**:
|
|
190
|
+
|
|
191
|
+
Create a namespace and a Secret with your connection strings:
|
|
192
|
+
|
|
193
|
+
```yaml
|
|
194
|
+
apiVersion: v1
|
|
195
|
+
kind: Namespace
|
|
196
|
+
metadata:
|
|
197
|
+
name: mastra-workers
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
kubectl apply -f k8s/namespace.yaml
|
|
202
|
+
kubectl create secret generic mastra-secrets -n mastra-workers \
|
|
203
|
+
--from-literal=POSTGRES_PASSWORD='your-password' \
|
|
204
|
+
--from-literal=DATABASE_URL='postgresql://mastra:your-password@postgres:5432/mastra' \
|
|
205
|
+
--from-literal=REDIS_URL='redis://redis:6379' \
|
|
206
|
+
--from-literal=MASTRA_WORKER_AUTH_TOKEN='your-shared-token'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
> **Note:** Add any other environment variables your application needs (e.g., your [model provider](https://mastra.ai/models/providers) API key) to the Secret or as additional `--from-literal` entries.
|
|
210
|
+
|
|
211
|
+
Build and push the Docker image to a registry your cluster can pull from:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
docker build -t your-registry/mastra-workers:latest ./app
|
|
215
|
+
docker push your-registry/mastra-workers:latest
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Apply Deployments and Services for the database, PubSub backend, API, and three workers. The example below uses in-cluster Postgres and Redis. In production, use managed services (e.g., Amazon RDS, Cloud SQL, ElastiCache, Memorystore).
|
|
219
|
+
|
|
220
|
+
```yaml
|
|
221
|
+
apiVersion: apps/v1
|
|
222
|
+
kind: Deployment
|
|
223
|
+
metadata:
|
|
224
|
+
name: postgres
|
|
225
|
+
namespace: mastra-workers
|
|
226
|
+
spec:
|
|
227
|
+
replicas: 1
|
|
228
|
+
selector:
|
|
229
|
+
matchLabels:
|
|
230
|
+
app: postgres
|
|
231
|
+
template:
|
|
232
|
+
metadata:
|
|
233
|
+
labels:
|
|
234
|
+
app: postgres
|
|
235
|
+
spec:
|
|
236
|
+
containers:
|
|
237
|
+
- name: postgres
|
|
238
|
+
image: postgres:16-alpine
|
|
239
|
+
ports:
|
|
240
|
+
- containerPort: 5432
|
|
241
|
+
env:
|
|
242
|
+
- name: POSTGRES_USER
|
|
243
|
+
value: mastra
|
|
244
|
+
- name: POSTGRES_PASSWORD
|
|
245
|
+
valueFrom:
|
|
246
|
+
secretKeyRef:
|
|
247
|
+
name: mastra-secrets
|
|
248
|
+
key: POSTGRES_PASSWORD
|
|
249
|
+
- name: POSTGRES_DB
|
|
250
|
+
value: mastra
|
|
251
|
+
volumeMounts:
|
|
252
|
+
- name: pgdata
|
|
253
|
+
mountPath: /var/lib/postgresql/data
|
|
254
|
+
volumes:
|
|
255
|
+
- name: pgdata
|
|
256
|
+
emptyDir: {}
|
|
257
|
+
---
|
|
258
|
+
apiVersion: v1
|
|
259
|
+
kind: Service
|
|
260
|
+
metadata:
|
|
261
|
+
name: postgres
|
|
262
|
+
namespace: mastra-workers
|
|
263
|
+
spec:
|
|
264
|
+
selector:
|
|
265
|
+
app: postgres
|
|
266
|
+
ports:
|
|
267
|
+
- port: 5432
|
|
268
|
+
targetPort: 5432
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
> **Caution:** The Postgres example above uses `emptyDir` for storage, which means data is lost when the pod restarts. In production, replace it with a `PersistentVolumeClaim` or use a managed database service.
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
apiVersion: apps/v1
|
|
275
|
+
kind: Deployment
|
|
276
|
+
metadata:
|
|
277
|
+
name: redis
|
|
278
|
+
namespace: mastra-workers
|
|
279
|
+
spec:
|
|
280
|
+
replicas: 1
|
|
281
|
+
selector:
|
|
282
|
+
matchLabels:
|
|
283
|
+
app: redis
|
|
284
|
+
template:
|
|
285
|
+
metadata:
|
|
286
|
+
labels:
|
|
287
|
+
app: redis
|
|
288
|
+
spec:
|
|
289
|
+
containers:
|
|
290
|
+
- name: redis
|
|
291
|
+
image: redis:7-alpine
|
|
292
|
+
args: ['--appendonly', 'yes']
|
|
293
|
+
ports:
|
|
294
|
+
- containerPort: 6379
|
|
295
|
+
---
|
|
296
|
+
apiVersion: v1
|
|
297
|
+
kind: Service
|
|
298
|
+
metadata:
|
|
299
|
+
name: redis
|
|
300
|
+
namespace: mastra-workers
|
|
301
|
+
spec:
|
|
302
|
+
selector:
|
|
303
|
+
app: redis
|
|
304
|
+
ports:
|
|
305
|
+
- port: 6379
|
|
306
|
+
targetPort: 6379
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
```yaml
|
|
310
|
+
apiVersion: apps/v1
|
|
311
|
+
kind: Deployment
|
|
312
|
+
metadata:
|
|
313
|
+
name: api
|
|
314
|
+
namespace: mastra-workers
|
|
315
|
+
spec:
|
|
316
|
+
replicas: 1
|
|
317
|
+
selector:
|
|
318
|
+
matchLabels:
|
|
319
|
+
app: api
|
|
320
|
+
template:
|
|
321
|
+
metadata:
|
|
322
|
+
labels:
|
|
323
|
+
app: api
|
|
324
|
+
spec:
|
|
325
|
+
containers:
|
|
326
|
+
- name: api
|
|
327
|
+
image: your-registry/mastra-workers:latest
|
|
328
|
+
ports:
|
|
329
|
+
- containerPort: 4111
|
|
330
|
+
env:
|
|
331
|
+
- name: MASTRA_WORKERS
|
|
332
|
+
value: 'false'
|
|
333
|
+
envFrom:
|
|
334
|
+
- secretRef:
|
|
335
|
+
name: mastra-secrets
|
|
336
|
+
readinessProbe:
|
|
337
|
+
httpGet:
|
|
338
|
+
path: /api/agents
|
|
339
|
+
port: 4111
|
|
340
|
+
initialDelaySeconds: 10
|
|
341
|
+
periodSeconds: 5
|
|
342
|
+
livenessProbe:
|
|
343
|
+
httpGet:
|
|
344
|
+
path: /api/agents
|
|
345
|
+
port: 4111
|
|
346
|
+
initialDelaySeconds: 15
|
|
347
|
+
periodSeconds: 10
|
|
348
|
+
resources:
|
|
349
|
+
requests:
|
|
350
|
+
cpu: 500m
|
|
351
|
+
memory: 512Mi
|
|
352
|
+
---
|
|
353
|
+
apiVersion: v1
|
|
354
|
+
kind: Service
|
|
355
|
+
metadata:
|
|
356
|
+
name: api
|
|
357
|
+
namespace: mastra-workers
|
|
358
|
+
spec:
|
|
359
|
+
selector:
|
|
360
|
+
app: api
|
|
361
|
+
ports:
|
|
362
|
+
- port: 4111
|
|
363
|
+
targetPort: 4111
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
```yaml
|
|
367
|
+
apiVersion: apps/v1
|
|
368
|
+
kind: Deployment
|
|
369
|
+
metadata:
|
|
370
|
+
name: orchestration-worker
|
|
371
|
+
namespace: mastra-workers
|
|
372
|
+
spec:
|
|
373
|
+
replicas: 1
|
|
374
|
+
selector:
|
|
375
|
+
matchLabels:
|
|
376
|
+
app: orchestration-worker
|
|
377
|
+
template:
|
|
378
|
+
metadata:
|
|
379
|
+
labels:
|
|
380
|
+
app: orchestration-worker
|
|
381
|
+
spec:
|
|
382
|
+
containers:
|
|
383
|
+
- name: worker
|
|
384
|
+
image: your-registry/mastra-workers:latest
|
|
385
|
+
env:
|
|
386
|
+
- name: MASTRA_WORKERS
|
|
387
|
+
value: orchestration
|
|
388
|
+
- name: MASTRA_STEP_EXECUTION_URL
|
|
389
|
+
value: http://api:4111/api
|
|
390
|
+
envFrom:
|
|
391
|
+
- secretRef:
|
|
392
|
+
name: mastra-secrets
|
|
393
|
+
resources:
|
|
394
|
+
requests:
|
|
395
|
+
cpu: 250m
|
|
396
|
+
memory: 256Mi
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
```yaml
|
|
400
|
+
apiVersion: apps/v1
|
|
401
|
+
kind: Deployment
|
|
402
|
+
metadata:
|
|
403
|
+
name: scheduler-worker
|
|
404
|
+
namespace: mastra-workers
|
|
405
|
+
spec:
|
|
406
|
+
replicas: 1
|
|
407
|
+
selector:
|
|
408
|
+
matchLabels:
|
|
409
|
+
app: scheduler-worker
|
|
410
|
+
template:
|
|
411
|
+
metadata:
|
|
412
|
+
labels:
|
|
413
|
+
app: scheduler-worker
|
|
414
|
+
spec:
|
|
415
|
+
containers:
|
|
416
|
+
- name: worker
|
|
417
|
+
image: your-registry/mastra-workers:latest
|
|
418
|
+
env:
|
|
419
|
+
- name: MASTRA_WORKERS
|
|
420
|
+
value: scheduler
|
|
421
|
+
envFrom:
|
|
422
|
+
- secretRef:
|
|
423
|
+
name: mastra-secrets
|
|
424
|
+
resources:
|
|
425
|
+
requests:
|
|
426
|
+
cpu: 250m
|
|
427
|
+
memory: 256Mi
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
```yaml
|
|
431
|
+
apiVersion: apps/v1
|
|
432
|
+
kind: Deployment
|
|
433
|
+
metadata:
|
|
434
|
+
name: background-task-worker
|
|
435
|
+
namespace: mastra-workers
|
|
436
|
+
spec:
|
|
437
|
+
replicas: 1
|
|
438
|
+
selector:
|
|
439
|
+
matchLabels:
|
|
440
|
+
app: background-task-worker
|
|
441
|
+
template:
|
|
442
|
+
metadata:
|
|
443
|
+
labels:
|
|
444
|
+
app: background-task-worker
|
|
445
|
+
spec:
|
|
446
|
+
containers:
|
|
447
|
+
- name: worker
|
|
448
|
+
image: your-registry/mastra-workers:latest
|
|
449
|
+
env:
|
|
450
|
+
- name: MASTRA_WORKERS
|
|
451
|
+
value: backgroundTasks
|
|
452
|
+
envFrom:
|
|
453
|
+
- secretRef:
|
|
454
|
+
name: mastra-secrets
|
|
455
|
+
resources:
|
|
456
|
+
requests:
|
|
457
|
+
cpu: 250m
|
|
458
|
+
memory: 256Mi
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Apply all manifests and wait for the API to become ready:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
kubectl apply -f k8s/
|
|
465
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=api --timeout=90s
|
|
466
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=orchestration-worker --timeout=60s
|
|
467
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=scheduler-worker --timeout=60s
|
|
468
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=background-task-worker --timeout=60s
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
4. Verify the stack is running and the API responds:
|
|
472
|
+
|
|
473
|
+
**Docker Compose**:
|
|
181
474
|
|
|
182
475
|
```bash
|
|
183
476
|
docker compose up -d
|
|
@@ -185,6 +478,21 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
185
478
|
curl http://localhost:4111/api/agents
|
|
186
479
|
```
|
|
187
480
|
|
|
481
|
+
**Kubernetes**:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
kubectl get pods -n mastra-workers
|
|
485
|
+
kubectl port-forward -n mastra-workers svc/api 4111:4111
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
In a separate terminal:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
curl http://localhost:4111/api/agents
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
A JSON list of your agents confirms the API and workers are running.
|
|
495
|
+
|
|
188
496
|
## Step execution URL
|
|
189
497
|
|
|
190
498
|
In a fully split deployment, the orchestration worker runs in a separate container from the API. When it processes a workflow event, it delegates step execution to the API over HTTP.
|
|
@@ -203,11 +511,46 @@ Without this variable, the orchestration worker attempts to execute steps in-pro
|
|
|
203
511
|
|
|
204
512
|
The orchestration and background task workers are safe to scale horizontally. PubSub consumer groups distribute events across instances, so each event is processed once:
|
|
205
513
|
|
|
514
|
+
**Docker Compose**:
|
|
515
|
+
|
|
206
516
|
```bash
|
|
207
517
|
docker compose up -d --scale orchestration-worker=3
|
|
208
518
|
docker compose up -d --scale background-task-worker=2
|
|
209
519
|
```
|
|
210
520
|
|
|
521
|
+
**Kubernetes**:
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
kubectl scale deployment/orchestration-worker -n mastra-workers --replicas=3
|
|
525
|
+
kubectl scale deployment/background-task-worker -n mastra-workers --replicas=2
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
For automatic scaling, add a HorizontalPodAutoscaler:
|
|
529
|
+
|
|
530
|
+
```yaml
|
|
531
|
+
apiVersion: autoscaling/v2
|
|
532
|
+
kind: HorizontalPodAutoscaler
|
|
533
|
+
metadata:
|
|
534
|
+
name: orchestration-worker
|
|
535
|
+
namespace: mastra-workers
|
|
536
|
+
spec:
|
|
537
|
+
scaleTargetRef:
|
|
538
|
+
apiVersion: apps/v1
|
|
539
|
+
kind: Deployment
|
|
540
|
+
name: orchestration-worker
|
|
541
|
+
minReplicas: 1
|
|
542
|
+
maxReplicas: 10
|
|
543
|
+
metrics:
|
|
544
|
+
- type: Resource
|
|
545
|
+
resource:
|
|
546
|
+
name: cpu
|
|
547
|
+
target:
|
|
548
|
+
type: Utilization
|
|
549
|
+
averageUtilization: 70
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
> **Note:** CPU-based autoscaling needs the [metrics-server](https://github.com/kubernetes-sigs/metrics-server) running in the cluster. Managed clusters like GKE, EKS, and AKS include it by default.
|
|
553
|
+
|
|
211
554
|
The API can also scale horizontally behind a load balancer.
|
|
212
555
|
|
|
213
556
|
**Don't scale the scheduler worker.** Run exactly one instance. Multiple schedulers polling the same storage fire duplicate events for the same schedule.
|
|
@@ -229,4 +572,5 @@ Workers recover from crashes because the distributed PubSub backend persists una
|
|
|
229
572
|
- [Workers reference](https://mastra.ai/reference/workers/overview): Configuration details for all worker types
|
|
230
573
|
- [CLI reference](https://mastra.ai/reference/cli/mastra): `mastra worker build` and `mastra worker start`
|
|
231
574
|
- [PubSub](https://mastra.ai/docs/server/pubsub): Event delivery backends
|
|
232
|
-
- [Deploy a Mastra server](https://mastra.ai/docs/deployment/mastra-server): Build output and server configuration
|
|
575
|
+
- [Deploy a Mastra server](https://mastra.ai/docs/deployment/mastra-server): Build output and server configuration
|
|
576
|
+
- [Deploy Mastra to Kubernetes](https://mastra.ai/guides/deployment/kubernetes): Multi-pod deployment with durable agents
|
|
@@ -86,6 +86,8 @@ export const mastra = new Mastra({
|
|
|
86
86
|
|
|
87
87
|
After deploying, Studio is available at the root URL (`https://<your-project>.vercel.app/`) and the API remains at `/api/*`. Studio automatically connects to the API on the same origin, so you don't need additional environment variables.
|
|
88
88
|
|
|
89
|
+
Studio serves its own pages from the CDN, and every other path goes to your server, so routes you add with [`registerApiRoute()`](https://mastra.ai/docs/server/custom-api-routes) stay reachable at their own paths. Avoid giving a custom route a path that Studio already uses (for example `/agents` or `/workflows`), since Studio claims those first.
|
|
90
|
+
|
|
89
91
|
> **Warning:** Once Studio is connected to your Mastra server, it has full access to your agents, workflows, and tools. Be sure to secure it properly in production (e.g. behind authentication, VPN, etc.) to prevent unauthorized access.
|
|
90
92
|
|
|
91
93
|
## Optional overrides
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# OpenRouter
|
|
4
4
|
|
|
5
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
5
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 335 models through Mastra's model router.
|
|
6
6
|
|
|
7
7
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
8
8
|
|
|
@@ -224,7 +224,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
224
224
|
| `openai/gpt-4o-mini` |
|
|
225
225
|
| `openai/gpt-4o-mini-2024-07-18` |
|
|
226
226
|
| `openai/gpt-5` |
|
|
227
|
-
| `openai/gpt-5-codex` |
|
|
228
227
|
| `openai/gpt-5-image` |
|
|
229
228
|
| `openai/gpt-5-image-mini` |
|
|
230
229
|
| `openai/gpt-5-mini` |
|
|
@@ -264,12 +263,10 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
264
263
|
| `openai/o1` |
|
|
265
264
|
| `openai/o1-pro` |
|
|
266
265
|
| `openai/o3` |
|
|
267
|
-
| `openai/o3-deep-research` |
|
|
268
266
|
| `openai/o3-mini` |
|
|
269
267
|
| `openai/o3-mini-high` |
|
|
270
268
|
| `openai/o3-pro` |
|
|
271
269
|
| `openai/o4-mini` |
|
|
272
|
-
| `openai/o4-mini-deep-research` |
|
|
273
270
|
| `openai/o4-mini-high` |
|
|
274
271
|
| `openrouter/auto` |
|
|
275
272
|
| `openrouter/bodybuilder` |
|
package/.docs/models/index.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Model Providers
|
|
4
4
|
|
|
5
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
5
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 5152 models from 164 providers through a single API.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Charm Hyper
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 23 Charm Hyper models through Mastra's model router. Authentication is handled automatically using the `HYPER_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Charm Hyper documentation](https://hyper.charm.land).
|
|
8
8
|
|
|
@@ -50,6 +50,7 @@ for await (const chunk of stream) {
|
|
|
50
50
|
| `hyper/llama-3.3-70b-instruct` | 128K | | | | | | $0.51 | $1 |
|
|
51
51
|
| `hyper/llama-4-maverick-17b-128e-instruct-fp8` | 430K | | | | | | $0.28 | $0.93 |
|
|
52
52
|
| `hyper/minimax-m2.7` | 205K | | | | | | $0.48 | $2 |
|
|
53
|
+
| `hyper/minimax-m3` | 512K | | | | | | $0.33 | $1 |
|
|
53
54
|
| `hyper/qwen3-coder-480b-a35b-instruct-int4-mixed-ar` | 106K | | | | | | $0.57 | $2 |
|
|
54
55
|
| `hyper/qwen3-next-80b-a3b-instruct` | 262K | | | | | | $0.12 | $1 |
|
|
55
56
|
| `hyper/qwen3.6-flash` | 1.0M | | | | | | $1 | $4 |
|
|
@@ -106,4 +106,4 @@ yarn add @ai-sdk/anthropic
|
|
|
106
106
|
bun add @ai-sdk/anthropic
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
For detailed provider-specific documentation, see the [AI SDK MiniMax (minimax.io) provider docs](https://ai-sdk.dev/providers/
|
|
109
|
+
For detailed provider-specific documentation, see the [AI SDK MiniMax (minimax.io) provider docs](https://ai-sdk.dev/providers/ai-sdk-providers/minimax).
|
|
@@ -59,9 +59,9 @@ for await (const chunk of stream) {
|
|
|
59
59
|
| `openai/gpt-5.5` | 1.1M | | | | | | $5 | $30 |
|
|
60
60
|
| `openai/gpt-5.5-pro` | 1.1M | | | | | | $30 | $180 |
|
|
61
61
|
| `openai/gpt-5.6` | 1.1M | | | | | | $5 | $30 |
|
|
62
|
-
| `openai/gpt-5.6-luna` | 1.1M | | | | | | $
|
|
62
|
+
| `openai/gpt-5.6-luna` | 1.1M | | | | | | $0.20 | $1 |
|
|
63
63
|
| `openai/gpt-5.6-sol` | 1.1M | | | | | | $5 | $30 |
|
|
64
|
-
| `openai/gpt-5.6-terra` | 1.1M | | | | | | $
|
|
64
|
+
| `openai/gpt-5.6-terra` | 1.1M | | | | | | $2 | $12 |
|
|
65
65
|
| `openai/gpt-image-1-mini` | — | | | | | | — | — |
|
|
66
66
|
| `openai/gpt-image-1.5` | — | | | | | | — | — |
|
|
67
67
|
| `openai/gpt-image-2` | — | | | | | | $5 | $30 |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# OpenCode Go
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 23 OpenCode Go models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [OpenCode Go documentation](https://opencode.ai/docs/zen).
|
|
8
8
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `opencode-go/deepseek-v4-pro` | 1.0M | | | | | | $0.43 | $0.87 |
|
|
41
41
|
| `opencode-go/glm-5.1` | 203K | | | | | | $1 | $4 |
|
|
42
42
|
| `opencode-go/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
43
|
+
| `opencode-go/gpt-5.6-luna` | 1.1M | | | | | | $0.10 | $0.60 |
|
|
43
44
|
| `opencode-go/grok-4.5` | 500K | | | | | | $2 | $6 |
|
|
44
45
|
| `opencode-go/hy3` | 256K | | | | | | $0.14 | $0.58 |
|
|
45
46
|
| `opencode-go/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
@@ -77,7 +77,7 @@ for await (const chunk of stream) {
|
|
|
77
77
|
| `opencode/gpt-5.4-pro` | 1.1M | | | | | | $30 | $180 |
|
|
78
78
|
| `opencode/gpt-5.5` | 1.1M | | | | | | $5 | $30 |
|
|
79
79
|
| `opencode/gpt-5.5-pro` | 1.1M | | | | | | $30 | $180 |
|
|
80
|
-
| `opencode/gpt-5.6-luna` | 1.1M | | | | | | $
|
|
80
|
+
| `opencode/gpt-5.6-luna` | 1.1M | | | | | | $0.20 | $1 |
|
|
81
81
|
| `opencode/gpt-5.6-sol` | 1.1M | | | | | | $5 | $30 |
|
|
82
82
|
| `opencode/gpt-5.6-terra` | 1.1M | | | | | | $3 | $15 |
|
|
83
83
|
| `opencode/grok-4.5` | 500K | | | | | | $2 | $6 |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Perplexity Agent
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 20 Perplexity Agent models through Mastra's model router. Authentication is handled automatically using the `PERPLEXITY_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Perplexity Agent documentation](https://docs.perplexity.ai/docs/agent-api/models).
|
|
8
8
|
|
|
@@ -46,6 +46,8 @@ for await (const chunk of stream) {
|
|
|
46
46
|
| `perplexity-agent/google/gemini-2.5-pro` | 1.0M | | | | | | $1 | $10 |
|
|
47
47
|
| `perplexity-agent/google/gemini-3-flash-preview` | 1.0M | | | | | | $0.50 | $3 |
|
|
48
48
|
| `perplexity-agent/google/gemini-3.1-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
49
|
+
| `perplexity-agent/moonshot-ai/kimi-k2.7-code` | 262K | | | | | | $0.95 | $4 |
|
|
50
|
+
| `perplexity-agent/moonshot-ai/kimi-k3` | 1.0M | | | | | | $3 | $15 |
|
|
49
51
|
| `perplexity-agent/nvidia/nemotron-3-super-120b-a12b` | 1.0M | | | | | | $0.25 | $3 |
|
|
50
52
|
| `perplexity-agent/openai/gpt-5-mini` | 400K | | | | | | $0.25 | $2 |
|
|
51
53
|
| `perplexity-agent/openai/gpt-5.1` | 400K | | | | | | $1 | $10 |
|
|
@@ -174,6 +174,17 @@ const { output, cleanup } = await durableAgent.observe(runId, {
|
|
|
174
174
|
await output.text
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
+
By default `observe()` waits indefinitely for events. If the process running the run stops unexpectedly, the run stops producing events but never emits a completion event, so the observed stream would wait forever. Pass `idleTimeoutMs` to bound that wait: after that many milliseconds of silence the stream ends. An optional `isAlive` check is consulted first. Return `true` while the run is still being worked on (for example a long-running tool call, or a run paused waiting for human input) to keep waiting. Returning `false`, or omitting `isAlive`, ends the stream with an error. A transient throw from `isAlive` is treated as "still alive", so a momentary check failure never ends a live stream.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
const { output } = await durableAgent.observe(runId, {
|
|
181
|
+
idleTimeoutMs: 30_000,
|
|
182
|
+
isAlive: () => runHeartbeat.isFresh(runId),
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Ending a run on idle timeout runs the same cleanup as a run that errors (see the warning below), so its cached state is released rather than retained. Both options are opt-in. Omit them for the previous wait-indefinitely behavior.
|
|
187
|
+
|
|
177
188
|
Returns: `Promise<DurableAgentStreamResult>`
|
|
178
189
|
|
|
179
190
|
> **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.
|
|
@@ -333,7 +344,7 @@ Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
|
333
344
|
|
|
334
345
|
## DurableAgentStreamResult
|
|
335
346
|
|
|
336
|
-
The object returned by `stream()`, `resume()`, and `
|
|
347
|
+
The object returned by `stream()`, `resume()`, `observe()`, and `recover()`.
|
|
337
348
|
|
|
338
349
|
```typescript
|
|
339
350
|
interface DurableAgentStreamResult<OUTPUT = undefined> {
|
|
@@ -171,7 +171,7 @@ Comma-separated list of custom arguments to pass to the Node.js process, e.g. `-
|
|
|
171
171
|
|
|
172
172
|
## `mastra worker build`
|
|
173
173
|
|
|
174
|
-
Bundles your Mastra application for worker deployment. Produces the same output as `mastra build
|
|
174
|
+
Bundles your Mastra application for worker deployment. Produces the same output as `mastra build`: a self-contained `.mastra/output/` directory.
|
|
175
175
|
|
|
176
176
|
```bash
|
|
177
177
|
mastra worker build [options]
|
|
@@ -179,29 +179,45 @@ mastra worker build [options]
|
|
|
179
179
|
|
|
180
180
|
### Flags
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
#### `--dir`
|
|
183
|
+
|
|
184
|
+
Path to your Mastra source directory. Defaults to `src/mastra`.
|
|
185
|
+
|
|
186
|
+
#### `--root`
|
|
187
|
+
|
|
188
|
+
Project root directory. Defaults to the current directory.
|
|
189
|
+
|
|
190
|
+
#### `--tools`
|
|
191
|
+
|
|
192
|
+
Comma-separated tool paths to include in the bundle.
|
|
193
|
+
|
|
194
|
+
#### `--output-dir`
|
|
195
|
+
|
|
196
|
+
Custom output directory. Defaults to `.mastra/output`.
|
|
197
|
+
|
|
198
|
+
#### `--debug`
|
|
199
|
+
|
|
200
|
+
Enable debug logging during the build.
|
|
189
201
|
|
|
190
202
|
## `mastra worker start`
|
|
191
203
|
|
|
192
204
|
> **Info:** You need to run `mastra worker build` or `mastra build` before using `mastra worker start`.
|
|
193
205
|
|
|
194
|
-
Starts a worker process from a previously built bundle.
|
|
206
|
+
Starts a worker process from a previously built bundle. The optional `name` argument sets `MASTRA_WORKERS` in the spawned process, controlling which worker starts.
|
|
195
207
|
|
|
196
208
|
```bash
|
|
197
209
|
mastra worker start [name] [options]
|
|
198
210
|
```
|
|
199
211
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
### Flags
|
|
213
|
+
|
|
214
|
+
#### `--dir`
|
|
215
|
+
|
|
216
|
+
Path to the build output directory. Defaults to `.mastra/output`.
|
|
217
|
+
|
|
218
|
+
#### `--env`
|
|
219
|
+
|
|
220
|
+
Path to the environment file. Defaults to `.env.production`, falling back to `.env`.
|
|
205
221
|
|
|
206
222
|
### Examples
|
|
207
223
|
|