@mastra/mcp-docs-server 1.2.7-alpha.1 → 1.2.7-alpha.12
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/agent-builder/integrations.md +45 -3
- package/.docs/docs/agent-builder/overview.md +4 -3
- package/.docs/docs/agent-builder/skill-registries.md +1 -3
- package/.docs/docs/agent-controller/modes.md +1 -1
- package/.docs/docs/agent-controller/overview.md +4 -3
- package/.docs/docs/agent-controller/session.md +3 -5
- package/.docs/docs/agents/a2a.md +2 -1
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/agents/code-mode.md +1 -1
- package/.docs/docs/agents/guardrails.md +10 -9
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +5 -5
- package/.docs/docs/agents/skills.md +3 -5
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -4
- package/.docs/docs/agents/using-tools.md +2 -4
- package/.docs/docs/browser/agent-browser.md +1 -3
- package/.docs/docs/browser/browser-viewer.md +1 -3
- package/.docs/docs/browser/overview.md +2 -1
- package/.docs/docs/browser/recording.md +1 -1
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/capabilities/channels/discord.md +98 -0
- package/.docs/docs/capabilities/channels/other-adapters.md +68 -0
- package/.docs/docs/capabilities/channels/overview.md +255 -0
- package/.docs/docs/capabilities/channels/slack.md +225 -0
- package/.docs/docs/capabilities/channels/teams.md +100 -0
- package/.docs/docs/capabilities/channels/telegram.md +98 -0
- package/.docs/docs/capabilities/channels/whatsapp.md +99 -0
- package/.docs/docs/deployment/mastra-server.md +2 -4
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/prompts.md +1 -1
- package/.docs/docs/editor/tools.md +3 -5
- package/.docs/docs/evals/built-in-scorers.md +2 -2
- package/.docs/docs/evals/custom-scorers.md +1 -3
- package/.docs/docs/evals/datasets/overview.md +4 -5
- package/.docs/docs/evals/datasets/running-experiments.md +10 -8
- package/.docs/docs/evals/evals-with-memory.md +1 -3
- package/.docs/docs/evals/gates-and-verdicts.md +2 -4
- package/.docs/docs/evals/overview.md +4 -1
- package/.docs/docs/evals/quick-checks.md +3 -5
- package/.docs/docs/getting-started/file-based-agents.md +116 -0
- package/.docs/docs/getting-started/manual-install.md +17 -4
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/long-running-agents/background-tasks.md +3 -3
- package/.docs/docs/long-running-agents/durable-agents.md +5 -7
- package/.docs/docs/long-running-agents/goals.md +5 -7
- package/.docs/docs/long-running-agents/schedules.md +1 -1
- package/.docs/docs/long-running-agents/signal-providers.md +1 -3
- package/.docs/docs/long-running-agents/signals.md +12 -23
- package/.docs/docs/mastra-platform/database.md +2 -2
- package/.docs/docs/mastra-platform/github.md +1 -1
- package/.docs/docs/mastra-platform/observability.md +5 -1
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +6 -10
- package/.docs/docs/memory/memory-processors.md +67 -0
- package/.docs/docs/memory/message-history.md +56 -2
- package/.docs/docs/memory/observational-memory.md +5 -4
- package/.docs/docs/memory/overview.md +8 -6
- package/.docs/docs/memory/semantic-recall.md +36 -2
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -3
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/rag/vector-databases.md +7 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/better-auth.md +2 -2
- package/.docs/docs/server/auth/clerk.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/google.md +3 -3
- package/.docs/docs/server/auth/jwt.md +2 -2
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +4 -4
- package/.docs/docs/server/server-adapters.md +8 -8
- package/.docs/docs/storage/overview.md +214 -0
- package/.docs/docs/studio/auth.md +1 -3
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/voice/livekit.md +101 -4
- package/.docs/docs/workflows/agents-and-tools.md +3 -5
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workflows/overview.md +6 -7
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +2 -2
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/concepts/streaming.md +3 -3
- package/.docs/guides/getting-started/quickstart.md +4 -2
- package/.docs/guides/guide/chef-michel.md +0 -2
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +0 -2
- package/.docs/models/embeddings.md +119 -0
- package/.docs/models/environment-variables.md +7 -0
- package/.docs/models/gateways/netlify.md +4 -1
- package/.docs/models/gateways/openrouter.md +10 -7
- package/.docs/models/gateways/vercel.md +8 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abacus.md +44 -14
- package/.docs/models/providers/crossmodel.md +109 -0
- package/.docs/models/providers/empiriolabs.md +106 -0
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/llmgateway.md +185 -181
- package/.docs/models/providers/meta.md +101 -0
- package/.docs/models/providers/model-oracle-ai.md +87 -0
- package/.docs/models/providers/nano-gpt.md +2 -2
- package/.docs/models/providers/neon.md +40 -29
- package/.docs/models/providers/nvidia.md +1 -3
- package/.docs/models/providers/openai.md +6 -1
- package/.docs/models/providers/opencode.md +6 -2
- package/.docs/models/providers/pioneer.md +148 -0
- package/.docs/models/providers/poolside.md +6 -5
- package/.docs/models/providers/routing-run.md +23 -34
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/unorouter.md +95 -0
- package/.docs/models/providers/wandb.md +21 -14
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers/zenifra.md +73 -0
- package/.docs/models/providers.md +7 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +3 -3
- package/.docs/reference/agent-controller/session.md +4 -4
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/agents/inngest-agent.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +3 -3
- package/.docs/reference/auth/google.md +5 -5
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +3 -3
- package/.docs/reference/cli/mastra.md +119 -12
- package/.docs/reference/code-sdk/mount-agent-controller.md +76 -0
- package/.docs/reference/coding-agent/create-coding-agent.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/evals/checks.md +4 -4
- package/.docs/reference/evals/create-scorer.md +8 -0
- package/.docs/reference/file-based-agents/config.md +97 -0
- package/.docs/reference/file-based-agents/instructions.md +54 -0
- package/.docs/reference/file-based-agents/logger.md +26 -0
- package/.docs/reference/file-based-agents/memory.md +58 -0
- package/.docs/reference/file-based-agents/observability.md +32 -0
- package/.docs/reference/file-based-agents/processors.md +56 -0
- package/.docs/reference/file-based-agents/scorers.md +54 -0
- package/.docs/reference/file-based-agents/server.md +37 -0
- package/.docs/reference/file-based-agents/skills.md +56 -0
- package/.docs/reference/file-based-agents/storage.md +30 -0
- package/.docs/reference/file-based-agents/studio.md +56 -0
- package/.docs/reference/file-based-agents/subagents.md +123 -0
- package/.docs/reference/file-based-agents/tools.md +63 -0
- package/.docs/reference/file-based-agents/workflows.md +52 -0
- package/.docs/reference/file-based-agents/workspace.md +74 -0
- package/.docs/reference/index.md +18 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/observational-memory.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/memory/summarizeConversation.md +99 -0
- package/.docs/reference/memory/summarizeThread.md +93 -0
- package/.docs/{docs/getting-started → reference}/project-structure.md +3 -10
- package/.docs/reference/pubsub/lease-provider.md +5 -5
- package/.docs/reference/server/express-adapter.md +1 -3
- package/.docs/reference/server/fastify-adapter.md +1 -3
- package/.docs/reference/server/hono-adapter.md +1 -3
- package/.docs/reference/server/koa-adapter.md +1 -3
- package/.docs/reference/server/nestjs-adapter.md +1 -3
- package/.docs/reference/signals/task-signal-provider.md +1 -1
- package/.docs/reference/storage/clickhouse.md +34 -2
- package/.docs/reference/storage/cloudflare-d1.md +1 -1
- package/.docs/reference/storage/composite.md +64 -6
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/mongodb.md +46 -46
- package/.docs/reference/storage/retention.md +74 -6
- package/.docs/reference/tools/create-tool.md +2 -2
- package/.docs/reference/tools/mcp-client.md +22 -0
- package/.docs/reference/tools/mcp-server.md +161 -4
- package/.docs/reference/vectors/mongodb.md +93 -4
- package/.docs/reference/voice/livekit.md +272 -8
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +1 -3
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -3
- package/.docs/reference/workspace/apple-container-sandbox.md +6 -8
- package/.docs/reference/workspace/archil-filesystem.md +1 -3
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -3
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -3
- package/.docs/reference/workspace/daytona-sandbox.md +1 -3
- package/.docs/reference/workspace/docker-sandbox.md +1 -3
- package/.docs/reference/workspace/e2b-sandbox.md +1 -3
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -3
- package/.docs/reference/workspace/gcs-filesystem.md +1 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -3
- package/.docs/reference/workspace/local-filesystem.md +1 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -3
- package/.docs/reference/workspace/mesa-filesystem.md +4 -4
- package/.docs/reference/workspace/modal-sandbox.md +1 -3
- package/.docs/reference/workspace/railway-sandbox.md +2 -4
- package/.docs/reference/workspace/s3-filesystem.md +1 -3
- package/.docs/reference/workspace/vercel-sandbox.md +5 -7
- package/.docs/reference/workspace/vercel-serverless.md +2 -4
- package/CHANGELOG.md +36 -0
- package/package.json +5 -5
- package/.docs/docs/agents/channels.md +0 -225
- package/.docs/docs/agents/file-based-agents.md +0 -297
- package/.docs/docs/memory/storage.md +0 -267
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Studio provides an interactive UI for building, testing, and managing your agents, workflows, and tools. Run it locally during development, add [authentication](https://mastra.ai/docs/studio/auth), or [deploy it](https://mastra.ai/docs/studio/deployment) to production so your team can manage agents, monitor performance, and gain insights through built-in observability.
|
|
6
6
|
|
|
7
|
-
[
|
|
7
|
+
> **📹 Watch:** Watch [Mastra Studio overview](https://youtu.be/ojGu6Bi4wYk) for a short walkthrough of building, testing, and managing agents in Studio.
|
|
8
8
|
|
|
9
9
|
## Start Studio
|
|
10
10
|
|
|
@@ -162,6 +162,45 @@ export default createLiveKitWorker({
|
|
|
162
162
|
|
|
163
163
|
See the [LiveKit turn detection docs](https://docs.livekit.io/agents/logic/turns/) for all options.
|
|
164
164
|
|
|
165
|
+
## Per-call voices and transcription
|
|
166
|
+
|
|
167
|
+
The top-level `stt` and `tts` options apply to every call. To pick them per call — one voice or language per tenant — set the `configuration.stt` and `configuration.tts` resolvers instead. Each resolver runs once per call with the dispatch metadata, request context, room name, and job context, and returns anything the matching top-level option accepts: a plugin instance or an inference model string. Return `undefined` to fall back to the top-level option.
|
|
168
|
+
|
|
169
|
+
The following example gives each tenant its own text-to-speech voice, keyed off the `tenant` entry in the dispatch metadata:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import * as cartesia from '@livekit/agents-plugin-cartesia'
|
|
173
|
+
|
|
174
|
+
// One voice id per tenant, resolved from the dispatch metadata on each call.
|
|
175
|
+
const tenantVoices: Record<string, string> = {
|
|
176
|
+
meridian: 'your-cartesia-voice-id-1',
|
|
177
|
+
coastal: 'your-cartesia-voice-id-2',
|
|
178
|
+
}
|
|
179
|
+
// The resolver runs during call setup, so cache plugin instances across calls.
|
|
180
|
+
const ttsByVoice = new Map<string, cartesia.TTS>()
|
|
181
|
+
|
|
182
|
+
export default createLiveKitWorker({
|
|
183
|
+
mastra,
|
|
184
|
+
agent: 'support',
|
|
185
|
+
stt: 'deepgram/nova-3',
|
|
186
|
+
tts: 'cartesia/sonic-3',
|
|
187
|
+
configuration: {
|
|
188
|
+
tts: ({ requestContext }) => {
|
|
189
|
+
const voice = tenantVoices[requestContext?.tenant as string]
|
|
190
|
+
if (!voice) return undefined // fall back to the top-level `tts`
|
|
191
|
+
let tts = ttsByVoice.get(voice)
|
|
192
|
+
if (!tts) {
|
|
193
|
+
tts = new cartesia.TTS({ voice })
|
|
194
|
+
ttsByVoice.set(voice, tts)
|
|
195
|
+
}
|
|
196
|
+
return tts
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`configuration.stt` works the same way for per-call transcription, for example a different transcription model or language per tenant. The greeting has a matching per-call form: `configuration.greeting.text` accepts a resolver with the same call context, so one worker can open with each tenant's own phrasing.
|
|
203
|
+
|
|
165
204
|
## Memory and threads
|
|
166
205
|
|
|
167
206
|
When the resolved Mastra agent has memory configured, each call becomes one memory thread:
|
|
@@ -172,7 +211,7 @@ When the resolved Mastra agent has memory configured, each call becomes one memo
|
|
|
172
211
|
|
|
173
212
|
Each turn sends only the new user input; Mastra Memory supplies history, semantic recall, and working memory. Pin a session to an existing thread by passing `threadId` in the connection request body, which is useful for continuing a text conversation by voice. In Studio, starting a call from an open chat binds the call to that thread, and the transcript fills into the chat after each exchange.
|
|
174
213
|
|
|
175
|
-
|
|
214
|
+
When a user interrupts the agent, the in-flight generation aborts and nothing from that turn is persisted at that moment. LiveKit keeps the part the user actually heard in its transcript, and on the next turn the worker re-sends that heard-only fragment so the thread backfills to match the call. A user who hangs up right after interrupting leaves that final fragment unrecorded; see [interrupted turns](https://mastra.ai/reference/voice/livekit) for the details and a reconciliation recipe.
|
|
176
215
|
|
|
177
216
|
## Speak while tools run
|
|
178
217
|
|
|
@@ -189,13 +228,13 @@ export default createLiveKitWorker({
|
|
|
189
228
|
})
|
|
190
229
|
```
|
|
191
230
|
|
|
192
|
-
The phrase is spoken as part of the reply and
|
|
231
|
+
The phrase is spoken as part of the reply and recorded in the transcript.
|
|
193
232
|
|
|
194
233
|
## Generate replies with a workflow
|
|
195
234
|
|
|
196
235
|
By default the worker generates each reply with a Mastra agent. To run multi-step logic per turn (for example classify intent, route, call tools in sequence, then compose a reply), generate replies with a Mastra [workflow](https://mastra.ai/docs/workflows/overview) instead. Set `workflow` in place of `agent`.
|
|
197
236
|
|
|
198
|
-
LiveKit still owns the audio loop and calls into Mastra once per turn, so the workflow runs to completion each turn.
|
|
237
|
+
LiveKit still owns the audio loop and calls into Mastra once per turn, so the workflow runs to completion each turn. The workflow can't suspend or resume, and no conversation state carries between turns. Pass the transcript in through `workflowInput` so the workflow stays stateless:
|
|
199
238
|
|
|
200
239
|
```typescript
|
|
201
240
|
import { createLiveKitWorker, chatContextToMessages } from '@mastra/livekit/worker'
|
|
@@ -233,6 +272,64 @@ const generateResponse = createStep({
|
|
|
233
272
|
|
|
234
273
|
With a workflow, the worker doesn't persist turns automatically the way an agent's `stream()` does. Persist conversation history inside the workflow, or keep the LiveKit transcript as the source of truth and pass it in each turn.
|
|
235
274
|
|
|
275
|
+
## Use Mastra as the LLM component
|
|
276
|
+
|
|
277
|
+
`createLiveKitWorker()` owns the LiveKit session for you. To own the session yourself, use [`MastraLLM`](https://mastra.ai/reference/voice/livekit) instead: a standard LiveKit LLM plugin that puts a Mastra agent in the `llm` slot of your own `voice.AgentSession`. The Mastra app — agent loop, tools, memory, observability — runs on your Mastra server, and the worker reaches it over HTTP. The worker process needs no Mastra app, database, or model provider keys.
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
import { fileURLToPath } from 'node:url'
|
|
281
|
+
import { defineAgent, voice } from '@livekit/agents'
|
|
282
|
+
import * as silero from '@livekit/agents-plugin-silero'
|
|
283
|
+
import { MastraLLM } from '@mastra/livekit/plugin'
|
|
284
|
+
import { runLiveKitWorker } from '@mastra/livekit/worker'
|
|
285
|
+
|
|
286
|
+
export default defineAgent({
|
|
287
|
+
entry: async ctx => {
|
|
288
|
+
await ctx.connect()
|
|
289
|
+
|
|
290
|
+
const session = new voice.AgentSession({
|
|
291
|
+
llm: new MastraLLM({
|
|
292
|
+
remote: { baseUrl: process.env.MASTRA_URL!, agentId: 'support' },
|
|
293
|
+
memory: { thread: ctx.room.name!, resource: 'user-7' },
|
|
294
|
+
}),
|
|
295
|
+
stt: 'deepgram/nova-3',
|
|
296
|
+
tts: 'cartesia/sonic-3',
|
|
297
|
+
vad: await silero.VAD.load(),
|
|
298
|
+
// Required with `memory`: LiveKit enables preemptive generation by default.
|
|
299
|
+
turnHandling: { preemptiveGeneration: { enabled: false } },
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
await session.start({
|
|
303
|
+
// These instructions never reach the Mastra agent; its own instructions apply.
|
|
304
|
+
agent: new voice.Agent({ instructions: 'Replies come from the Mastra agent.' }),
|
|
305
|
+
room: ctx.room,
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
session.say('Hi! How can I help you today?')
|
|
309
|
+
},
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
313
|
+
runLiveKitWorker({ entry: import.meta.url, agentName: 'mastra-voice' })
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Both paths share the same reply pipeline underneath; choose by who should own the session:
|
|
318
|
+
|
|
319
|
+
| | `createLiveKitWorker()` | `MastraLLM` |
|
|
320
|
+
| ------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
321
|
+
| Session ownership | The worker helper builds and manages the `AgentSession` | Your code builds the session; every LiveKit option and hook is yours |
|
|
322
|
+
| Where the Mastra app runs | In the worker process | On your Mastra server, reached over HTTP (or in-process via `agent`) |
|
|
323
|
+
| Worker process needs | Your Mastra app, storage, and model provider keys | Only the LiveKit SDK and network access to your server |
|
|
324
|
+
| Built-in conveniences | Greeting, consent gating, agent-initiated hang-up, thread bootstrap, observability roll-up | Rebuild what you need with the [session helpers](https://mastra.ai/reference/voice/livekit) |
|
|
325
|
+
| Best for | Fastest path to a working voice agent; Studio voice mode | Existing LiveKit apps and full control over the session |
|
|
326
|
+
|
|
327
|
+
Tools stay on the Mastra agent and execute on the server; LiveKit-side tools passed to the session are ignored. Tool activity reaches the worker through `toolFeedback` (spoken filler), `onToolCall` (fires as each tool call starts), and `onTurnComplete` (fires after each reply with the text, tool calls, and token usage). Agent-initiated hang-up takes a few lines: pair `onToolCall` with [`runEndCall()`](https://mastra.ai/reference/voice/livekit).
|
|
328
|
+
|
|
329
|
+
> **Warning:** Don't combine the `memory` option with LiveKit's `preemptiveGeneration`, which LiveKit enables by default in sessions you build yourself. A speculative turn that completes before LiveKit discards it persists a user message and a never-spoken reply to the thread. Set `turnHandling: { preemptiveGeneration: { enabled: false } }` as shown above, or run without `memory` and pass the full transcript each turn.
|
|
330
|
+
|
|
331
|
+
`MastraLLM` also accepts an in-process Mastra `agent` instance — session ownership without a second deployment — or a custom `generate` function. The remote transport is available standalone as [`createRemoteAgentReplyGenerator()`](https://mastra.ai/reference/voice/livekit), which also plugs into `createLiveKitWorker`'s `generate` option to run the batteries-included worker against a remote server.
|
|
332
|
+
|
|
236
333
|
## Server-initiated sessions
|
|
237
334
|
|
|
238
335
|
Use `dispatchVoiceSession()` to add a voice agent to a room from your own code, for example to join an existing room or to drive an outbound [SIP call](https://docs.livekit.io/sip/):
|
|
@@ -255,7 +352,7 @@ When the Mastra instance has [observability](https://mastra.ai/docs/observabilit
|
|
|
255
352
|
- A child span for each LiveKit pipeline metric: speech-to-text, text-to-speech, end-of-utterance (turn detection), voice activity detection, and the model's time-to-first-token. These carry the latency and audio measurements that text traces can't show.
|
|
256
353
|
- A per-model usage roll-up (token, character, and audio totals for the whole call) written to the span when the session ends.
|
|
257
354
|
|
|
258
|
-
The worker is a separate process, so point storage at a backend that accepts concurrent writes from both the server and the worker. SQLite-backed [LibSQL](https://mastra.ai/reference/storage/libsql) works; single-writer stores
|
|
355
|
+
The worker is a separate process, so point storage at a backend that accepts concurrent writes from both the server and the worker. SQLite-backed [LibSQL](https://mastra.ai/reference/storage/libsql) works; single-writer stores don't. Traces, memory, and threads can share one store:
|
|
259
356
|
|
|
260
357
|
```typescript
|
|
261
358
|
import { Mastra } from '@mastra/core/mastra'
|
|
@@ -57,7 +57,7 @@ export const testWorkflow = createWorkflow({})
|
|
|
57
57
|
.commit()
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
Visit [Input Data Mapping](https://mastra.ai/docs/workflows/control-flow) for more information.
|
|
61
61
|
|
|
62
62
|
When no `structuredOutput` option is provided, Mastra agents use a default schema that expects a `prompt` string as input and returns a `text` string as output:
|
|
63
63
|
|
|
@@ -106,9 +106,7 @@ export const testWorkflow = createWorkflow({})
|
|
|
106
106
|
.commit()
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
The `structuredOutput.schema` option accepts any Standard JSON Schema. The agent will generate output conforming to this schema, and the step's `outputSchema` will be automatically set to match.
|
|
110
|
-
|
|
111
|
-
> **Info:** Visit [Structured Output](https://mastra.ai/docs/agents/structured-output) for more options like error handling strategies and streaming with structured output.
|
|
109
|
+
The `structuredOutput.schema` option accepts any Standard JSON Schema. The agent will generate output conforming to this schema, and the step's `outputSchema` will be automatically set to match. Visit [Structured Output](https://mastra.ai/docs/agents/structured-output) for more options like error handling strategies and streaming with structured output.
|
|
112
110
|
|
|
113
111
|
## Using tools in workflows
|
|
114
112
|
|
|
@@ -157,7 +155,7 @@ export const testWorkflow = createWorkflow({})
|
|
|
157
155
|
.commit()
|
|
158
156
|
```
|
|
159
157
|
|
|
160
|
-
|
|
158
|
+
Visit [Input Data Mapping](https://mastra.ai/docs/workflows/control-flow) for more information.
|
|
161
159
|
|
|
162
160
|
## Related
|
|
163
161
|
|
|
@@ -101,8 +101,6 @@ export const testWorkflow = createWorkflow({
|
|
|
101
101
|
.commit()
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
> **📹 Watch:** How to run steps in parallel and optimize your Mastra workflow → [YouTube (3 minutes)](https://youtu.be/GQJxve5Hki4)
|
|
105
|
-
|
|
106
104
|
### Output structure
|
|
107
105
|
|
|
108
106
|
When steps run in parallel, the output is an object where each key is the step's `id` and the value is that step's output. This allows you to access each parallel step's result independently.
|
|
@@ -210,7 +208,7 @@ const writerStep = createStep({
|
|
|
210
208
|
})
|
|
211
209
|
```
|
|
212
210
|
|
|
213
|
-
|
|
211
|
+
Visit [Choosing the right pattern](#choosing-the-right-pattern) to understand when to use `.parallel()` vs `.foreach()`.
|
|
214
212
|
|
|
215
213
|
## Conditional logic with `.branch()`
|
|
216
214
|
|
|
@@ -10,8 +10,6 @@ Workflows let you define complex sequences of tasks using clear, structured step
|
|
|
10
10
|
|
|
11
11
|
Use workflows for tasks that are clearly defined upfront and involve multiple steps with a specific execution order. They give you fine-grained control over how data flows and transforms between steps, and which primitives are called at each stage.
|
|
12
12
|
|
|
13
|
-
> **Tip:** Watch an introduction to workflows, and how they compare to agents on [YouTube (7 minutes)](https://youtu.be/0jg2g3sNvgw).
|
|
14
|
-
|
|
15
13
|
## Core principles
|
|
16
14
|
|
|
17
15
|
Mastra workflows operate using these principles:
|
|
@@ -103,7 +101,7 @@ const step1 = createStep({
|
|
|
103
101
|
})
|
|
104
102
|
```
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
Visit [`Step`](https://mastra.ai/reference/workflows/step) for a full list of configuration options.
|
|
107
105
|
|
|
108
106
|
### Using agents and tools
|
|
109
107
|
|
|
@@ -177,7 +175,7 @@ export const testWorkflow = createWorkflow({
|
|
|
177
175
|
.commit();
|
|
178
176
|
```
|
|
179
177
|
|
|
180
|
-
|
|
178
|
+
Visit [Workflow Class](https://mastra.ai/reference/workflows/workflow) for a full list of configuration options.
|
|
181
179
|
|
|
182
180
|
### Understanding control flow
|
|
183
181
|
|
|
@@ -214,7 +212,7 @@ const step1 = createStep({
|
|
|
214
212
|
})
|
|
215
213
|
```
|
|
216
214
|
|
|
217
|
-
|
|
215
|
+
Visit [Workflow State](https://mastra.ai/docs/workflows/workflow-state) for complete documentation on state schemas, initial state, persistence across suspend/resume, and nested workflows.
|
|
218
216
|
|
|
219
217
|
## Workflows as steps
|
|
220
218
|
|
|
@@ -535,7 +533,7 @@ const step1 = createStep({
|
|
|
535
533
|
})
|
|
536
534
|
```
|
|
537
535
|
|
|
538
|
-
|
|
536
|
+
Visit [Request Context](https://mastra.ai/docs/server/request-context) for more information.
|
|
539
537
|
|
|
540
538
|
> **Tip:** For type-safe request context schema validation, see [Schema Validation](https://mastra.ai/docs/server/request-context).
|
|
541
539
|
|
|
@@ -546,4 +544,5 @@ For a closer look at workflows, see our [Workflow Guide](https://mastra.ai/guide
|
|
|
546
544
|
- [Workflow State](https://mastra.ai/docs/workflows/workflow-state)
|
|
547
545
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
548
546
|
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
549
|
-
- [Error Handling](https://mastra.ai/docs/workflows/error-handling)
|
|
547
|
+
- [Error Handling](https://mastra.ai/docs/workflows/error-handling)
|
|
548
|
+
- 📹 [Agentic workflows with Mastra workshop](https://www.youtube.com/watch?v=HGt8pVPpX9g)
|
|
@@ -145,7 +145,7 @@ export const mastra = new Mastra({
|
|
|
145
145
|
- [Upstash Storage](https://mastra.ai/reference/storage/upstash)
|
|
146
146
|
- [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
|
|
147
147
|
- [DynamoDB](https://mastra.ai/reference/storage/dynamodb)
|
|
148
|
-
- [More storage providers](https://mastra.ai/docs/
|
|
148
|
+
- [More storage providers](https://mastra.ai/docs/storage/overview)
|
|
149
149
|
|
|
150
150
|
## Best practices
|
|
151
151
|
|
|
@@ -411,4 +411,5 @@ External providers may perform additional setup like establishing connections or
|
|
|
411
411
|
- [LSP inspection](https://mastra.ai/docs/workspace/lsp)
|
|
412
412
|
- [Skills](https://mastra.ai/docs/workspace/skills)
|
|
413
413
|
- [Search and indexing](https://mastra.ai/docs/workspace/search)
|
|
414
|
-
- [Workspace class reference](https://mastra.ai/reference/workspace/workspace-class)
|
|
414
|
+
- [Workspace class reference](https://mastra.ai/reference/workspace/workspace-class)
|
|
415
|
+
- 📹 [Introduction to Mastra Workspaces workshop](https://www.youtube.com/watch?v=QcQLiYlJuNQ)
|
|
@@ -15,6 +15,8 @@ A sandbox provider executes commands in a controlled environment:
|
|
|
15
15
|
- **Timeouts**: Prevent long-running commands from hanging
|
|
16
16
|
- **Isolation**: Optional OS-level sandboxing for security
|
|
17
17
|
|
|
18
|
+
> **📹 Watch:** Watch [Mastra remote sandboxes overview](https://www.youtube.com/watch?v=Ix2X-sjVXjw) to see how remote sandboxes give agents an isolated computer to work in.
|
|
19
|
+
|
|
18
20
|
## Supported providers
|
|
19
21
|
|
|
20
22
|
- [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox): Executes commands on the local machine
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
> **Info:** For a full-stack integration approach where Mastra runs directly in your Next.js API routes, see the [Full-Stack Integration Guide](https://www.assistant-ui.com/docs/integrations/frameworks/mastra/full-stack) on Assistant UI's documentation site.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Visit Mastra's [**"UI Dojo"**](https://ui-dojo.mastra.ai/) to see real-world examples of Assistant UI integrated with Mastra.
|
|
10
10
|
|
|
11
11
|
## Integration guide
|
|
12
12
|
|
|
@@ -8,7 +8,7 @@ The same Mastra agent that powers your in-app copilot can also run as a bot in m
|
|
|
8
8
|
|
|
9
9
|
## How it fits together
|
|
10
10
|
|
|
11
|
-
Your Mastra agent stays where it
|
|
11
|
+
Your Mastra agent stays where it's, exposed through `registerCopilotKit()` as described in [CopilotKit overview](https://mastra.ai/guides/build-your-ui/copilotkit/overview). The bot is a separate process built with `@copilotkit/bot`: you attach one or more platform adapters and point the bot at your agent. `createBot` takes an array of adapters, so a single bot can serve several platforms at once.
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { createBot } from '@copilotkit/bot'
|
|
@@ -37,7 +37,7 @@ export const weatherAgent = new Agent({
|
|
|
37
37
|
})
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
On the frontend, register a renderer for the tool by name with `useRenderTool`. It
|
|
40
|
+
On the frontend, register a renderer for the tool by name with `useRenderTool`. It's render-only (it doesn't execute the tool); the `render` function receives the tool call's `status` and, once the agent returns, its `result`:
|
|
41
41
|
|
|
42
42
|
```tsx
|
|
43
43
|
import { z } from 'zod'
|
|
@@ -152,7 +152,7 @@ The catalog defines the primitives (their schemas) and the renderers (how each p
|
|
|
152
152
|
|
|
153
153
|
At the far end of the spectrum, the agent owns the entire surface: the UI is invented elsewhere and sandboxed in your app. CopilotKit supports this through **MCP Apps**, where an MCP server ships UI that renders inside your application. This tier trades determinism for novelty and is the most experimental point on the spectrum.
|
|
154
154
|
|
|
155
|
-
The path of least resistance keeps the frontend untouched: your existing `<CopilotKit>` provider is enough. On the backend, point `registerCopilotKit()` at one or more MCP servers with the `mcpApps` option (it
|
|
155
|
+
The path of least resistance keeps the frontend untouched: your existing `<CopilotKit>` provider is enough. On the backend, point `registerCopilotKit()` at one or more MCP servers with the `mcpApps` option (it's forwarded to the CopilotKit runtime):
|
|
156
156
|
|
|
157
157
|
```typescript
|
|
158
158
|
registerCopilotKit({
|
|
@@ -10,7 +10,7 @@ Visit the [CopilotKit documentation](https://docs.copilotkit.ai/) to learn more
|
|
|
10
10
|
|
|
11
11
|
> **Info:** For a full-stack integration approach where Mastra runs directly in your Next.js API routes, see the [CopilotKit Quickstart](https://docs.copilotkit.ai/mastra/quickstart) guide.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Visit Mastra's ["UI Dojo"](https://ui-dojo.mastra.ai/) to see real-world examples of CopilotKit integrated with Mastra.
|
|
14
14
|
|
|
15
15
|
## Integration guide
|
|
16
16
|
|
|
@@ -29,7 +29,7 @@ for await (const chunk of stream.textStream) {
|
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
|
|
33
33
|
|
|
34
34
|
> **Tip:** For agents that dispatch [background tasks](https://mastra.ai/docs/long-running-agents/background-tasks), use [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle) to keep the stream open until those tasks complete and the agent has had a chance to respond to their results.
|
|
35
35
|
|
|
@@ -101,7 +101,7 @@ for await (const chunk of stream) {
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
Visit [Run.stream()](https://mastra.ai/reference/streaming/workflows/stream) for more information.
|
|
105
105
|
|
|
106
106
|
### Output from `Run.stream()`
|
|
107
107
|
|
|
@@ -160,7 +160,7 @@ for await (const chunk of stream) {
|
|
|
160
160
|
}
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
|
|
164
164
|
|
|
165
165
|
### Example agent output
|
|
166
166
|
|
|
@@ -8,6 +8,8 @@ The `create mastra` CLI command is the quickest way to get started. It walks you
|
|
|
8
8
|
|
|
9
9
|
If you need more control over the setup, see the [manual installation guide](https://mastra.ai/docs/getting-started/manual-install). You can also use [`mastra init`](https://mastra.ai/reference/cli/mastra) for existing projects.
|
|
10
10
|
|
|
11
|
+
> **📹 Watch:** Watch [Mastra AI agent course](https://www.youtube.com/watch?v=lCmf_qrGfGA) for a guided introduction to building agents with Mastra.
|
|
12
|
+
|
|
11
13
|
## Before you begin
|
|
12
14
|
|
|
13
15
|
- You'll need an API key from a supported [model provider](https://mastra.ai/models). If you don't have a preference, use [OpenAI](https://mastra.ai/models/providers/openai).
|
|
@@ -50,7 +52,7 @@ The wizard creates a new directory for your project with a `src/mastra` folder c
|
|
|
50
52
|
- `workflows/weather-workflow.ts`: A workflow that runs the weather agent
|
|
51
53
|
- `scorers/weather-scorer.ts`: A scorer to evaluate the weather agent's responses
|
|
52
54
|
|
|
53
|
-
Depending on your choices, you'll also end up with [Mastra Skills](https://mastra.ai/docs/getting-started/build-with-ai) or the [MCP Docs Server](https://mastra.ai/docs/getting-started/build-with-ai) installed.
|
|
55
|
+
Depending on your choices, you'll also end up with [Mastra Skills](https://mastra.ai/docs/getting-started/build-with-ai) or the [MCP Docs Server](https://mastra.ai/docs/getting-started/build-with-ai) installed. Learn more about Mastra's [project structure](https://mastra.ai/reference/project-structure).
|
|
54
56
|
|
|
55
57
|
> **Tip:** You can use [flags](https://mastra.ai/reference/cli/create-mastra) with `create mastra` like `--no-example` to skip the example weather agent or `--template` to start from a specific [template](https://mastra.ai/templates).
|
|
56
58
|
|
|
@@ -58,7 +60,7 @@ Depending on your choices, you'll also end up with [Mastra Skills](https://mastr
|
|
|
58
60
|
|
|
59
61
|
Once setup is complete, follow the instructions in your terminal to start the Mastra dev server, then open Studio at [localhost:4111](http://localhost:4111).
|
|
60
62
|
|
|
61
|
-
Try asking about the weather. If your API key is set up correctly, you'll get a response
|
|
63
|
+
Try asking about the weather. If your API key is set up correctly, you'll get a response in Studio.
|
|
62
64
|
|
|
63
65
|
[Studio](https://mastra.ai/docs/studio/overview) lets you rapidly build and prototype agents without needing to build a UI. Once you're ready, you can integrate your Mastra agent into your app using the guides below.
|
|
64
66
|
|
|
@@ -6,8 +6,6 @@ In this guide, you'll create a "Chef Assistant" agent that helps users cook meal
|
|
|
6
6
|
|
|
7
7
|
You'll learn how to create the agent and register it with Mastra. Next, you'll interact with the agent through your terminal and get to know different response formats. Lastly, you'll access the agent through Mastra's local API endpoints.
|
|
8
8
|
|
|
9
|
-
[YouTube video player](https://www.youtube-nocookie.com/embed/_tZhOqHCrF0)
|
|
10
|
-
|
|
11
9
|
## Prerequisites
|
|
12
10
|
|
|
13
11
|
- Node.js `v22.13.0` or later installed
|
|
@@ -182,12 +182,12 @@ You can extend this agent to:
|
|
|
182
182
|
|
|
183
183
|
- [Deploy your application](https://mastra.ai/docs/deployment/overview) and update the Slack **Request URL** to your production endpoint
|
|
184
184
|
- Add more adapters (Discord, Telegram) to the same agent so it responds on multiple platforms
|
|
185
|
-
- Configure [multimodal content](https://mastra.ai/docs/
|
|
185
|
+
- Configure [multimodal content](https://mastra.ai/docs/capabilities/channels/overview) to let your agent process images, video, and audio shared in chat
|
|
186
186
|
- Add [tools](https://mastra.ai/docs/agents/using-tools) to give the agent access to external APIs and data
|
|
187
187
|
|
|
188
188
|
Learn more:
|
|
189
189
|
|
|
190
|
-
- [Channels overview](https://mastra.ai/docs/
|
|
190
|
+
- [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
|
|
191
191
|
- [Studio](https://mastra.ai/docs/studio/overview)
|
|
192
192
|
- [Deployment overview](https://mastra.ai/docs/deployment/overview)
|
|
193
193
|
- [Chat SDK adapter docs](https://chat-sdk.dev)
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
In this guide, you're going to create an agent that fetches the last day's closing stock price for a given symbol. You'll learn how to create a tool, add it to an agent, and use the agent to fetch stock prices.
|
|
6
6
|
|
|
7
|
-
[YouTube video player](https://www.youtube-nocookie.com/embed/rIaZ4l7y9wo)
|
|
8
|
-
|
|
9
7
|
## Prerequisites
|
|
10
8
|
|
|
11
9
|
- Node.js `v22.13.0` or later installed
|
|
@@ -37,17 +37,136 @@ const embedder = new ModelRouterEmbeddingModel("openai/text-embedding-3-small");
|
|
|
37
37
|
const embedder = new ModelRouterEmbeddingModel("google/gemini-embedding-001");
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
### VoyageAI
|
|
41
|
+
|
|
42
|
+
VoyageAI provides specialized embedding models optimized for retrieval tasks. These models are available as standalone packages:
|
|
43
|
+
|
|
44
|
+
**npm**:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @mastra/voyageai
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**pnpm**:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add @mastra/voyageai
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Yarn**:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
yarn add @mastra/voyageai
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Bun**:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
bun add @mastra/voyageai
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Available models:**
|
|
69
|
+
|
|
70
|
+
- `voyage-4-large` - 1024 dimensions (default), supports 256-2048 dimensions, best general-purpose and multilingual retrieval quality (120k max tokens per batch)
|
|
71
|
+
- `voyage-4` - 1024 dimensions (default), supports 256-2048 dimensions, optimized for general-purpose and multilingual retrieval (320k max tokens per batch)
|
|
72
|
+
- `voyage-4-lite` - 1024 dimensions (default), supports 256-2048 dimensions, optimized for latency and cost (1M max tokens per batch)
|
|
73
|
+
- `voyage-code-3` - 1024 dimensions (default), supports 256-2048 dimensions, optimized for code retrieval
|
|
74
|
+
- `voyage-finance-2` - 1024 dimensions, optimized for finance retrieval and RAG
|
|
75
|
+
- `voyage-law-2` - 1024 dimensions, optimized for legal retrieval and RAG (16k context)
|
|
76
|
+
- `voyage-3-large` - 1024 dimensions (default), supports 256-2048 dimensions (previous generation)
|
|
77
|
+
- `voyage-3.5` - 1024 dimensions (default), supports 256-2048 dimensions (previous generation)
|
|
78
|
+
- `voyage-3.5-lite` - 1024 dimensions (default), supports 256-2048 dimensions, optimized for latency and cost (previous generation)
|
|
79
|
+
- `voyage-multimodal-3.5` - 1024 dimensions, supports text + images
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { voyage, voyageEmbedding } from "@mastra/voyageai";
|
|
83
|
+
|
|
84
|
+
// Use default model (voyage-3.5)
|
|
85
|
+
const { embeddings } = await voyage.doEmbed({
|
|
86
|
+
values: ["Hello world"],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Use specific model (voyage-3-large)
|
|
90
|
+
const largeEmbeddings = await voyage.large.doEmbed({
|
|
91
|
+
values: ["More complex content"],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Custom configuration
|
|
95
|
+
const customModel = voyageEmbedding({
|
|
96
|
+
model: "voyage-3.5",
|
|
97
|
+
inputType: "query", // or 'document'
|
|
98
|
+
outputDimension: 512, // 256, 512, 1024, or 2048
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const { embeddings: customEmbeddings } = await customModel.doEmbed({
|
|
102
|
+
values: ["Custom configuration example"],
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**VoyageAI with MongoDB:**
|
|
107
|
+
|
|
108
|
+
VoyageAI works seamlessly with MongoDB Atlas Vector Search:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { voyage } from "@mastra/voyageai";
|
|
112
|
+
import { MongoDBVector } from "@mastra/mongodb";
|
|
113
|
+
|
|
114
|
+
const mongoVector = new MongoDBVector({
|
|
115
|
+
id: "mongodb-vector",
|
|
116
|
+
uri: process.env.MONGODB_URI,
|
|
117
|
+
dbName: process.env.MONGODB_DB_NAME,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Create index matching VoyageAI dimensions
|
|
121
|
+
await mongoVector.createIndex({
|
|
122
|
+
indexName: "documents",
|
|
123
|
+
dimension: 1024, // voyage-3.5 default
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Generate and store embeddings
|
|
127
|
+
const { embeddings } = await voyage.doEmbed({
|
|
128
|
+
values: chunks.map((chunk) => chunk.text),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await mongoVector.upsert({
|
|
132
|
+
indexName: "documents",
|
|
133
|
+
vectors: embeddings,
|
|
134
|
+
metadata: chunks.map((chunk) => ({ text: chunk.text })),
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Multimodal embeddings (text + images):**
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { voyage } from "@mastra/voyageai";
|
|
142
|
+
|
|
143
|
+
const { embeddings } = await voyage.multimodal.doEmbed({
|
|
144
|
+
values: [
|
|
145
|
+
{
|
|
146
|
+
content: [
|
|
147
|
+
{ type: "text", text: "Product description" },
|
|
148
|
+
{ type: "image_url", image_url: "https://example.com/image.jpg" },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
For more details, see the [MongoDB + VoyageAI integration guide](https://mastra.ai/reference/vectors/mongodb).
|
|
156
|
+
|
|
40
157
|
## Authentication
|
|
41
158
|
|
|
42
159
|
The model router automatically detects API keys from environment variables:
|
|
43
160
|
|
|
44
161
|
- **OpenAI**: `OPENAI_API_KEY`
|
|
45
162
|
- **Google**: `GOOGLE_API_KEY` (falls back to `GOOGLE_GENERATIVE_AI_API_KEY`)
|
|
163
|
+
- **VoyageAI**: `VOYAGE_API_KEY`
|
|
46
164
|
|
|
47
165
|
```bash
|
|
48
166
|
# .env
|
|
49
167
|
OPENAI_API_KEY=sk-...
|
|
50
168
|
GOOGLE_API_KEY=...
|
|
169
|
+
VOYAGE_API_KEY=pa-...
|
|
51
170
|
```
|
|
52
171
|
|
|
53
172
|
## Custom Providers
|
|
@@ -31,12 +31,14 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
31
31
|
| [Cloudflare Workers AI](https://mastra.ai/models/providers/cloudflare-workers-ai) | `cloudflare-workers-ai/*` | `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_API_KEY` |
|
|
32
32
|
| [Cortecs](https://mastra.ai/models/providers/cortecs) | `cortecs/*` | `CORTECS_API_KEY` |
|
|
33
33
|
| [CrofAI](https://mastra.ai/models/providers/crof) | `crof/*` | `CROF_API_KEY` |
|
|
34
|
+
| [CrossModel](https://mastra.ai/models/providers/crossmodel) | `crossmodel/*` | `CROSSMODEL_API_KEY` |
|
|
34
35
|
| [D.Run (China)](https://mastra.ai/models/providers/drun) | `drun/*` | `DRUN_API_KEY` |
|
|
35
36
|
| [Databricks](https://mastra.ai/models/providers/databricks) | `databricks/*` | `DATABRICKS_HOST`, `DATABRICKS_TOKEN` |
|
|
36
37
|
| [Deep Infra](https://mastra.ai/models/providers/deepinfra) | `deepinfra/*` | `DEEPINFRA_API_KEY` |
|
|
37
38
|
| [DeepSeek](https://mastra.ai/models/providers/deepseek) | `deepseek/*` | `DEEPSEEK_API_KEY` |
|
|
38
39
|
| [DigitalOcean](https://mastra.ai/models/providers/digitalocean) | `digitalocean/*` | `DIGITALOCEAN_ACCESS_TOKEN` |
|
|
39
40
|
| [DInference](https://mastra.ai/models/providers/dinference) | `dinference/*` | `DINFERENCE_API_KEY` |
|
|
41
|
+
| [EmpirioLabs AI](https://mastra.ai/models/providers/empiriolabs) | `empiriolabs/*` | `EMPIRIOLABS_API_KEY` |
|
|
40
42
|
| [evroc](https://mastra.ai/models/providers/evroc) | `evroc/*` | `EVROC_API_KEY` |
|
|
41
43
|
| [FastRouter](https://mastra.ai/models/providers/fastrouter) | `fastrouter/*` | `FASTROUTER_API_KEY` |
|
|
42
44
|
| [Fireworks AI](https://mastra.ai/models/providers/fireworks-ai) | `fireworks-ai/*` | `FIREWORKS_API_KEY` |
|
|
@@ -68,6 +70,7 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
68
70
|
| [LongCat](https://mastra.ai/models/providers/longcat) | `longcat/*` | `LONGCAT_API_KEY` |
|
|
69
71
|
| [LucidQuery](https://mastra.ai/models/providers/lucidquery) | `lucidquery/*` | `LUCIDQUERY_API_KEY` |
|
|
70
72
|
| [Meganova](https://mastra.ai/models/providers/meganova) | `meganova/*` | `MEGANOVA_API_KEY` |
|
|
73
|
+
| [Meta](https://mastra.ai/models/providers/meta) | `meta/*` | `META_MODEL_API_KEY` |
|
|
71
74
|
| [MiniMax (minimax.io)](https://mastra.ai/models/providers/minimax) | `minimax/*` | `MINIMAX_API_KEY` |
|
|
72
75
|
| [MiniMax (minimaxi.com)](https://mastra.ai/models/providers/minimax-cn) | `minimax-cn/*` | `MINIMAX_API_KEY` |
|
|
73
76
|
| [MiniMax Token Plan (minimax.io)](https://mastra.ai/models/providers/minimax-coding-plan) | `minimax-coding-plan/*` | `MINIMAX_API_KEY` |
|
|
@@ -75,6 +78,7 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
75
78
|
| [Mistral](https://mastra.ai/models/providers/mistral) | `mistral/*` | `MISTRAL_API_KEY` |
|
|
76
79
|
| [Mixlayer](https://mastra.ai/models/providers/mixlayer) | `mixlayer/*` | `MIXLAYER_API_KEY` |
|
|
77
80
|
| [Moark](https://mastra.ai/models/providers/moark) | `moark/*` | `MOARK_API_KEY` |
|
|
81
|
+
| [Model Oracle AI](https://mastra.ai/models/providers/model-oracle-ai) | `model-oracle-ai/*` | `MODEL_ORACLE_API_KEY` |
|
|
78
82
|
| [ModelScope](https://mastra.ai/models/providers/modelscope) | `modelscope/*` | `MODELSCOPE_API_KEY` |
|
|
79
83
|
| [Moonshot AI](https://mastra.ai/models/providers/moonshotai) | `moonshotai/*` | `MOONSHOT_API_KEY` |
|
|
80
84
|
| [Moonshot AI (China)](https://mastra.ai/models/providers/moonshotai-cn) | `moonshotai-cn/*` | `MOONSHOT_API_KEY` |
|
|
@@ -95,6 +99,7 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
95
99
|
| [OVHcloud AI Endpoints](https://mastra.ai/models/providers/ovhcloud) | `ovhcloud/*` | `OVHCLOUD_API_KEY` |
|
|
96
100
|
| [Perplexity](https://mastra.ai/models/providers/perplexity) | `perplexity/*` | `PERPLEXITY_API_KEY` |
|
|
97
101
|
| [Perplexity Agent](https://mastra.ai/models/providers/perplexity-agent) | `perplexity-agent/*` | `PERPLEXITY_API_KEY` |
|
|
102
|
+
| [Pioneer](https://mastra.ai/models/providers/pioneer) | `pioneer/*` | `PIONEER_API_KEY` |
|
|
98
103
|
| [Poe](https://mastra.ai/models/providers/poe) | `poe/*` | `POE_API_KEY` |
|
|
99
104
|
| [Poolside](https://mastra.ai/models/providers/poolside) | `poolside/*` | `POOLSIDE_API_KEY` |
|
|
100
105
|
| [Privatemode AI](https://mastra.ai/models/providers/privatemode-ai) | `privatemode-ai/*` | `PRIVATEMODE_API_KEY` |
|
|
@@ -124,6 +129,7 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
124
129
|
| [TrustedRouter](https://mastra.ai/models/providers/trustedrouter) | `trustedrouter/*` | `TRUSTEDROUTER_API_KEY` |
|
|
125
130
|
| [Umans AI](https://mastra.ai/models/providers/umans-ai) | `umans-ai/*` | `UMANS_AI_API_KEY` |
|
|
126
131
|
| [Umans AI Coding Plan](https://mastra.ai/models/providers/umans-ai-coding-plan) | `umans-ai-coding-plan/*` | `UMANS_AI_CODING_PLAN_API_KEY` |
|
|
132
|
+
| [UnoRouter](https://mastra.ai/models/providers/unorouter) | `unorouter/*` | `UNOROUTER_API_KEY` |
|
|
127
133
|
| [Upstage](https://mastra.ai/models/providers/upstage) | `upstage/*` | `UPSTAGE_API_KEY` |
|
|
128
134
|
| [Vivgrid](https://mastra.ai/models/providers/vivgrid) | `vivgrid/*` | `VIVGRID_API_KEY` |
|
|
129
135
|
| [Vultr](https://mastra.ai/models/providers/vultr) | `vultr/*` | `VULTR_API_KEY` |
|
|
@@ -138,6 +144,7 @@ List of required environment variables for each model provider and gateway suppo
|
|
|
138
144
|
| [Z.AI](https://mastra.ai/models/providers/zai) | `zai/*` | `ZHIPU_API_KEY` |
|
|
139
145
|
| [Z.AI Coding Plan](https://mastra.ai/models/providers/zai-coding-plan) | `zai-coding-plan/*` | `ZHIPU_API_KEY` |
|
|
140
146
|
| [Zeldoc](https://mastra.ai/models/providers/zeldoc) | `zeldoc/*` | `ZELDOC_API_KEY` |
|
|
147
|
+
| [Zenifra](https://mastra.ai/models/providers/zenifra) | `zenifra/*` | `ZENIFRA_AI_KEY` |
|
|
141
148
|
| [ZenMux](https://mastra.ai/models/providers/zenmux) | `zenmux/*` | `ZENMUX_API_KEY` |
|
|
142
149
|
| [Zhipu AI](https://mastra.ai/models/providers/zhipuai) | `zhipuai/*` | `ZHIPU_API_KEY` |
|
|
143
150
|
| [Zhipu AI Coding Plan](https://mastra.ai/models/providers/zhipuai-coding-plan) | `zhipuai-coding-plan/*` | `ZHIPU_API_KEY` |
|