@mastra/mcp-docs-server 1.3.15 → 1.3.16-alpha.0
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/overview.md +1 -1
- package/.docs/docs/agents/processors.md +5 -5
- package/.docs/docs/agents/resumable-streams.md +2 -2
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/connections/mcp.md +3 -1
- package/.docs/docs/deployment/mastra-server.md +1 -1
- package/.docs/docs/evals/multi-turn.md +2 -2
- package/.docs/docs/guides/build-an-eval-loop.md +1 -1
- package/.docs/docs/harness/agent-controller.md +2 -2
- package/.docs/docs/harness/durable-agents.md +1 -0
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/mastra-platform/alerts.md +225 -122
- package/.docs/docs/mastra-platform/api.md +3 -3
- package/.docs/docs/mastra-platform/connect.md +1 -1
- package/.docs/docs/mastra-platform/gateway/api/audio.md +50 -0
- package/.docs/docs/mastra-platform/gateway/api/chat-completions.md +91 -0
- package/.docs/docs/mastra-platform/gateway/api/decisions.md +54 -0
- package/.docs/docs/mastra-platform/gateway/api/embeddings.md +35 -0
- package/.docs/docs/mastra-platform/gateway/api/images.md +52 -0
- package/.docs/docs/mastra-platform/gateway/api/messages.md +50 -0
- package/.docs/docs/mastra-platform/gateway/api/models.md +25 -0
- package/.docs/docs/mastra-platform/gateway/api/rerank.md +33 -0
- package/.docs/docs/mastra-platform/gateway/api/responses.md +48 -0
- package/.docs/docs/mastra-platform/gateway/api/videos.md +86 -0
- package/.docs/docs/mastra-platform/gateway/integrations.md +151 -0
- package/.docs/docs/mastra-platform/gateway/keys-and-byok.md +76 -0
- package/.docs/docs/mastra-platform/gateway/migrate.md +60 -0
- package/.docs/docs/mastra-platform/gateway/models-and-routing.md +40 -0
- package/.docs/docs/mastra-platform/gateway/overview.md +182 -0
- package/.docs/docs/mastra-platform/gateway/quickstart.md +103 -0
- package/.docs/docs/mastra-platform/gateway/usage-and-limits.md +76 -0
- package/.docs/docs/mastra-platform/gateway/web-search.md +46 -0
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +6 -0
- package/.docs/docs/sandbox/overview.md +5 -5
- package/.docs/integrations/channels/slack.md +1 -1
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/archil.md +1 -1
- package/.docs/integrations/file-storage/azure-blob.md +1 -1
- package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
- package/.docs/integrations/file-storage/mesa.md +1 -1
- package/.docs/integrations/file-storage/neon.md +1 -1
- package/.docs/integrations/file-storage/vercel-files.md +1 -1
- package/.docs/integrations/sandboxes/apple-container.md +1 -1
- package/.docs/integrations/sandboxes/blaxel.md +1 -1
- package/.docs/integrations/sandboxes/daytona.md +1 -1
- package/.docs/integrations/sandboxes/docker.md +1 -1
- package/.docs/integrations/sandboxes/e2b-desktop.md +1 -1
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/sandboxes/modal.md +1 -1
- package/.docs/integrations/sandboxes/railway.md +1 -1
- package/.docs/integrations/sandboxes/sprites.md +1 -1
- package/.docs/integrations/sandboxes/vercel.md +2 -2
- package/.docs/integrations/tools/brightdata.md +1 -1
- package/.docs/integrations/tools/parallel.md +1 -1
- package/.docs/integrations/tools/perplexity.md +1 -1
- package/.docs/integrations/tools/sanity-context.md +226 -0
- package/.docs/integrations/tools/tavily.md +1 -1
- package/.docs/integrations/vectors/mongodb.md +221 -17
- package/.docs/integrations.md +1 -0
- package/.docs/models/gateways/custom-gateways.md +1 -1
- package/.docs/models/gateways/mastra.md +13 -41
- package/.docs/models/gateways/merge-gateway.md +2 -1
- package/.docs/models/gateways/netlify.md +2 -1
- package/.docs/models/gateways/openrouter.md +1 -1
- package/.docs/models/gateways/requesty.md +8 -1
- package/.docs/models/gateways/vercel.md +3 -1
- package/.docs/models/index.md +4 -4
- package/.docs/models/providers/aimlapi.md +3 -3
- package/.docs/models/providers/ambient.md +1 -1
- package/.docs/models/providers/chutes.md +2 -2
- package/.docs/models/providers/cloudflare-workers-ai.md +2 -1
- package/.docs/models/providers/cortecs.md +19 -15
- package/.docs/models/providers/crossmodel.md +2 -1
- package/.docs/models/providers/digitalocean.md +3 -1
- package/.docs/models/providers/edenai.md +9 -3
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/hostinger-router.md +1 -1
- package/.docs/models/providers/huggingface.md +7 -1
- package/.docs/models/providers/inceptron.md +8 -8
- package/.docs/models/providers/kenari.md +2 -2
- package/.docs/models/providers/kilo.md +85 -82
- package/.docs/models/providers/llmgateway-providers.md +9 -5
- package/.docs/models/providers/llmgateway.md +5 -4
- package/.docs/models/providers/nano-gpt.md +21 -39
- package/.docs/models/providers/nearai.md +1 -2
- package/.docs/models/providers/novita-ai.md +5 -2
- package/.docs/models/providers/obscurify.md +1 -1
- package/.docs/models/providers/ofox.md +4 -1
- package/.docs/models/providers/opencode-go.md +0 -1
- package/.docs/models/providers/opencode.md +3 -5
- package/.docs/models/providers/prime.md +4 -1
- package/.docs/models/providers/vivgrid.md +5 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
- package/.docs/reference/agent-controller/session.md +7 -5
- package/.docs/reference/agents/agent.md +2 -2
- package/.docs/reference/agents/durable-agent.md +18 -0
- package/.docs/reference/client-js/agent-controller.md +1 -1
- package/.docs/reference/coding-agent/build-base-prompt.md +1 -1
- package/.docs/reference/coding-agent/create-coding-agent.md +7 -7
- package/.docs/reference/core/mastra-model-gateway.md +1 -1
- package/.docs/reference/datasets/startExperiment.md +1 -1
- package/.docs/reference/evals/multi-turn-judge.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +1 -1
- package/.docs/reference/evals/tool-call-accuracy.md +1 -1
- package/.docs/reference/memory/observational-memory.md +2 -2
- package/.docs/reference/memory/recall.md +1 -1
- package/.docs/reference/processors/prefill-error-handler.md +2 -2
- package/.docs/reference/processors/processor-interface.md +1 -1
- package/.docs/reference/processors/provider-history-compat.md +1 -1
- package/.docs/reference/processors/response-cache.md +1 -1
- package/.docs/reference/processors/stream-error-retry-processor.md +3 -3
- package/.docs/reference/rag/retrieval.md +29 -1
- package/.docs/reference/workspace/platform-filesystem.md +1 -1
- package/.docs/reference/workspace/platform-sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +5 -5
- package/package.json +5 -5
|
@@ -85,7 +85,7 @@ await store.connect()
|
|
|
85
85
|
|
|
86
86
|
### `createIndex()`
|
|
87
87
|
|
|
88
|
-
Creates a new vector index (collection) in MongoDB.
|
|
88
|
+
Creates a new vector index (collection) in MongoDB. When calls for the same new name run concurrently and ask for the same collection and embedding, all of them succeed. If they ask for different ones, the later call throws `CONFLICT` naming what differs.
|
|
89
89
|
|
|
90
90
|
**indexName** (`string`): Name of the collection to create
|
|
91
91
|
|
|
@@ -95,13 +95,13 @@ Creates a new vector index (collection) in MongoDB.
|
|
|
95
95
|
|
|
96
96
|
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
97
97
|
|
|
98
|
-
**filterFields** (`string[]`): Metadata field names to declare as filter fields in the MongoDB vectorSearch index (registered as metadata.\<field>). Queries that filter only on declared fields are pushed directly into $vectorSearch instead of pre-filtering candidate \_ids, avoiding the 16 MB BSON limit on large result sets. Filters that reference an undeclared field, or use an operator $vectorSearch does not support, fall back to the pre-filter automatically.
|
|
98
|
+
**filterFields** (`string[]`): Metadata field names to declare as filter fields in the MongoDB vectorSearch index (registered as metadata.\<field>). Queries that filter only on declared fields are pushed directly into $vectorSearch instead of pre-filtering candidate \_ids, avoiding the 16 MB BSON limit on large result sets. Filters that reference an undeclared field, or use an operator $vectorSearch does not support, fall back to the pre-filter automatically. On a bring-your-own index, names are declared as written (for example, lane or specs.gpu), so metadataMode: 'document' filters can use them.
|
|
99
99
|
|
|
100
|
-
**collectionName** (`string`): Store the vectors on an existing (operational) collection instead of a managed collection named after the index. The collection is never created or dropped by this store when set. Defaults to indexName.
|
|
100
|
+
**collectionName** (`string`): Store the vectors on an existing (operational) collection instead of a managed collection named after the index. The collection is never created or dropped by this store when set. Defaults to indexName. A managed collection is created with validationLevel: 'off', which has no effect without a validator. It lets Mastra tell a collection it created from one another client created at the same moment with other options, which Mastra adopts and never drops.
|
|
101
101
|
|
|
102
102
|
**searchIndexName** (`string`): Name for the MongoDB vectorSearch index created on the collection. Defaults to ${indexName}\_vector_index.
|
|
103
103
|
|
|
104
|
-
**allowWrites** (`boolean`):
|
|
104
|
+
**allowWrites** (`boolean`): Deprecated, and removed in the next major version. Opts in to upsert, updateVector, deleteVector, and deleteVectors on a bring-your-own collection, which is read-only by default. Ignored for managed collections, which are always writable. The policy is persisted with the index registration and survives restarts. See the warning under Indexing an existing collection. (Default: `false`)
|
|
105
105
|
|
|
106
106
|
### `waitForIndexReady()`
|
|
107
107
|
|
|
@@ -115,7 +115,7 @@ Waits for an index to become ready after creation. Useful when you need to ensur
|
|
|
115
115
|
|
|
116
116
|
### `upsert()`
|
|
117
117
|
|
|
118
|
-
Adds or updates vectors and their metadata in the collection. On a bring-your-own index, this requires `allowWrites: true` at `createIndex()` time because BYO collections are read-only by default.
|
|
118
|
+
Adds or updates vectors and their metadata in the collection. On a bring-your-own index, this requires the deprecated `allowWrites: true` option at `createIndex()` time because BYO collections are read-only by default.
|
|
119
119
|
|
|
120
120
|
**indexName** (`string`): Name of the collection to insert into
|
|
121
121
|
|
|
@@ -151,6 +151,18 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
151
151
|
|
|
152
152
|
**metadataMode** (`'field' | 'document'`): 'field' (default) projects the managed metadata/document fields, and filter fields are matched against the metadata subdocument. 'document' returns the full source document as metadata — use for bring-your-own operational collections whose documents have their own shape — and filter fields are matched against the \*\*root\*\* document (no metadata. prefix). The embedding field is omitted from metadata by default (to avoid payload bloat); set includeVector: true to retain it in metadata and also expose it as a top-level vector. (Default: `field`)
|
|
153
153
|
|
|
154
|
+
#### BYO filter declarations after upgrading
|
|
155
|
+
|
|
156
|
+
BYO `filterFields` are now declared exactly as written. Earlier versions prefixed bare declarations with `metadata.`. If your BYO documents store values under `metadata` and you use the default `metadataMode: 'field'`, declare the full paths, such as `filterFields: ['metadata.category']`. Keep the query filter as `{ category: 'billing' }`.
|
|
157
|
+
|
|
158
|
+
For root-level BYO fields, use `filterFields: ['category']` with `metadataMode: 'document'`. If you rebuild an index with root-level declarations but still query nested metadata, filtering falls back to the bounded pre-filter instead of running inside `$vectorSearch`. To change an existing search index's field declarations, update its definition in MongoDB rather than registering it again. After the updated index reaches `READY`, create a new `MongoDBVector` instance and use it for subsequent queries so it loads the updated declarations instead of cached paths. Otherwise, large nested-metadata queries can continue to hit `TOO_MANY_CANDIDATES` even after you add the required filter paths.
|
|
159
|
+
|
|
160
|
+
#### Filters that can't run inside `$vectorSearch`
|
|
161
|
+
|
|
162
|
+
A filter runs inside `$vectorSearch` only when every field it uses is declared in `filterFields` and every operator is one `$vectorSearch` supports. Otherwise `query()` and `hybridQuery()` first run the filter as a `$match`, load the matching `_id`s into memory, and pass them to `$vectorSearch`. Without a regular index on the filtered fields, that step scans the collection. If more than 100,000 documents match or their candidate `_id` array exceeds 12 MiB of BSON, the query throws `TOO_MANY_CANDIDATES`. The byte budget leaves room for the rest of the MongoDB command. Long string IDs can reach it before the document-count limit.
|
|
163
|
+
|
|
164
|
+
Results come back as a complete array of at most 10,000 hits. Memory use grows with `topK`, `includeVector`, and document size, and `metadataMode: 'document'` returns full source documents.
|
|
165
|
+
|
|
154
166
|
### `createSearchIndex()`
|
|
155
167
|
|
|
156
168
|
Provisions a MongoDB Search (BM25/full-text) index on the collection backing an index and records it as the text-search index that `textQuery()` and `hybridQuery()` will target.
|
|
@@ -167,7 +179,7 @@ Naming:
|
|
|
167
179
|
|
|
168
180
|
**indexName** (`string`): Name of the Mastra index whose collection will have the search index
|
|
169
181
|
|
|
170
|
-
**fields** (`string[]`): Field names to index for full-text search. Omit for dynamic mapping (all string fields).
|
|
182
|
+
**fields** (`string[]`): Field names to index for full-text search. Use dot notation for nested fields, for example metadata.name. Omit for dynamic mapping (all string fields).
|
|
171
183
|
|
|
172
184
|
**searchIndexName** (`string`): Name for the MongoDB Search index. When fields is provided and this is omitted, a distinct default name that is unique per logical index is used, so the field mapping is not shadowed by the auto-created dynamic index and two logical indexes on the same collection do not collide. (Default: ``${collectionName}_search_index (or ${collectionName}_${indexName}_search_fields_index when `fields` is given)``)
|
|
173
185
|
|
|
@@ -180,7 +192,7 @@ await store.createSearchIndex({
|
|
|
180
192
|
})
|
|
181
193
|
```
|
|
182
194
|
|
|
183
|
-
The field-mapped index name includes the logical `indexName`, so two logical indexes on the same collection get distinct text indexes. Calling `createSearchIndex()` again for the _same_ logical index with different `fields` updates the existing text index definition in place. You don't need to drop it first.
|
|
195
|
+
The field-mapped index name includes the logical `indexName`, so two logical indexes on the same collection get distinct text indexes. Calling `createSearchIndex()` again for the _same_ logical index with different `fields` updates the existing text index definition in place if Mastra created it. You don't need to drop it first. Mastra never changes a full-text index it didn't create: an existing index with the requested name is reused only when its whole definition is equivalent to the one requested: field types, analyzers (including the root `analyzer` and `searchAnalyzer`), nested fields, `storedSource` and synonyms. Defaults that Atlas echoes back, such as `indexOptions: 'offsets'`, `store: true`, `norms: 'include'` and an empty `fields`, count as equivalent. Otherwise `createSearchIndex()` throws a `CONFLICT` error. When the registration predates ownership records, the message suggests [`claimLegacyIndex()`](#claimlegacyindex).
|
|
184
196
|
|
|
185
197
|
### `waitForSearchIndexReady()`
|
|
186
198
|
|
|
@@ -230,7 +242,7 @@ const results = await store.textQuery({
|
|
|
230
242
|
|
|
231
243
|
### `hybridQuery()`
|
|
232
244
|
|
|
233
|
-
Runs a hybrid search that fuses vector similarity with full-text results through MongoDB's server-side `$rankFusion`. The feature requires MongoDB 8.0 or later
|
|
245
|
+
Runs a hybrid search that fuses vector similarity with full-text results through MongoDB's server-side `$rankFusion`. The feature requires MongoDB 8.0 or later. A full-text search index must exist. Managed indexes create one automatically, while bring-your-own collections require an explicit `createSearchIndex()` call.
|
|
234
246
|
|
|
235
247
|
**indexName** (`string`): Name of the Mastra index to search
|
|
236
248
|
|
|
@@ -267,7 +279,90 @@ const results = await store.hybridQuery({
|
|
|
267
279
|
})
|
|
268
280
|
```
|
|
269
281
|
|
|
270
|
-
`hybridQuery()` requires MongoDB 8.0 or later for the `$rankFusion` stage
|
|
282
|
+
`hybridQuery()` requires MongoDB 8.0 or later for the `$rankFusion` stage. If your deployment is older or lacks `$rankFusion`, run `query()` and `textQuery()` separately before merging the results client-side.
|
|
283
|
+
|
|
284
|
+
#### Per-branch options and native reranking
|
|
285
|
+
|
|
286
|
+
`hybridQuery()` also accepts separate `vector` and `text` options. Use this form to set a different retrieval limit for each branch, and optionally rerank the fused results before the final `topK` limit. Existing calls that use the parameters above don't change.
|
|
287
|
+
|
|
288
|
+
This form has the same `$rankFusion` requirements and registered indexes. For bring-your-own collections, register a full-text index with `createSearchIndex()` or pass `text.searchIndexName`.
|
|
289
|
+
|
|
290
|
+
Native [`$rerank`](https://www.mongodb.com/docs/vector-search/query/aggregation-stages/rerank/) requires Atlas running MongoDB 9.0 or later with **Native Reranking** enabled in the project's settings. The default `rerank-2.5` model isn't in Preview. In native `$rerank`, the `rerank-3` and `rerank-3-lite` models are in Preview and require a dedicated M10-or-higher cluster. The same models are out of Preview in the Voyage AI API. Self-managed and Atlas Local deployments don't support native reranking. No separate Voyage AI client or application-side API key is required.
|
|
291
|
+
|
|
292
|
+
With an initialized `store`, registered indexes, an `embedding` you generated, and text stored in `metadata.text`, retrieve candidates and rerank them in one call:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
const results = await store.hybridQuery({
|
|
296
|
+
indexName: 'articles',
|
|
297
|
+
vector: { queryVector: embedding, limit: 50, numCandidates: 1000 },
|
|
298
|
+
text: { query: question, paths: ['metadata.text'], limit: 50 },
|
|
299
|
+
rerank: { query: question, paths: ['metadata.text'], numDocsToRerank: 50 },
|
|
300
|
+
topK: 5,
|
|
301
|
+
})
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Each retrieval branch contributes up to its own `limit` documents. `$rerank` evaluates up to `numDocsToRerank` fused documents, then `topK` limits the response. The reranker receives source documents before projection, so `text.paths` and `rerank.paths` are relative to the document root, for both managed and bring-your-own collections.
|
|
305
|
+
|
|
306
|
+
This form has no `metadataMode` option. Managed indexes return the managed `metadata` and `document` fields. Bring-your-own indexes return the source document as `metadata`, excluding the embedding field. With `includeVector: true`, `metadata` keeps the embedding field and the result also returns it as `vector`.
|
|
307
|
+
|
|
308
|
+
On an `autoEmbed` index, use `vector.query` instead of `vector.queryVector`. Omit `rerank` to return fused results without reranking:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
const results = await store.hybridQuery({
|
|
312
|
+
indexName: 'articles_auto',
|
|
313
|
+
vector: { query: question, limit: 50 },
|
|
314
|
+
text: { query: question, paths: ['document'], limit: 50 },
|
|
315
|
+
topK: 5,
|
|
316
|
+
})
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**indexName** (`string`): Logical Mastra index identifying the collection and registered search indexes.
|
|
320
|
+
|
|
321
|
+
**topK** (`number`): Final result limit after fusion and optional reranking. Integer from 1 to 10000. (Default: `10`)
|
|
322
|
+
|
|
323
|
+
**filter** (`MongoDBVectorFilter`): Filter applied to both retrieval branches before fusion. On managed indexes, keys target the managed metadata fields. On bring-your-own indexes, keys target source document fields. Filters on fields declared in filterFields run inside $vectorSearch. Other filters use the \`\_id\` pre-filter, as in the flat form.
|
|
324
|
+
|
|
325
|
+
**weights** (`{ vector?: number; text?: number }`): Finite, non-negative fusion weights. Each omitted weight defaults to 1. At least one must be positive.
|
|
326
|
+
|
|
327
|
+
**includeVector** (`boolean`): Return each result's stored embedding as vector. Not supported on autoEmbed indexes, which throw an error. (Default: `false`)
|
|
328
|
+
|
|
329
|
+
**vector** (`object`): Vector retrieval configuration. Supply exactly one of queryVector or query.
|
|
330
|
+
|
|
331
|
+
**vector.queryVector** (`number[]`): Non-empty, finite embedding that you generate. Mutually exclusive with vector.query and vector.model. Not supported on autoEmbed indexes, which throw an error; use vector.query instead.
|
|
332
|
+
|
|
333
|
+
**vector.query** (`string`): Non-empty text for MongoDB to embed. Requires an autoEmbed index and is independent of text.query.
|
|
334
|
+
|
|
335
|
+
**vector.model** (`string`): Query embedding model override. Requires vector.query and must be compatible with the index model. Independent of rerank.model.
|
|
336
|
+
|
|
337
|
+
**vector.limit** (`number`): Maximum vector results contributed to fusion. Integer from 1 to 10000. (Default: `min(10000, max(4 * topK, 20))`)
|
|
338
|
+
|
|
339
|
+
**vector.numCandidates** (`number`): Vector search candidates. Integer from 1 to 10000. An explicit value is sent to MongoDB unchanged, which rejects a value below the resolved vector.limit. (Default: `min(10000, 20 * vector.limit)`)
|
|
340
|
+
|
|
341
|
+
**vector.searchIndexName** (`string`): Bring-your-own collections only. Search this existing vector index instead of the registered one. With this option, filters always use the \`\_id\` pre-filter, so the index must declare \_id as a filter field. It must also index the registered embedding field with the same embedding mode (vectors or autoEmbed); otherwise MongoDB rejects the query. Managed indexes throw an error.
|
|
342
|
+
|
|
343
|
+
**text** (`object`): Full-text retrieval configuration, independent of vector retrieval.
|
|
344
|
+
|
|
345
|
+
**text.query** (`string`): Non-empty full-text query.
|
|
346
|
+
|
|
347
|
+
**text.paths** (`string[]`): Non-empty array of indexed source field paths for full-text matching.
|
|
348
|
+
|
|
349
|
+
**text.searchIndexName** (`string`): Bring-your-own collections only. Search this existing full-text index instead of the registered one. Managed indexes throw an error.
|
|
350
|
+
|
|
351
|
+
**text.limit** (`number`): Maximum text results contributed to fusion. Integer from 1 to 10000. (Default: `min(10000, max(4 * topK, 20))`)
|
|
352
|
+
|
|
353
|
+
**rerank** (`object`): Enable native reranking after fusion. Omit for hybrid retrieval only. An empty object is invalid.
|
|
354
|
+
|
|
355
|
+
**rerank.query** (`string`): Required when rerank is supplied. Non-empty relevance query, independent of both retrieval queries.
|
|
356
|
+
|
|
357
|
+
**rerank.paths** (`string[]`): Required when rerank is supplied. Non-empty array of source fields used to judge relevance. MongoDB returns an error if any candidate document lacks a specified field.
|
|
358
|
+
|
|
359
|
+
**rerank.model** (`string`): Native reranking model, independent of the embedding model. MongoDB determines model availability. (Default: `rerank-2.5`)
|
|
360
|
+
|
|
361
|
+
**rerank.numDocsToRerank** (`number`): Required when rerank is supplied. Maximum fused documents to rerank and return before topK. Integer from 1 to 1000.
|
|
362
|
+
|
|
363
|
+
Returns `QueryResult[]` in final relevance order. `score` is the native reranking score when reranking is enabled, or the fusion score otherwise. These scores use different scales.
|
|
364
|
+
|
|
365
|
+
Invalid requests throw `MastraError`. Server failures preserve their causes, including unavailable reranking, unsupported models, and missing source fields. The method never silently substitutes a model or skips reranking.
|
|
271
366
|
|
|
272
367
|
### `describeIndex()`
|
|
273
368
|
|
|
@@ -287,20 +382,115 @@ interface IndexStats {
|
|
|
287
382
|
|
|
288
383
|
On an `autoEmbed` index, `dimension` is read from the index definition and reports MongoDB's default of `1024` when the index doesn't pin one. `metric` is omitted when the `autoEmbed` index doesn't specify a similarity. `count` counts documents that carry the embedded text field, since the generated vectors aren't stored on your documents.
|
|
289
384
|
|
|
385
|
+
`count` is an exact count of the documents that carry the embedding field. On a large collection without a regular MongoDB index on that field, the count scans the collection, so avoid calling `describeIndex()` from request paths or health checks. `upsert()` and `updateVector()` read the dimension from the index definition and don't count documents.
|
|
386
|
+
|
|
290
387
|
### `deleteIndex()`
|
|
291
388
|
|
|
292
|
-
Deletes a vector index.
|
|
389
|
+
Deletes a vector index. Mastra records which search indexes and collections it created, and drops only those:
|
|
390
|
+
|
|
391
|
+
- **Managed index** (created without `collectionName`): drops the collection and all its data. If a collection with that name already existed when `createIndex()` ran, Mastra keeps it and drops only the search indexes it created. Managed indexes created before `@mastra/mongodb@1.15.0`, or registered by 1.15 through 1.27 without an ownership record, aren't dropped until you call [`claimLegacyIndex()`](#claimlegacyindex) for them.
|
|
392
|
+
- **Bring-your-own index** (created with `collectionName`): drops the vector and full-text indexes Mastra created. The collection and its documents are kept.
|
|
393
|
+
|
|
394
|
+
Mastra keeps any search index that existed before `createIndex()` or `createSearchIndex()` ran, that another logical index still uses, or that an earlier version registered. Drop those yourself if you no longer need them. Pointing an index at a different `searchIndexName` counts as a new index that Mastra doesn't own unless that call creates it. If Mastra created the old vector index, it keeps cleanup responsibility for it and drops it when the logical index is deleted. When one logical index is deleted and another registration still uses a search index, Mastra keeps that index and passes cleanup responsibility to the other registration. The last registration to be deleted drops it. Renaming a text index with `createSearchIndex()` keeps responsibility for the old index Mastra created, and Mastra drops it when the logical index is deleted, not at rename time.
|
|
395
|
+
|
|
396
|
+
`deleteIndex()` throws these errors:
|
|
397
|
+
|
|
398
|
+
- `NOT_REGISTERED`: the name has no registration, and nothing is dropped. If the collection predates `@mastra/mongodb@1.15.0`, call `claimLegacyIndex()` first.
|
|
399
|
+
- `OWNERSHIP_UNKNOWN`: a managed index registered by 1.15 through 1.27 has no ownership record. Call `claimLegacyIndex()` first.
|
|
400
|
+
- `IN_USE`: another registration still uses the managed collection. Mastra checks this again when you retry a stalled delete.
|
|
401
|
+
- `CAPABILITY_CHECK_FAILED`: the check for transaction support failed. Nothing changed, so retry.
|
|
402
|
+
- `OUTCOME_UNKNOWN`: MongoDB couldn't confirm whether the delete committed. Retry. If the retry throws `NOT_REGISTERED`, the delete completed. A retry deletes whatever is registered under the name at that point, and no read can tell the original registration from a re-created one. If another process may re-create the index, coordinate with it before you retry. Don't retry by name if you can't rule out a re-create.
|
|
403
|
+
|
|
404
|
+
`createIndex()`, `createSearchIndex()` and `claimLegacyIndex()` throw `INDEX_DELETING` while a delete is half-finished, and while Mastra is still removing a search index it created under the same name (see [cleanup errors and logs](#cleanup-errors-and-logs)). Retrying `deleteIndex()` resumes and finishes a half-finished delete.
|
|
405
|
+
|
|
406
|
+
Concurrent deletes of indexes that share a collection are coordinated with transactions on Atlas, Atlas Local and replica sets. On a standalone server they aren't, and neither is a create that runs during a delete, so don't run them concurrently there. A `createIndex()` or `createSearchIndex()` call that starts using a search index a running `deleteIndex()` is about to drop throws `INDEX_DELETING`. Retry it once the delete finishes. Retrying is safe: if the delete already handed the search index to the new registration, that registration is kept and drops the index when it's deleted. A call throws `CONFLICT` and provisions nothing when, before its last check ahead of provisioning, `deleteIndex()` removes its registration or another call changes the registration's collection or the names of the search indexes the call is about to create. A `createSearchIndex()` call also throws `CONFLICT` when another call changed the registration after it was read. A `createIndex()` call on an existing registration throws `CONFLICT` and changes nothing when the registration was deleted or recreated after it was read. A registration created by an earlier version is the exception: the call re-reads it once and proceeds against the current registration. A `deleteIndex()` that overlaps another delete and a re-create leaves the new registration alone. A re-created managed collection has one exception, listed under [cleanup limits](#cleanup-limits).
|
|
407
|
+
|
|
408
|
+
Mastra records the Atlas ID of every search index it creates and drops or updates search indexes only by the ID it recorded, so a recorded index is never confused with one recreated under the same name. [Cleanup limits](#cleanup-limits) lists the exceptions. Identical concurrent calls both succeed, and the index is recorded once. When the registration changes after that last check, or a `deleteIndex()` and a re-create with the same names overlap, the call throws `CONFLICT`. The index it created is still recorded: it's kept as a retired index that `deleteIndex()` drops, handed to the registration that now uses the name, or dropped. If a process crashes or stalls during a create or a cleanup, the next `createIndex()`, `createSearchIndex()`, `deleteIndex()` or `claimLegacyIndex()` on that collection finishes the work once 5 minutes have passed.
|
|
293
409
|
|
|
294
|
-
|
|
295
|
-
|
|
410
|
+
If `createIndex()` or `createSearchIndex()` fails before its search index is created, Mastra removes the registration that call inserted, or restores only the fields that call wrote. Mastra never undoes a search index it created. If `createIndex()` creates the vector index and then fails to create the companion full-text index, it throws and keeps the vector index registered, so a retry or `deleteIndex()` handles it.
|
|
411
|
+
|
|
412
|
+
Mastra reads and writes its registry (`__mastra_vector_indexes__`) and its internal provisioning journal (`__mastra_vector_ops__`) on the primary with majority read and write concerns, and commits its transactions the same way, whatever the client's read preference and concerns. This adds latency to these methods. These writes wait until the required number of the replica set's data-bearing voting members acknowledge them. In a primary-secondary-arbiter (PSA) replica set with its secondary down, the arbiter stores no data and can't acknowledge. The writes wait until the secondary is back. Don't modify `__mastra_vector_ops__`.
|
|
296
413
|
|
|
297
414
|
The BYO classification is recorded durably when the index is created, so it's applied correctly even by a different process (e.g. an index created by a setup job and later deleted by a long-lived service). Always pass the **logical index name** (the `indexName` used at `createIndex`), not the physical collection name.
|
|
298
415
|
|
|
299
416
|
**indexName** (`string`): Logical name of the index to delete
|
|
300
417
|
|
|
418
|
+
#### Cleanup errors and logs
|
|
419
|
+
|
|
420
|
+
`createIndex()` and `createSearchIndex()` can throw these errors while search indexes are being created or removed. Each message is shown verbatim, with placeholders in angle brackets:
|
|
421
|
+
|
|
422
|
+
- `CONFLICT`: `search index "<name>" on "<collection>" is in status <status> (id <id>); the previous index under this name is still being removed. Retry. If it persists, drop it manually.` Atlas still lists an earlier index under this name with status `DELETING` or `DOES_NOT_EXIST`, and Mastra doesn't create over it. A `DELETING` row usually clears within seconds. If the error persists, drop the row by ID as shown below. The error only delays the create. Nothing is dropped or lost while it lasts.
|
|
423
|
+
- `CONFLICT`: `Index "<indexName>" was removed or recreated by another call while this one ran, so nothing was provisioned. Retry.`
|
|
424
|
+
- `CONFLICT`: `the target changed concurrently; the index this call created is kept as a retired index of the registration and removed by deleteIndex`
|
|
425
|
+
- `CONFLICT`: `the registration was removed or recreated while this call ran; what it created was handed over or removed`
|
|
426
|
+
- `INDEX_DELETING`: `search index "<name>" on "<collection>" is pending removal of an index Mastra created (cleanup record <_id>). Retry: retrying runs the cleanup. If the drop keeps failing, the block remains and the failure is logged at error level.`
|
|
427
|
+
- `FAILED`: `The create of search index "<name>" on "<collection>" may or may not have reached Atlas. Retry.`
|
|
428
|
+
|
|
429
|
+
Mastra also logs these messages:
|
|
430
|
+
|
|
431
|
+
- `warn`: `search index "<name>" on "<collection>" (id <id>) may have been created by Mastra; kept; drop it manually if unused`. Mastra couldn't confirm whether its create reached Atlas, for example after a lost response or a crash, and an index with that name now exists. Mastra doesn't record it as its own, so `deleteIndex()` keeps it. The message can repeat when Mastra removes its internal record. If no logical index uses the search index, drop it by ID.
|
|
432
|
+
- `warn`: `search index "<name>" on "<collection>" (id <id>) is not recorded as created by Mastra: its id time <time> is more than 30 s before the pre-list at <time>`. The index Atlas returned is older than Mastra's create, so Mastra treats it as created by someone else and keeps it.
|
|
433
|
+
- `error`: `could not drop search index "<name>" (id <id>) on "<collection>"; cleanup record <_id> keeps blocking the name: <error>`. Mastra retries the drop, and logs this again if it fails, on each later `createIndex()`, `createSearchIndex()`, `deleteIndex()` or `claimLegacyIndex()` on that collection. Until the drop succeeds, calls that use that name throw `INDEX_DELETING`.
|
|
434
|
+
|
|
435
|
+
To drop a search index by ID in `mongosh`, list the collection's search indexes and pass the `id` of the one to drop:
|
|
436
|
+
|
|
437
|
+
```javascript
|
|
438
|
+
db.getCollection('movies').getSearchIndexes()
|
|
439
|
+
db.runCommand({ dropSearchIndex: 'movies', id: '<id>' })
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
> **Note:** On Atlas Local, dropping a collection that still has search indexes can leave rows with status `DOES_NOT_EXIST` that reappear when a collection with the same name is created again. Mastra then throws the `CONFLICT` for a row that's still being removed, and retrying doesn't help. Drop the stuck row by ID with `dropSearchIndex`. To avoid it, drop a collection's search indexes before you drop the collection.
|
|
443
|
+
|
|
444
|
+
#### Cleanup limits
|
|
445
|
+
|
|
446
|
+
- **Unconfirmed creates:** if a create's response is lost, or the process crashes before Mastra records the new index, Mastra keeps the index and logs the `may have been created by Mastra` warning. In rarer cases, such as a process paused for more than 5 minutes in the middle of a create, the index is kept without a log. Drop it by ID if unused.
|
|
447
|
+
- **Indexes registered by earlier versions:** these have no recorded ID, so Mastra lists the name when a delete starts, records the listed ID and drops by it. If someone drops and recreates the index under the same name before that listing, Mastra drops the recreated one. When another logical index still uses the name, Mastra transfers the index to it with the ID recorded from that listing. Search indexes that earlier versions created and left unregistered stay unrecorded. Drop them yourself.
|
|
448
|
+
- **Mixed versions:** upgrade every instance before relying on these cleanup guarantees. Older instances drop search indexes by name and ignore the provisioning journal.
|
|
449
|
+
- **A delete overlapping a re-create of a managed index:** right before dropping a managed collection, `deleteIndex()` checks that its delete is still the current one, but MongoDB can't drop a collection conditionally. If the delete stalls between that check and the drop while another call finishes the same delete and `createIndex()` creates the collection again, the stalled delete drops the new collection. Don't re-create a managed index while a delete of it may still be running.
|
|
450
|
+
- **A managed collection created concurrently with the same option:** `createIndex()` creates a managed collection with `validationLevel: 'off'`, so a collection another client creates between Mastra's existence check and its create with other options, defaults included, is adopted and kept. If the other client also uses `validationLevel: 'off'` and no other option, MongoDB reports success to both, Mastra records the collection as its own, and `deleteIndex()` drops it. Don't let other clients create collections with the names of managed indexes.
|
|
451
|
+
- **A retarget made by another process:** each `MongoDBVector` instance caches the collection and search index an index resolves to. When another process points the index at a different search index with `createIndex()`, this instance keeps querying the previous one until it reads the registration again, for example after `createIndex()`, `createSearchIndex()` or `deleteIndex()` on that index, or in a new instance.
|
|
452
|
+
- **Indexes dropped outside Mastra during a delete:** if someone drops a search index Mastra recorded and Mastra creates a new one under that name while a delete is deciding, the registration that takes the name over can keep the old ID. Its later delete then leaves the new index in place. Drop it by ID if unused.
|
|
453
|
+
- **Identical external creates on an Atlas cluster:** if another client creates a search index with the same name and an identical definition within about one round trip before Mastra's own create, Atlas returns that index's ID to Mastra, Mastra records the index as its own, and `deleteIndex()` drops it. Only a definition that matches the one Mastra generates triggers this, so in practice the other client is another Mastra process. An index whose ID is more than 30 seconds older than Mastra's create is treated as someone else's and logged at `warn`. Mastra never drops a search index that another logical index uses, so only a client outside Mastra can lose an index this way. Atlas Local isn't affected.
|
|
454
|
+
|
|
455
|
+
### `claimLegacyIndex()`
|
|
456
|
+
|
|
457
|
+
Records that Mastra created a managed index's collection and its recorded search indexes, so later calls to `deleteIndex()` and `createSearchIndex()` can manage them. Use it for managed indexes created before `@mastra/mongodb@1.15.0`, which have no registration, and for managed indexes registered by 1.15 through 1.27, which have no ownership record.
|
|
458
|
+
|
|
459
|
+
> **Warning:** After a claim, `deleteIndex()` drops the collection and all its data. A claim also overrides an explicit "not owned" record, such as a collection an earlier version adopted, so claim an index only when Mastra created the collection. The claim itself drops nothing.
|
|
460
|
+
|
|
461
|
+
```typescript
|
|
462
|
+
await store.claimLegacyIndex({ indexName: 'movies' })
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
The claim records ownership before it verifies the search indexes, so a concurrent `deleteIndex()` can act on it before the claim completes. Don't delete an index while you claim it. If verification fails, Mastra attempts to undo the claim. A concurrent write to the registration makes that undo miss, and Mastra then logs a `warn` that the claim may still stand. After a failed claim, retry `claimLegacyIndex()` before calling `deleteIndex()`.
|
|
466
|
+
|
|
467
|
+
Calling it again for a claimed index does nothing. It never overwrites another registration.
|
|
468
|
+
|
|
469
|
+
**indexName** (`string`): Logical name of the managed index to claim
|
|
470
|
+
|
|
471
|
+
`claimLegacyIndex()` throws these errors:
|
|
472
|
+
|
|
473
|
+
- `BYO`: the index is bring-your-own. Mastra keeps those collections, so there's nothing to claim.
|
|
474
|
+
- `CONFLICT`: another registration already uses the name for something else, or a search index changed during the claim (`index changed while it was being claimed; nothing was claimed; retry`).
|
|
475
|
+
- `IN_USE`: another registration uses the same collection.
|
|
476
|
+
- `NOT_FOUND`: the name has no registration, and its collection or `<name>_vector_index` doesn't exist.
|
|
477
|
+
- `INDEX_DELETING`: a delete of this index is half-finished. Retry `deleteIndex()`.
|
|
478
|
+
- `FAILED`: any other failure.
|
|
479
|
+
|
|
480
|
+
### Upgrading from versions before this release
|
|
481
|
+
|
|
482
|
+
Call `claimLegacyIndex()` once for each of these indexes:
|
|
483
|
+
|
|
484
|
+
- Managed collections created before `@mastra/mongodb@1.15.0`, if you want to delete them with `deleteIndex()`.
|
|
485
|
+
- Managed indexes registered by 1.15 through 1.27 that you want to delete, or whose text mappings you want to change with `createSearchIndex()`.
|
|
486
|
+
|
|
487
|
+
Indexes you only query, upsert into or list need no claim. Mastra refuses to delete or rewrite what it can't prove it created, so it asks you to confirm instead of guessing.
|
|
488
|
+
|
|
489
|
+
Upgrade every instance that shares the database before you rely on the cleanup guarantees in [`deleteIndex()`](#deleteindex). Older instances drop search indexes by name and ignore the provisioning journal. See [cleanup limits](#cleanup-limits) for indexes that earlier versions created.
|
|
490
|
+
|
|
301
491
|
### `listIndexes()`
|
|
302
492
|
|
|
303
|
-
Lists the **logical** Mastra index names (the `indexName` values passed to `createIndex`), not physical collection names. For a bring-your-own index whose data lives in an operational collection, the logical index name is returned instead of the physical collection name. The value can be passed straight back into `deleteIndex()`
|
|
493
|
+
Lists the **logical** Mastra index names (the `indexName` values passed to `createIndex`), not physical collection names. For a bring-your-own index whose data lives in an operational collection, the logical index name is returned instead of the physical collection name. The value can be passed straight back into `describeIndex()`, and into `deleteIndex()` for indexes Mastra has ownership records for. A legacy managed index needs [`claimLegacyIndex()`](#claimlegacyindex) first. Managed indexes created before durable metadata was introduced are still discovered via their `${name}_vector_index` search index. The internal registry and provisioning journal collections are never listed.
|
|
304
494
|
|
|
305
495
|
Returns: `Promise<string[]>`
|
|
306
496
|
|
|
@@ -308,7 +498,7 @@ Returns: `Promise<string[]>`
|
|
|
308
498
|
|
|
309
499
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
310
500
|
|
|
311
|
-
> **Bring-your-own collections are read-only by default.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a USER-category error on a BYO index unless it was created with `allowWrites: true
|
|
501
|
+
> **Bring-your-own collections are read-only by default.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a USER-category error on a BYO index unless it was created with the deprecated `allowWrites: true` option. See [Indexing an existing collection](#indexing-an-existing-collection).
|
|
312
502
|
|
|
313
503
|
**indexName** (`string`): Name of the collection containing the vector
|
|
314
504
|
|
|
@@ -444,7 +634,7 @@ Any other field the `autoEmbed` index definition accepts is forwarded to MongoDB
|
|
|
444
634
|
|
|
445
635
|
**Important notes:**
|
|
446
636
|
|
|
447
|
-
- Automated Embedding
|
|
637
|
+
- On MongoDB Atlas, Automated Embedding isn't a Preview feature, and the cluster needs storage auto-scaling enabled. On self-managed deployments it's a Preview feature that needs `mongot` configured with a Voyage AI API key. For local development, use the `mongodb/mongodb-atlas-local:preview` image.
|
|
448
638
|
- The Voyage AI API key must be provisioned through the Atlas UI. A key issued directly by Voyage AI is rejected by the default embedding endpoint.
|
|
449
639
|
- **MongoDB stores the generated vectors outside your collection**, so documents carry text only. `includeVector: true` isn't supported on an `autoEmbed` index and throws.
|
|
450
640
|
- Embeddings are generated asynchronously. A query can legitimately return no results for a short time after a write, even once the index reports ready.
|
|
@@ -494,17 +684,31 @@ console.log(hits[0].metadata.amount, hits[0].metadata.customField)
|
|
|
494
684
|
await store.createSearchIndex({ indexName: 'precedents', fields: ['note'] })
|
|
495
685
|
```
|
|
496
686
|
|
|
687
|
+
The diagram shows what `MongoDBVector` reads, writes, and drops in a bring-your-own setup.
|
|
688
|
+
|
|
689
|
+

|
|
690
|
+
|
|
691
|
+
<details>
|
|
692
|
+
**Text version of the diagram**
|
|
693
|
+
|
|
694
|
+
</details>
|
|
695
|
+
|
|
497
696
|
**Important notes:**
|
|
498
697
|
|
|
499
698
|
- The collection must already exist and contain documents with an `embedding` field (or the custom `embeddingFieldPath` you configured)
|
|
500
699
|
- The collection is never created or dropped when using `collectionName`
|
|
501
|
-
- **A BYO index is read-only
|
|
700
|
+
- **A BYO index is read-only.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a clear error rather than mutating caller-owned operational documents. Write embeddings into the same documents from your application, or use `autoEmbed` and let MongoDB generate them. The deprecated `allowWrites: true` option still lets the store write. Entries written by older versions without the flag are treated as read-only (fail closed).
|
|
502
701
|
- Use `metadataMode: 'document'` when querying to retrieve the full source document as `metadata`
|
|
503
702
|
- In `'document'` mode the embedding is omitted from `metadata` by default; pass `includeVector: true` to retain it (and also expose it as a top-level `vector`)
|
|
504
703
|
- **Filtering in `'document'` mode operates on root document fields**, not a nested `metadata.` subdocument. `filter: { lane: 'fraud' }` matches the top-level `lane` field of your operational documents (in the default `'field'` mode, bare fields are rewritten to `metadata.<field>` for managed collections). Both the pushdown and `$match` fallback paths honor this.
|
|
505
704
|
- **Native `ObjectId` `_id`s are supported.** Operational collections commonly key on `ObjectId`; query results coerce `_id` to a string (the `QueryResult.id` contract), and `deleteVector()`/`updateVector()`/`deleteVectors()` accept that string and match the underlying `ObjectId` document. Managed collections (string `_id`s) are unaffected.
|
|
506
705
|
- Full-text and hybrid search on a BYO collection are **opt-in**: no full-text index is auto-created, so call `createSearchIndex()` before `textQuery()`/`hybridQuery()`. The full-text index builds asynchronously. Call `waitForSearchIndexReady()` (or pass `waitUntilReady: true`) before an immediate text/hybrid query.
|
|
507
|
-
- `deleteIndex()` on a BYO index drops the vector
|
|
706
|
+
- `deleteIndex()` on a BYO index drops the vector and text indexes Mastra created but **preserves** the collection, its documents, and any search index that existed before
|
|
707
|
+
- To filter in `'document'` mode without loading candidate `_id`s, declare the root fields you filter on: `createIndex({ ..., filterFields: ['lane'] })`
|
|
708
|
+
|
|
709
|
+
> **Warning:** `allowWrites` is deprecated and will be removed in the next major version. With `allowWrites: true`, `deleteVector()` and `deleteVectors()` delete your original documents, not only their embeddings, and `upsert()` replaces each document's `metadata` field. The setting is stored with the index, so it applies to every process that uses that index name.
|
|
710
|
+
>
|
|
711
|
+
> `allowWrites` is a guard in Mastra, not database access control. It doesn't limit the MongoDB user, and it doesn't stop `createIndex()`, `createSearchIndex()`, or `deleteIndex()` from managing search indexes and the `__mastra_vector_indexes__` registry. To enforce read-only access, connect with a MongoDB role that can only read the collection, and use a separate user to create indexes.
|
|
508
712
|
|
|
509
713
|
## Best practices
|
|
510
714
|
|
package/.docs/integrations.md
CHANGED
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
- [Firecrawl](https://mastra.ai/integrations/tools/firecrawl)
|
|
134
134
|
- [Parallel](https://mastra.ai/integrations/tools/parallel)
|
|
135
135
|
- [Perplexity](https://mastra.ai/integrations/tools/perplexity)
|
|
136
|
+
- [Sanity Context](https://mastra.ai/integrations/tools/sanity-context)
|
|
136
137
|
- [Tavily](https://mastra.ai/integrations/tools/tavily)
|
|
137
138
|
|
|
138
139
|
## Voice
|
|
@@ -110,7 +110,7 @@ class MyPrivateGateway extends MastraModelGateway {
|
|
|
110
110
|
return {
|
|
111
111
|
'my-provider': {
|
|
112
112
|
name: 'My Provider',
|
|
113
|
-
models: ['openai/gpt-6.1-sol', 'anthropic/claude-sonnet-5
|
|
113
|
+
models: ['openai/gpt-6.1-sol', 'anthropic/claude-sonnet-5.5'],
|
|
114
114
|
apiKeyEnvVar: 'MY_API_KEY',
|
|
115
115
|
gateway: this.id,
|
|
116
116
|
url: this.baseURL,
|
|
@@ -4,23 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
# Mastra
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Mastra Gateway is one OpenAI- and Anthropic-compatible API for models from many providers, with routing, failover, bring-your-own-key, and per-request cost tracking.
|
|
8
8
|
|
|
9
|
-
Learn more in the [Gateway documentation](https://
|
|
9
|
+
Learn more in the [Gateway documentation](https://mastra.ai/docs/mastra-platform/gateway/overview).
|
|
10
10
|
|
|
11
11
|
## Get an API key
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Add credits in **Billing** at [projects.mastra.ai](https://projects.mastra.ai), then create a key in **Gateway** > **API keys**. Keys start with `msk-gateway-`. See the [Quickstart](https://mastra.ai/docs/mastra-platform/gateway/quickstart).
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
Define your API key as an environment variable:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
MASTRA_GATEWAY_API_KEY=
|
|
20
|
+
MASTRA_GATEWAY_API_KEY=msk-gateway-...
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Set
|
|
23
|
+
Set a model ID with the `mastra/` prefix:
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
26
|
import { Agent } from "@mastra/core/agent";
|
|
@@ -29,11 +29,11 @@ const agent = new Agent({
|
|
|
29
29
|
id: "my-agent",
|
|
30
30
|
name: "My Agent",
|
|
31
31
|
instructions: "You are a helpful assistant",
|
|
32
|
-
model: "mastra/openai/gpt-
|
|
32
|
+
model: "mastra/openai/gpt-6.1-sol"
|
|
33
33
|
});
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Use the same prefix for embedding models
|
|
36
|
+
Use the same prefix for embedding models:
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
@@ -41,40 +41,12 @@ import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
|
41
41
|
const embedder = new ModelRouterEmbeddingModel("mastra/openai/text-embedding-3-small");
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import { weatherAgent } from "./agents/weather-agent";
|
|
48
|
-
|
|
49
|
-
const memory = {
|
|
50
|
-
thread: "assistant-thread-1",
|
|
51
|
-
resource: "user-42",
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const result = await weatherAgent.stream("My name is Alex and I prefer concise answers.", {
|
|
55
|
-
memory,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
for await (const chunk of result.textStream) {
|
|
59
|
-
process.stdout.write(chunk);
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
A gateway with a Gateway project key (`msk_...`) stores each thread's observations when it serves the request with its own provider keys and memory is enabled for the project. A gateway with an organization key (`msk-gateway-...` or `mskv2_...`) is served without the memory API, so it doesn't. Configure [`Memory`](https://mastra.ai/docs/memory/observational-memory) with `observationalMemory: true` in that case: Observational Memory then runs against your storage adapter instead of the gateway.
|
|
64
|
-
|
|
65
|
-
When a request is routed with your own provider key, or memory is disabled for the project, the gateway proxies it without storing observations while Mastra skips local Observational Memory for a `mastra/` model on a project key. Use gateway-managed provider keys with project memory enabled when the thread has to be stored.
|
|
66
|
-
|
|
67
|
-
## Configuration
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
# Use gateway API key
|
|
71
|
-
MASTRA_GATEWAY_API_KEY=your-gateway-key
|
|
72
|
-
```
|
|
44
|
+
For conversation memory, see [Memory](https://mastra.ai/docs/memory/overview).
|
|
73
45
|
|
|
74
46
|
## Learn more
|
|
75
47
|
|
|
76
|
-
- [
|
|
77
|
-
- [
|
|
78
|
-
- [
|
|
79
|
-
- [API
|
|
80
|
-
- [
|
|
48
|
+
- [Models and routing](https://mastra.ai/docs/mastra-platform/gateway/models-and-routing)
|
|
49
|
+
- [Keys and BYOK](https://mastra.ai/docs/mastra-platform/gateway/keys-and-byok)
|
|
50
|
+
- [Usage, pricing, and limits](https://mastra.ai/docs/mastra-platform/gateway/usage-and-limits)
|
|
51
|
+
- [API reference](https://mastra.ai/docs/mastra-platform/gateway/api/chat-completions)
|
|
52
|
+
- [Integrations](https://mastra.ai/docs/mastra-platform/gateway/integrations)
|
|
@@ -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 209 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-4-argon` |
|
|
97
97
|
| `google/gemini-4-carbon` |
|
|
98
98
|
| `google/gemini-4-hydrogen` |
|
|
99
|
+
| `google/gemini-4-neon` |
|
|
99
100
|
| `google/gemini-embedding-001` |
|
|
100
101
|
| `google/gemini-embedding-2` |
|
|
101
102
|
| `google/gemini-flash-latest` |
|
|
@@ -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 288 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
|
|
|
@@ -73,6 +73,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
73
73
|
| `gemini/gemini-4-argon` |
|
|
74
74
|
| `gemini/gemini-4-carbon` |
|
|
75
75
|
| `gemini/gemini-4-hydrogen` |
|
|
76
|
+
| `gemini/gemini-4-neon` |
|
|
76
77
|
| `gemini/gemini-flash-latest` |
|
|
77
78
|
| `gemini/gemini-flash-lite-latest` |
|
|
78
79
|
| `gemini/gemini-nano-banana-2.1` |
|
|
@@ -138,6 +138,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
138
138
|
| `google/gemini-4-argon` |
|
|
139
139
|
| `google/gemini-4-carbon` |
|
|
140
140
|
| `google/gemini-4-hydrogen` |
|
|
141
|
+
| `google/gemini-4-neon` |
|
|
141
142
|
| `google/gemini-nano-banana-2.1` |
|
|
142
143
|
| `google/gemini-omni-1.1-flash` |
|
|
143
144
|
| `google/gemini-omni-1.2-flash` |
|
|
@@ -382,7 +383,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
382
383
|
| `thedrummer/unslopnemo-12b` |
|
|
383
384
|
| `thinkingmachines/inkling` |
|
|
384
385
|
| `thinkingmachines/inkling-2-small` |
|
|
385
|
-
| `thinkingmachines/inkling-2-small:free` |
|
|
386
386
|
| `thinkingmachines/inkling-small` |
|
|
387
387
|
| `unbiased/pareto-26.10` |
|
|
388
388
|
| `unbiased/pareto-26.10-preview` |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Requesty
|
|
6
6
|
|
|
7
|
-
Requesty aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
Requesty aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 182 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Requesty documentation](https://requesty.ai/solution/llm-routing/models).
|
|
10
10
|
|
|
@@ -100,6 +100,9 @@ REQUESTY_API_KEY=your-gateway-key
|
|
|
100
100
|
| `gemini-4-hydrogen` |
|
|
101
101
|
| `gemini-4-hydrogen@eu` |
|
|
102
102
|
| `gemini-4-hydrogen@us` |
|
|
103
|
+
| `gemini-4-neon` |
|
|
104
|
+
| `gemini-4-neon@eu` |
|
|
105
|
+
| `gemini-4-neon@us` |
|
|
103
106
|
| `gemma-4-26b-a4b-it` |
|
|
104
107
|
| `gemma-4-31b-it` |
|
|
105
108
|
| `glm-5.1` |
|
|
@@ -141,6 +144,10 @@ REQUESTY_API_KEY=your-gateway-key
|
|
|
141
144
|
| `gpt-6.1-sol@eu` |
|
|
142
145
|
| `gpt-6.1-terra` |
|
|
143
146
|
| `gpt-6.1-terra@eu` |
|
|
147
|
+
| `gpt-6.2-astra` |
|
|
148
|
+
| `gpt-6.2-astra@eu` |
|
|
149
|
+
| `gpt-6.2-sol` |
|
|
150
|
+
| `gpt-6.2-sol@eu` |
|
|
144
151
|
| `grok-4.2-beta` |
|
|
145
152
|
| `grok-4.3` |
|
|
146
153
|
| `grok-4.5` |
|
|
@@ -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 418 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
|
|
|
@@ -178,6 +178,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
178
178
|
| `google/gemini-4-argon` |
|
|
179
179
|
| `google/gemini-4-carbon` |
|
|
180
180
|
| `google/gemini-4-hydrogen` |
|
|
181
|
+
| `google/gemini-4-neon` |
|
|
181
182
|
| `google/gemini-embedding-001` |
|
|
182
183
|
| `google/gemini-embedding-2` |
|
|
183
184
|
| `google/gemini-nano-banana-2.1` |
|
|
@@ -383,6 +384,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
383
384
|
| `sakana/fugu-ultra` |
|
|
384
385
|
| `sakana/fugu-ultra-v2` |
|
|
385
386
|
| `sakana/namazu` |
|
|
387
|
+
| `scaledown/extract-1` |
|
|
386
388
|
| `scaledown/scaledown-extract-1` |
|
|
387
389
|
| `scaledown/scaledown-summarize-1` |
|
|
388
390
|
| `spacexai/grok-4.20-multi-agent` |
|