@mastra/mcp-docs-server 1.3.7-alpha.5 → 1.3.7-alpha.9
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/harness/agent-controller.md +18 -0
- package/.docs/docs/harness/durable-agents.md +12 -0
- package/.docs/docs/mastra-platform/api.md +88 -0
- package/.docs/docs/mastra-platform/observability.md +2 -0
- package/.docs/docs/observability/metrics/overview.md +1 -1
- package/.docs/docs/server/request-context.md +5 -5
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/integrations/observability/opentelemetry.md +11 -5
- package/.docs/integrations/sandboxes/e2b.md +4 -9
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/gateways/custom-gateways.md +22 -0
- package/.docs/models/gateways/merge-gateway.md +5 -1
- package/.docs/models/gateways/netlify.md +5 -4
- package/.docs/models/gateways/openrouter.md +6 -4
- package/.docs/models/gateways/vercel.md +7 -2
- package/.docs/models/index.md +2 -1
- package/.docs/models/providers/aimlapi.md +257 -0
- package/.docs/models/providers/ambient.md +3 -1
- package/.docs/models/providers/deepinfra.md +3 -2
- package/.docs/models/providers/digitalocean.md +1 -1
- package/.docs/models/providers/edenai.md +328 -312
- package/.docs/models/providers/empiriolabs.md +2 -1
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/kilo.md +17 -15
- package/.docs/models/providers/llmgateway-providers.md +3 -2
- package/.docs/models/providers/llmgateway.md +2 -1
- package/.docs/models/providers/meta.md +1 -1
- package/.docs/models/providers/nano-gpt.md +8 -2
- package/.docs/models/providers/nearai.md +1 -1
- package/.docs/models/providers/novita-ai.md +3 -2
- package/.docs/models/providers/opencode-go.md +5 -4
- package/.docs/models/providers/opencode.md +3 -1
- package/.docs/models/providers/prime.md +5 -1
- package/.docs/models/providers/requesty.md +5 -1
- package/.docs/models/providers/standardcompute.md +2 -2
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
- package/.docs/reference/agent-controller/session.md +56 -9
- package/.docs/reference/client-js/agent-controller.md +2 -2
- package/.docs/reference/core/mastra-model-gateway.md +2 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +1 -1
- package/.docs/reference/observability/tracing/bridges/datadog.md +3 -0
- package/.docs/reference/observability/tracing/bridges/otel.md +2 -2
- package/.docs/reference/observability/tracing/exporters/datadog.md +3 -0
- package/.docs/reference/observability/tracing/exporters/langsmith.md +3 -1
- package/.docs/reference/workspace/factory-sandbox.md +173 -0
- package/package.json +5 -5
|
@@ -133,6 +133,24 @@ const session = await controller.createSession({
|
|
|
133
133
|
|
|
134
134
|
Use [`session.thread.create()`](https://mastra.ai/reference/agent-controller/session) and [`session.thread.switch()`](https://mastra.ai/reference/agent-controller/session) to move one live Session between conversations.
|
|
135
135
|
|
|
136
|
+
### Transfer thread ownership
|
|
137
|
+
|
|
138
|
+
Each new thread stores its durable owner in `metadata.ownerId` and its original creator in `metadata.createdBy`. Both default to the Session host's `ownerId`. `createdBy` doesn't change when ownership transfers.
|
|
139
|
+
|
|
140
|
+
Read the active thread's owner and transfer it through `session.thread`:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const currentOwnerId = await session.thread.getOwner()
|
|
144
|
+
|
|
145
|
+
await session.thread.transferOwnership({
|
|
146
|
+
toOwnerId: 'user-456',
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Transfers are serialized within one process. Hosts that require a durable cross-process compare-and-set should commit it in their own storage first, then call `transferOwnership()` to mirror the owner onto the active thread.
|
|
151
|
+
|
|
152
|
+
Every run snapshots the thread owner when it starts. Tools and other dynamic runtime code can read that value from `AgentControllerRequestContext.threadOwnerId`. If ownership changes during a run, the active run keeps the old snapshot and the next run receives the new owner. `context.session.ownerId` remains the identity of the process-local Session host.
|
|
153
|
+
|
|
136
154
|
### List stored messages from the client
|
|
137
155
|
|
|
138
156
|
Use the Agent Controller client to page through a thread's stored messages. Passing an options object returns the messages with pagination metadata:
|
|
@@ -364,6 +364,18 @@ Enforcement of the claim depends on the workflows store. When the store supports
|
|
|
364
364
|
- `InMemoryStore` from `@mastra/core/storage`
|
|
365
365
|
- `@mastra/pg`
|
|
366
366
|
- `@mastra/libsql` and `@mastra/turso`
|
|
367
|
+
- `@mastra/mysql`
|
|
368
|
+
- `@mastra/mssql`
|
|
369
|
+
- `@mastra/oracledb`
|
|
370
|
+
- `@mastra/spanner`
|
|
371
|
+
- `@mastra/dsql`
|
|
372
|
+
- `@mastra/cloudflare-d1`
|
|
373
|
+
- `@mastra/cloudflare`, with `CloudflareDOStorage`
|
|
374
|
+
- `@mastra/convex`
|
|
375
|
+
- `@mastra/mongodb`, on a replica set or sharded cluster
|
|
376
|
+
- `@mastra/dynamodb`
|
|
377
|
+
|
|
378
|
+
On Convex, run fencing runs in the Mastra server functions you deploy. Redeploy your Convex functions after upgrading `@mastra/convex`. Until you do, durable agent runs fail with an error asking you to redeploy, while other writes keep working.
|
|
367
379
|
|
|
368
380
|
Stores that support run fencing keep one claim record per run, plus one memory fence record per run with memory. Stores with retention support prune them with the `workflows.runOwnership` and `memory.runFences` [retention keys](https://mastra.ai/reference/storage/retention). A run's first generation comes from the store's clock, so a run that reuses a `runId` after its records were pruned still outranks the fences and stream events of its earlier executions.
|
|
369
381
|
|
|
@@ -179,6 +179,94 @@ The API returns `401` for invalid credentials, `403` for organization authorizat
|
|
|
179
179
|
|
|
180
180
|
Hosted observability doesn't provide a feedback creation route. Export feedback from the application as described in [Export feedback to Mastra Platform](https://mastra.ai/docs/observability/feedback).
|
|
181
181
|
|
|
182
|
+
## Metrics API
|
|
183
|
+
|
|
184
|
+
The Metrics API queries metrics exported to Mastra Platform Observability. Because the API is unversioned, backwards compatibility isn't guaranteed. Rate limits, retention, and ingestion-to-query freshness aren't published contracts.
|
|
185
|
+
|
|
186
|
+
The endpoints share their query parameters, request bodies, and response types with the Mastra runtime metric routes. See the [metric queries reference](https://mastra.ai/reference/observability/metrics/queries) for the full contract, including [shared filters](https://mastra.ai/reference/observability/metrics/queries), [analytics methods](https://mastra.ai/reference/observability/metrics/queries), and [metric discovery](https://mastra.ai/reference/observability/metrics/queries).
|
|
187
|
+
|
|
188
|
+
Use the root URL for your environment's data-residency region:
|
|
189
|
+
|
|
190
|
+
| Region | Root URL |
|
|
191
|
+
| -------------- | ------------------------------------------------------ |
|
|
192
|
+
| United States | `https://observability.mastra.ai/api/observability` |
|
|
193
|
+
| European Union | `https://observability.eu.mastra.ai/api/observability` |
|
|
194
|
+
|
|
195
|
+
Telemetry stays in its residency region. Querying the other region returns no records for the environment. See [Observability co-location](https://mastra.ai/docs/mastra-platform/regions) for the environment-to-region mapping.
|
|
196
|
+
|
|
197
|
+
### Authentication and project scope
|
|
198
|
+
|
|
199
|
+
Every request requires a platform access token. Create one in [Mastra Platform](https://projects.mastra.ai), or use the token written to `.env` during Platform setup.
|
|
200
|
+
|
|
201
|
+
Include `X-Mastra-Project-Id` to limit results to one project. If you omit it, the query covers metrics in every project available to the token's organization.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
curl -sS "https://observability.mastra.ai/api/observability/discovery/metric-names?prefix=mastra_model_" \
|
|
205
|
+
-H "Authorization: Bearer $MASTRA_PLATFORM_ACCESS_TOKEN" \
|
|
206
|
+
-H "X-Mastra-Project-Id: $MASTRA_PROJECT_ID" | jq
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Use an organization-scoped Platform access token. Gateway inference keys such as `mk_*` keys aren't accepted. Queries remain constrained to the token's organization even when you supply a project ID.
|
|
210
|
+
|
|
211
|
+
### Endpoints
|
|
212
|
+
|
|
213
|
+
| Method | Endpoint | Description |
|
|
214
|
+
| ------ | -------------------------------- | --------------------------------------- |
|
|
215
|
+
| GET | `/metrics` | List raw metric records |
|
|
216
|
+
| POST | `/metrics/aggregate` | Return one aggregate value |
|
|
217
|
+
| POST | `/metrics/breakdown` | Group metrics by dimensions |
|
|
218
|
+
| POST | `/metrics/timeseries` | Bucket metrics by interval |
|
|
219
|
+
| POST | `/metrics/percentiles` | Return percentile series for one metric |
|
|
220
|
+
| GET | `/discovery/metric-names` | List metric names |
|
|
221
|
+
| GET | `/discovery/metric-label-keys` | List label keys for a metric |
|
|
222
|
+
| GET | `/discovery/metric-label-values` | List values for a metric label key |
|
|
223
|
+
|
|
224
|
+
The list and discovery endpoints take their arguments as query parameters. See [`listMetrics(args)`](https://mastra.ai/reference/observability/metrics/queries) and [metric discovery](https://mastra.ai/reference/observability/metrics/queries) in the metric queries reference for the parameters each one accepts.
|
|
225
|
+
|
|
226
|
+
Analytics endpoints accept the same JSON request bodies and return types as the [metric queries reference](https://mastra.ai/reference/observability/metrics/queries), including `name`, `aggregation`, `filters`, `groupBy`, `interval`, `percentiles`, `comparePeriod`, `limit`, `orderDirection`, and `distinctColumn`.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
curl -sS "https://observability.mastra.ai/api/observability/metrics/aggregate" \
|
|
230
|
+
-X POST \
|
|
231
|
+
-H "Authorization: Bearer $MASTRA_PLATFORM_ACCESS_TOKEN" \
|
|
232
|
+
-H "X-Mastra-Project-Id: $MASTRA_PROJECT_ID" \
|
|
233
|
+
-H "Content-Type: application/json" \
|
|
234
|
+
--data '{"name":["mastra_model_total_input_tokens","mastra_model_total_output_tokens"],"aggregation":"sum","filters":{"timestamp":{"start":"2026-09-13T00:00:00Z","end":"2026-10-13T00:00:00Z"}},"comparePeriod":"previous_period"}' | jq
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`filters.timestamp` is optional. If you omit `start` and `end`, the query covers all retained data. `comparePeriod` requires both `start` and `end`. Without them, the previous-period fields are `null`.
|
|
238
|
+
|
|
239
|
+
The API returns `401` for invalid credentials, `403` for organization authorization failures, and `400` for malformed query arguments or JSON bodies.
|
|
240
|
+
|
|
241
|
+
#### `MastraClient`
|
|
242
|
+
|
|
243
|
+
`MastraClient` from `@mastra/client-js` exposes the analytics and discovery methods. Set `baseUrl` to the region's host without the `/api/observability` path:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { MastraClient } from '@mastra/client-js'
|
|
247
|
+
|
|
248
|
+
const mastraClient = new MastraClient({
|
|
249
|
+
baseUrl: 'https://observability.mastra.ai',
|
|
250
|
+
headers: {
|
|
251
|
+
Authorization: `Bearer ${process.env.MASTRA_PLATFORM_ACCESS_TOKEN}`,
|
|
252
|
+
'X-Mastra-Project-Id': process.env.MASTRA_PROJECT_ID!,
|
|
253
|
+
},
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
const result = await mastraClient.getMetricAggregate({
|
|
257
|
+
name: ['mastra_model_total_input_tokens', 'mastra_model_total_output_tokens'],
|
|
258
|
+
aggregation: 'sum',
|
|
259
|
+
})
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### CLI
|
|
263
|
+
|
|
264
|
+
The [`mastra api metric`](https://mastra.ai/reference/cli/mastra) commands target the United States endpoint by default. Pass `--url` to query the European Union region:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
mastra api --url https://observability.eu.mastra.ai metric aggregate '<json>'
|
|
268
|
+
```
|
|
269
|
+
|
|
182
270
|
## Gateway proxy endpoints
|
|
183
271
|
|
|
184
272
|
Visit the [Gateway documentation](https://gateway.mastra.ai/docs) for more details.
|
|
@@ -168,6 +168,8 @@ The CLI can infer platform credentials from your project environment. See the [`
|
|
|
168
168
|
|
|
169
169
|
You can query exported feedback over HTTP. See the [Feedback API](https://mastra.ai/docs/mastra-platform/api) for its current status, regional endpoints, authentication, project scoping, and supported query parameters such as `traceId` and `environment`.
|
|
170
170
|
|
|
171
|
+
You can query exported metrics over HTTP, with `MastraClient`, or with `mastra api metric`. See the [Metrics API](https://mastra.ai/docs/mastra-platform/api) for regional endpoints, authentication, project scoping, and supported endpoints.
|
|
172
|
+
|
|
171
173
|
## Import existing traces
|
|
172
174
|
|
|
173
175
|
Use `mastra traces import` to move existing trace history from a supported observability provider into an existing Mastra Platform project. The command reads and validates complete traces at the source, converts them into Mastra spans, then uses a shared workflow for preparation, upload, resume, and verification.
|
|
@@ -10,7 +10,7 @@ Mastra emits:
|
|
|
10
10
|
|
|
11
11
|
- **Duration metrics** for agent runs, workflows, tools, model calls, and processors
|
|
12
12
|
- **Token usage metrics** for model input and output, including detailed token categories when the provider reports them
|
|
13
|
-
- **Cost estimates** calculated from token usage, provider, model, and model prices from [models.dev](https://models.dev)
|
|
13
|
+
- **Cost estimates** calculated from token usage, provider, model, and model prices from [models.dev](https://models.dev) or from a [custom gateway](https://mastra.ai/models/gateways/custom-gateways)
|
|
14
14
|
|
|
15
15
|
Metrics retain trace correlation context, so you can investigate a change in a chart by finding the related span. See the [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics) for metric names, labels, and cost fields.
|
|
16
16
|
|
|
@@ -284,11 +284,11 @@ requestContext.set(MASTRA_RESOURCE_ID_KEY, user.id)
|
|
|
284
284
|
requestContext.set(MASTRA_THREAD_ID_KEY, threadId)
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
| Key | Purpose
|
|
288
|
-
| --------------------------- |
|
|
289
|
-
| `MASTRA_RESOURCE_ID_KEY` | Forces all memory operations to use this resource ID. The server validates that accessed threads belong to this resource and returns 403 if not.
|
|
290
|
-
| `MASTRA_THREAD_ID_KEY` | Forces thread operations to use this thread ID, overriding client-provided values
|
|
291
|
-
| `MASTRA_MESSAGE_AUTHOR_KEY` | Names who sent a user message as `{ id, name?, avatarUrl? }`. Agent-controller sessions
|
|
287
|
+
| Key | Purpose |
|
|
288
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
289
|
+
| `MASTRA_RESOURCE_ID_KEY` | Forces all memory operations to use this resource ID. The server validates that accessed threads belong to this resource and returns 403 if not. |
|
|
290
|
+
| `MASTRA_THREAD_ID_KEY` | Forces thread operations to use this thread ID, overriding client-provided values |
|
|
291
|
+
| `MASTRA_MESSAGE_AUTHOR_KEY` | Names who sent a user message as `{ id, name?, avatarUrl? }`. Agent-controller sessions persist it at `content.metadata.signal.author` and mirror it to `providerMetadata.mastra.author` for compatibility, so a thread shared by several people can show who wrote what. |
|
|
292
292
|
|
|
293
293
|
These keys are used to implement user isolation in multi-tenant applications. See [Authorization middleware](https://mastra.ai/docs/server/middleware) for usage examples.
|
|
294
294
|
|
|
@@ -117,7 +117,7 @@ See [datasets overview](https://mastra.ai/docs/evals/datasets) for the full API
|
|
|
117
117
|
|
|
118
118
|
### Experiments
|
|
119
119
|
|
|
120
|
-
Run all items in a dataset against an agent, workflow, or scorer and collect the results in one place. Select a target, optionally attach scorers, and trigger the experiment. The results view shows each item's input, output, status, and individual score breakdowns. Compare two experiments side by side to measure the impact of prompt, model, or code changes.
|
|
120
|
+
Run all items in a dataset against an agent, workflow, or scorer and collect the results in one place. Select a target, optionally attach scorers, and trigger the experiment. The results view shows each item's input, output, status, and individual score breakdowns. Compare two to ten experiments side by side against a baseline to measure the impact of prompt, model, or code changes.
|
|
121
121
|
|
|
122
122
|
See [datasets overview](https://mastra.ai/docs/evals/datasets) for setup details.
|
|
123
123
|
|
|
@@ -766,7 +766,7 @@ No Mastra exporters are required when using the bridge. Traces are sent via your
|
|
|
766
766
|
|
|
767
767
|
#### Forwarding logs (optional)
|
|
768
768
|
|
|
769
|
-
The bridge also forwards Mastra log events to the globally registered OTEL `LoggerProvider`. To wire up logs alongside traces, register a
|
|
769
|
+
The bridge also forwards Mastra log events to the globally registered OTEL `LoggerProvider`. To wire up logs alongside traces, register a log record processor on `NodeSDK`:
|
|
770
770
|
|
|
771
771
|
```typescript
|
|
772
772
|
import { NodeSDK } from '@opentelemetry/sdk-node'
|
|
@@ -775,11 +775,13 @@ import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs'
|
|
|
775
775
|
|
|
776
776
|
const sdk = new NodeSDK({
|
|
777
777
|
// ...trace config as usual
|
|
778
|
-
|
|
779
|
-
new
|
|
780
|
-
|
|
778
|
+
logRecordProcessors: [
|
|
779
|
+
new BatchLogRecordProcessor({
|
|
780
|
+
exporter: new OTLPLogExporter({
|
|
781
|
+
url: process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT || 'http://localhost:4318/v1/logs',
|
|
782
|
+
}),
|
|
781
783
|
}),
|
|
782
|
-
|
|
784
|
+
],
|
|
783
785
|
})
|
|
784
786
|
```
|
|
785
787
|
|
|
@@ -795,6 +797,10 @@ Use the `--import` flag to ensure instrumentation loads before your application:
|
|
|
795
797
|
tsx --import ./instrumentation.ts ./src/index.ts
|
|
796
798
|
```
|
|
797
799
|
|
|
800
|
+
#### Flushing before exit
|
|
801
|
+
|
|
802
|
+
Mastra's `flush()` and `shutdown()` ask the registered OTEL providers to flush, but a `BatchSpanProcessor` can still hold a batch it has already started exporting. In serverless or short-lived processes, also `await sdk.shutdown()` after Mastra's flush, so no spans are left in your OTEL SDK when the process exits. The provider's own `forceFlush()` is not enough: it does not wait for a batch the exporter is already sending.
|
|
803
|
+
|
|
798
804
|
### Semantic conventions
|
|
799
805
|
|
|
800
806
|
The `OtelBridge` exports Mastra spans using [OpenTelemetry Semantic Conventions for GenAI v1.38.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.38.0/docs/gen-ai). This includes standardized span names (`chat {model}`, `execute_tool {tool_name}`, etc.) and attributes (`gen_ai.usage.input_tokens`, `gen_ai.request.model`, etc.).
|
|
@@ -402,23 +402,18 @@ Setup commands that need their own credentials — a registry token, a private i
|
|
|
402
402
|
|
|
403
403
|
### Per-session sandboxes
|
|
404
404
|
|
|
405
|
-
Hosts that construct one sandbox per session, such as Mastra Factory's `sandbox` config,
|
|
405
|
+
Hosts that construct one sandbox per session, such as Mastra Factory's `sandbox` config, use `E2BFactorySandbox`: sandbox identity is the session id (id-keyed getOrCreate, so the sandbox pauses on E2B's idle timeout and resumes by id), the repo template comes from `createRepoTemplate` over the session's repositories, and the project's `cpuCount` and `memoryMb` settings flow into the template. See the [FactorySandbox reference](https://mastra.ai/reference/workspace/factory-sandbox).
|
|
406
406
|
|
|
407
407
|
```typescript
|
|
408
408
|
import { MastraFactory } from '@mastra/factory'
|
|
409
|
-
import {
|
|
409
|
+
import { E2BFactorySandbox } from '@mastra/e2b'
|
|
410
410
|
|
|
411
411
|
new MastraFactory({
|
|
412
|
-
sandbox:
|
|
413
|
-
new E2BSandbox({
|
|
414
|
-
id: ctx.sessionId,
|
|
415
|
-
// Undefined for a session with no repository.
|
|
416
|
-
template: createRepoTemplate(ctx),
|
|
417
|
-
}),
|
|
412
|
+
sandbox: new E2BFactorySandbox({ apiKey: process.env.E2B_API_KEY }),
|
|
418
413
|
})
|
|
419
414
|
```
|
|
420
415
|
|
|
421
|
-
|
|
416
|
+
The bare callback form, `sandbox: ctx => new E2BSandbox({ id: ctx.sessionId, template: createRepoTemplate(ctx) })`, is also supported: factory sees it as a custom provider with no settings to tune. Either way, factory attaches its own session setup to the sandbox it gets back.
|
|
422
417
|
|
|
423
418
|
## Using with Code Mode
|
|
424
419
|
|
|
@@ -15,6 +15,7 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
15
15
|
| [AgentRouter](https://mastra.ai/models/providers/agentrouter) | `agentrouter/*` | `AGENTROUTER_API_KEY` |
|
|
16
16
|
| [Agnes AI](https://mastra.ai/models/providers/agnes) | `agnes/*` | `AGNES_API_KEY` |
|
|
17
17
|
| [AI-ROUTER](https://mastra.ai/models/providers/ai-router) | `ai-router/*` | `AI_ROUTER_API_KEY` |
|
|
18
|
+
| [AI/ML API](https://mastra.ai/models/providers/aimlapi) | `aimlapi/*` | `AIMLAPI_API_KEY` |
|
|
18
19
|
| [ai&](https://mastra.ai/models/providers/aiand) | `aiand/*` | `AIAND_API_KEY` |
|
|
19
20
|
| [AI21 Labs](https://mastra.ai/models/providers/ai21) | `ai21/*` | `AI21_API_KEY` |
|
|
20
21
|
| [ainetcafe](https://mastra.ai/models/providers/ainetcafe) | `ainetcafe/*` | `AINETCAFE_API_KEY` |
|
|
@@ -371,6 +371,28 @@ interface ProviderConfig {
|
|
|
371
371
|
url?: string; // Optional API base URL
|
|
372
372
|
apiKeyHeader?: string; // Optional custom auth header
|
|
373
373
|
docUrl?: string; // Optional documentation URL
|
|
374
|
+
pricing?: Record<string, ModelPricing>; // Optional prices per model ID
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Model pricing
|
|
379
|
+
|
|
380
|
+
models.dev does not list private deployments, so their calls have no cost in [metrics](https://mastra.ai/docs/observability/metrics/overview). Add a `pricing` entry per model to give them one. Prices are in USD per 1 million tokens and use the same keys as a model's `cost` on [models.dev](https://models.dev): `input`, `output`, `cache_read`, `cache_write`, `reasoning`, `input_audio`, and `output_audio`. `@mastra/observability` reads these prices on the first call to a model it can't price, which also picks up gateways added later with `addGateway()`. Under `mastra dev`, or with `MASTRA_AUTO_REFRESH_PRICING=true`, it also reads them when Mastra starts, so the first call is priced too. models.dev prices take precedence. A gateway price is used only when models.dev has none for that provider and model ID, and then it applies to every call with those IDs, including direct calls. Give a reseller its own provider ID when its rates must stay separate from direct calls. A gateway whose `fetchProviders()` fails is logged and retried about once an hour. Set `MASTRA_OFFLINE=true` to skip loading them. The same shape as models.dev also means you can add `tiers` for long-context pricing.
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
async fetchProviders(): Promise<Record<string, ProviderConfig>> {
|
|
384
|
+
return {
|
|
385
|
+
'my-provider': {
|
|
386
|
+
name: 'My Provider',
|
|
387
|
+
models: ['model-1'],
|
|
388
|
+
apiKeyEnvVar: 'MY_API_KEY',
|
|
389
|
+
gateway: 'private',
|
|
390
|
+
url: 'https://api.myprovider.com/v1',
|
|
391
|
+
pricing: {
|
|
392
|
+
'model-1': { input: 0.5, output: 1.5, cache_read: 0.05 },
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
};
|
|
374
396
|
}
|
|
375
397
|
```
|
|
376
398
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Merge Gateway
|
|
6
6
|
|
|
7
|
-
Merge Gateway aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
Merge Gateway aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 203 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Merge Gateway documentation](https://docs.merge.dev/merge-gateway).
|
|
10
10
|
|
|
@@ -96,6 +96,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
96
96
|
| `google/gemini-3.6-flash` |
|
|
97
97
|
| `google/gemini-3.7-flash` |
|
|
98
98
|
| `google/gemini-3.8-flash` |
|
|
99
|
+
| `google/gemini-4-argon` |
|
|
99
100
|
| `google/gemini-embedding-001` |
|
|
100
101
|
| `google/gemini-embedding-2` |
|
|
101
102
|
| `google/gemini-flash-latest` |
|
|
@@ -189,11 +190,13 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
189
190
|
| `qwen/qwen3-coder-next` |
|
|
190
191
|
| `qwen/qwen3-coder-plus` |
|
|
191
192
|
| `qwen/qwen3-max` |
|
|
193
|
+
| `qwen/qwen3-max-preview` |
|
|
192
194
|
| `qwen/qwen3-next-80b-a3b-instruct` |
|
|
193
195
|
| `qwen/qwen3-next-80b-a3b-thinking` |
|
|
194
196
|
| `qwen/qwen3-vl-235b-a22b-instruct` |
|
|
195
197
|
| `qwen/qwen3-vl-235b-a22b-thinking` |
|
|
196
198
|
| `qwen/qwen3-vl-30b-a3b-instruct` |
|
|
199
|
+
| `qwen/qwen3-vl-flash` |
|
|
197
200
|
| `qwen/qwen3-vl-plus` |
|
|
198
201
|
| `qwen/qwen3.5-122b-a10b` |
|
|
199
202
|
| `qwen/qwen3.5-27b` |
|
|
@@ -212,6 +215,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
212
215
|
| `qwen/qwen3.8-2.4t-a95b` |
|
|
213
216
|
| `qwen/qwen3.8-flash` |
|
|
214
217
|
| `qwen/qwen3.8-max` |
|
|
218
|
+
| `sakana/fugu-max` |
|
|
215
219
|
| `sakana/fugu-ultra` |
|
|
216
220
|
| `sakana/sakana-namazu` |
|
|
217
221
|
| `thinkingmachines/inkling` |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Netlify
|
|
6
6
|
|
|
7
|
-
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access
|
|
7
|
+
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access 275 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Netlify documentation](https://docs.netlify.com/build/ai-gateway/overview/).
|
|
10
10
|
|
|
@@ -72,6 +72,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
72
72
|
| `gemini/gemini-3.6-flash` |
|
|
73
73
|
| `gemini/gemini-3.7-flash` |
|
|
74
74
|
| `gemini/gemini-3.8-flash` |
|
|
75
|
+
| `gemini/gemini-4-argon` |
|
|
75
76
|
| `gemini/gemini-flash-latest` |
|
|
76
77
|
| `gemini/gemini-flash-lite-latest` |
|
|
77
78
|
| `gemini/gemini-nano-banana-2.1` |
|
|
@@ -136,7 +137,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
136
137
|
| `openrouter/~z-ai/glm-flash-latest` |
|
|
137
138
|
| `openrouter/~z-ai/glm-latest` |
|
|
138
139
|
| `openrouter/anthracite-org/magnum-v4-72b` |
|
|
139
|
-
| `openrouter/apodex/apodex-1.1-mini:free` |
|
|
140
140
|
| `openrouter/bytedance-seed/seed-1.6` |
|
|
141
141
|
| `openrouter/bytedance-seed/seed-1.6-flash` |
|
|
142
142
|
| `openrouter/bytedance-seed/seed-2-1-turbo` |
|
|
@@ -169,12 +169,11 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
169
169
|
| `openrouter/inception/mercury-2` |
|
|
170
170
|
| `openrouter/inception/mercury-2.5` |
|
|
171
171
|
| `openrouter/inclusionai/ling-3.0-flash` |
|
|
172
|
-
| `openrouter/inclusionai/ling-3.0-flash-fin` |
|
|
173
|
-
| `openrouter/inclusionai/ling-3.0-flash-sante` |
|
|
174
172
|
| `openrouter/inclusionai/ling-3.0-flash-vl` |
|
|
175
173
|
| `openrouter/inclusionai/ling-3.1-flash` |
|
|
176
174
|
| `openrouter/inference-net/schematron-v2-small` |
|
|
177
175
|
| `openrouter/inference-net/schematron-v2-turbo` |
|
|
176
|
+
| `openrouter/liquid/lfm-2.5-24b-a2b` |
|
|
178
177
|
| `openrouter/mancer/weaver` |
|
|
179
178
|
| `openrouter/meta-llama/llama-3.1-70b-instruct` |
|
|
180
179
|
| `openrouter/meta-llama/llama-3.1-8b-instruct` |
|
|
@@ -272,6 +271,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
272
271
|
| `openrouter/sao10k/l3-lunaris-8b` |
|
|
273
272
|
| `openrouter/sao10k/l3.1-euryale-70b` |
|
|
274
273
|
| `openrouter/sao10k/l3.3-euryale-70b` |
|
|
274
|
+
| `openrouter/scaledown/extract` |
|
|
275
|
+
| `openrouter/scaledown/summarize` |
|
|
275
276
|
| `openrouter/stepfun/step-3.7-flash` |
|
|
276
277
|
| `openrouter/tencent/hy-mt2-1.8b` |
|
|
277
278
|
| `openrouter/tencent/hy-mt2-30b-a3b` |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# OpenRouter
|
|
6
6
|
|
|
7
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 382 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
10
10
|
|
|
@@ -84,7 +84,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
84
84
|
| `anthropic/claude-sonnet-4.6` |
|
|
85
85
|
| `anthropic/claude-sonnet-5` |
|
|
86
86
|
| `anthropic/claude-sonnet-5.5` |
|
|
87
|
-
| `apodex/apodex-1.1-mini:free` |
|
|
88
87
|
| `arcee-ai/trinity-large-thinking` |
|
|
89
88
|
| `bytedance-seed/seed-1.6` |
|
|
90
89
|
| `bytedance-seed/seed-1.6-flash` |
|
|
@@ -136,6 +135,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
136
135
|
| `google/gemini-3.6-flash` |
|
|
137
136
|
| `google/gemini-3.7-flash` |
|
|
138
137
|
| `google/gemini-3.8-flash` |
|
|
138
|
+
| `google/gemini-4-argon` |
|
|
139
139
|
| `google/gemini-nano-banana-2.1` |
|
|
140
140
|
| `google/gemma-2-27b-it` |
|
|
141
141
|
| `google/gemma-3-12b-it` |
|
|
@@ -153,13 +153,12 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
153
153
|
| `inception/mercury-2` |
|
|
154
154
|
| `inception/mercury-2.5` |
|
|
155
155
|
| `inclusionai/ling-3.0-flash` |
|
|
156
|
-
| `inclusionai/ling-3.0-flash-fin` |
|
|
157
|
-
| `inclusionai/ling-3.0-flash-sante` |
|
|
158
156
|
| `inclusionai/ling-3.0-flash-vl` |
|
|
159
157
|
| `inclusionai/ling-3.1-flash` |
|
|
160
158
|
| `inference-net/schematron-v2-small` |
|
|
161
159
|
| `inference-net/schematron-v2-turbo` |
|
|
162
160
|
| `liquid/lfm-2.5-2.6b:free` |
|
|
161
|
+
| `liquid/lfm-2.5-24b-a2b` |
|
|
163
162
|
| `mancer/weaver` |
|
|
164
163
|
| `meituan/longcat-2.0` |
|
|
165
164
|
| `meta-llama/llama-3.1-70b-instruct` |
|
|
@@ -366,6 +365,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
366
365
|
| `sao10k/l3-lunaris-8b` |
|
|
367
366
|
| `sao10k/l3.1-euryale-70b` |
|
|
368
367
|
| `sao10k/l3.3-euryale-70b` |
|
|
368
|
+
| `scaledown/extract` |
|
|
369
|
+
| `scaledown/summarize` |
|
|
369
370
|
| `stepfun/step-3.5-flash` |
|
|
370
371
|
| `stepfun/step-3.7-flash` |
|
|
371
372
|
| `stepfun/step-5-preview` |
|
|
@@ -385,6 +386,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
385
386
|
| `thinkingmachines/inkling:free` |
|
|
386
387
|
| `unbiased/pareto` |
|
|
387
388
|
| `unbiased/pareto-26.10-preview` |
|
|
389
|
+
| `unbiased/pareto-26.9` |
|
|
388
390
|
| `undi95/remm-slerp-l2-13b` |
|
|
389
391
|
| `upstage/solar-mini4` |
|
|
390
392
|
| `upstage/solar-pro-3` |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Vercel
|
|
6
6
|
|
|
7
|
-
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 407 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Vercel documentation](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
10
10
|
|
|
@@ -146,6 +146,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
146
146
|
| `deepseek/deepseek-v4.1-flash` |
|
|
147
147
|
| `deepseek/deepseek-v4.1-flash-fast` |
|
|
148
148
|
| `fireworks/ember-1` |
|
|
149
|
+
| `fish-audio/drama-3` |
|
|
149
150
|
| `fish-audio/s1` |
|
|
150
151
|
| `fish-audio/s2-pro` |
|
|
151
152
|
| `fish-audio/s2.1-pro` |
|
|
@@ -172,6 +173,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
172
173
|
| `google/gemini-3.8-flash-tts` |
|
|
173
174
|
| `google/gemini-3.8-live` |
|
|
174
175
|
| `google/gemini-3.8-live-extended-thinking` |
|
|
176
|
+
| `google/gemini-4-argon` |
|
|
175
177
|
| `google/gemini-embedding-001` |
|
|
176
178
|
| `google/gemini-embedding-2` |
|
|
177
179
|
| `google/gemini-nano-banana-2.1` |
|
|
@@ -194,7 +196,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
194
196
|
| `inclusionai/ling-3.0-flash-sante` |
|
|
195
197
|
| `inclusionai/ling-3.0-flash-vl` |
|
|
196
198
|
| `inclusionai/ling-3.1-flash` |
|
|
197
|
-
| `inclusionai/ling-3.1-flash-free` |
|
|
198
199
|
| `inference-net/schematron-v2-small` |
|
|
199
200
|
| `inference-net/schematron-v2-turbo` |
|
|
200
201
|
| `interfaze/interfaze-beta` |
|
|
@@ -206,6 +207,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
206
207
|
| `klingai/kling-v3.0-i2v` |
|
|
207
208
|
| `klingai/kling-v3.0-motion-control` |
|
|
208
209
|
| `klingai/kling-v3.0-t2v` |
|
|
210
|
+
| `liquid/lfm2.5-24b-a2b` |
|
|
209
211
|
| `meituan/longcat-2.5-preview` |
|
|
210
212
|
| `meta/llama-3.1-70b` |
|
|
211
213
|
| `meta/llama-3.1-8b` |
|
|
@@ -220,6 +222,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
220
222
|
| `meta/muse-spark-1.3` |
|
|
221
223
|
| `meta/muse-spark-1.3-contributor` |
|
|
222
224
|
| `meta/muse-wonder-1.0` |
|
|
225
|
+
| `microsoft/mai-image-2.6` |
|
|
226
|
+
| `microsoft/mai-image-2.6-flash` |
|
|
223
227
|
| `microsoft/mai-transcribe-2` |
|
|
224
228
|
| `microsoft/mai-transcribe-2-streaming` |
|
|
225
229
|
| `microsoft/mai-voice-2` |
|
|
@@ -261,6 +265,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
261
265
|
| `nvidia/nemotron-3-super-120b-a12b` |
|
|
262
266
|
| `nvidia/nemotron-3-ultra-550b-a55b` |
|
|
263
267
|
| `nvidia/nemotron-3.5-lightning` |
|
|
268
|
+
| `nvidia/nemotron-3.5-lightning-free` |
|
|
264
269
|
| `nvidia/nemotron-nano-12b-v2-vl` |
|
|
265
270
|
| `nvidia/nemotron-nano-9b-v2` |
|
|
266
271
|
| `openai/gpt-3.5-turbo` |
|
package/.docs/models/index.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Model Providers
|
|
6
6
|
|
|
7
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
7
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 8147 models from 216 providers through a single API.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -383,6 +383,7 @@ Every provider below works with the model router as `provider/model`. Read the p
|
|
|
383
383
|
- [AgentRouter](https://mastra.ai/models/providers/agentrouter)
|
|
384
384
|
- [Agnes AI](https://mastra.ai/models/providers/agnes)
|
|
385
385
|
- [AI-ROUTER](https://mastra.ai/models/providers/ai-router)
|
|
386
|
+
- [AI/ML API](https://mastra.ai/models/providers/aimlapi)
|
|
386
387
|
- [ai&](https://mastra.ai/models/providers/aiand)
|
|
387
388
|
- [AI21 Labs](https://mastra.ai/models/providers/ai21)
|
|
388
389
|
- [ainetcafe](https://mastra.ai/models/providers/ainetcafe)
|