@mastra/mcp-docs-server 1.0.0-beta.4 → 1.0.0-beta.6
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/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +29 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +411 -211
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +52 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Freact.md +89 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
- package/.docs/organized/changelogs/create-mastra.md +201 -1
- package/.docs/organized/changelogs/mastra.md +201 -1
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-sdk-v5.md +1 -0
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/raw/agents/adding-voice.mdx +7 -10
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +26 -23
- package/.docs/raw/agents/networks.mdx +2 -2
- package/.docs/raw/agents/overview.mdx +27 -62
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
- package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
- package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
- package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
- package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
- package/.docs/raw/deployment/building-mastra.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +20 -27
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +19 -17
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +1 -1
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/web-framework.mdx +5 -5
- package/.docs/raw/evals/custom-scorers.mdx +3 -5
- package/.docs/raw/evals/overview.mdx +2 -3
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/guide → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/project-structure.mdx +1 -1
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/{frameworks/agentic-uis/ai-sdk.mdx → guides/build-your-ui/ai-sdk-ui.mdx} +113 -11
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +23 -25
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +3 -4
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +11 -11
- package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx} +7 -7
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +23 -25
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
- package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
- package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
- package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
- package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
- package/.docs/raw/guides/guide/web-search.mdx +12 -10
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +40 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +5 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +51 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mcp/overview.mdx +3 -5
- package/.docs/raw/memory/memory-processors.mdx +264 -79
- package/.docs/raw/memory/semantic-recall.mdx +7 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -4
- package/.docs/raw/memory/threads-and-resources.mdx +3 -3
- package/.docs/raw/memory/working-memory.mdx +14 -7
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +1 -1
- package/.docs/raw/observability/overview.mdx +2 -3
- package/.docs/raw/observability/tracing/bridges/otel.mdx +176 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +17 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +20 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +25 -5
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +107 -0
- package/.docs/raw/observability/tracing/overview.mdx +74 -8
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +3 -2
- package/.docs/raw/rag/retrieval.mdx +43 -38
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/agent.mdx +7 -10
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +46 -3
- package/.docs/raw/reference/cli/mastra.mdx +2 -1
- package/.docs/raw/reference/client-js/agents.mdx +3 -3
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +5 -19
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/answer-relevancy.mdx +28 -98
- package/.docs/raw/reference/evals/answer-similarity.mdx +12 -258
- package/.docs/raw/reference/evals/bias.mdx +29 -87
- package/.docs/raw/reference/evals/completeness.mdx +31 -90
- package/.docs/raw/reference/evals/content-similarity.mdx +28 -88
- package/.docs/raw/reference/evals/context-precision.mdx +28 -130
- package/.docs/raw/reference/evals/context-relevance.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +28 -101
- package/.docs/raw/reference/evals/hallucination.mdx +28 -103
- package/.docs/raw/reference/evals/keyword-coverage.mdx +28 -107
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +11 -11
- package/.docs/raw/reference/evals/prompt-alignment.mdx +15 -15
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +27 -100
- package/.docs/raw/reference/evals/tone-consistency.mdx +25 -98
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +7 -7
- package/.docs/raw/reference/evals/toxicity.mdx +29 -92
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/memory/memory-class.mdx +5 -7
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +150 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +4 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +6 -0
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +10 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +12 -5
- package/.docs/raw/reference/processors/pii-detector.mdx +12 -5
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +10 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +3 -4
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/rag/embeddings.mdx +5 -5
- package/.docs/raw/reference/rag/rerank.mdx +1 -2
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +0 -1
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +64 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/templates/overview.mdx +1 -4
- package/.docs/raw/reference/tools/client.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +132 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +5 -5
- package/.docs/raw/reference/tools/mcp-client.mdx +76 -21
- package/.docs/raw/reference/tools/mcp-server.mdx +1 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +14 -15
- package/.docs/raw/reference/vectors/chroma.mdx +81 -1
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +24 -17
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/vectors/lance.mdx +38 -22
- package/.docs/raw/reference/vectors/libsql.mdx +35 -2
- package/.docs/raw/reference/vectors/mongodb.mdx +35 -2
- package/.docs/raw/reference/vectors/opensearch.mdx +37 -16
- package/.docs/raw/reference/vectors/pg.mdx +43 -36
- package/.docs/raw/reference/vectors/pinecone.mdx +48 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +36 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +74 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/voice/openai-realtime.mdx +2 -2
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +2 -3
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run.mdx +13 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/mastra-client.mdx +1 -2
- package/.docs/raw/server-db/mastra-server.mdx +30 -1
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +26 -15
- package/.docs/raw/streaming/tool-streaming.mdx +48 -5
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/tools-mcp/advanced-usage.mdx +1 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +3 -5
- package/.docs/raw/voice/overview.mdx +21 -41
- package/.docs/raw/voice/speech-to-speech.mdx +4 -4
- package/.docs/raw/voice/speech-to-text.mdx +1 -2
- package/.docs/raw/voice/text-to-speech.mdx +1 -2
- package/.docs/raw/workflows/control-flow.mdx +180 -0
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
- package/dist/prepare-docs/package-changes.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -90
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -102
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
- package/.docs/raw/getting-started/quickstart.mdx +0 -27
- package/.docs/raw/getting-started/templates.mdx +0 -73
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +0 -0
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/copilotkit.mdx +0 -0
|
@@ -147,4 +147,4 @@ export const mastra = new Mastra({
|
|
|
147
147
|
## Next steps
|
|
148
148
|
|
|
149
149
|
- Learn more about Mastra's suggested [project structure](/docs/v1/getting-started/project-structure).
|
|
150
|
-
- Integrate Mastra with your frontend framework of choice - [Next.js](/
|
|
150
|
+
- Integrate Mastra with your frontend framework of choice - [Next.js](/guides/v1/getting-started/next-js), [React](/guides/v1/getting-started/vite-react), or [Astro](/guides/v1/getting-started/astro).
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Using AI SDK | Frameworks"
|
|
3
|
-
description: "Learn how Mastra leverages the AI SDK library and how you can leverage it further with Mastra"
|
|
2
|
+
title: "Using AI SDK UI | Frameworks"
|
|
3
|
+
description: "Learn how Mastra leverages the AI SDK UI library and how you can leverage it further with Mastra"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import Tabs from "@theme/Tabs";
|
|
7
7
|
import TabItem from "@theme/TabItem";
|
|
8
8
|
|
|
9
|
-
# Using AI SDK
|
|
9
|
+
# Using AI SDK UI
|
|
10
10
|
|
|
11
|
-
[AI SDK](https://sdk.vercel.ai) is a free open-source library that gives you the tools you need to build AI-powered products. Mastra has great integration with AI SDK, including model routing, streaming support, custom React hooks, custom tool/UI, and more.
|
|
11
|
+
[AI SDK UI](https://sdk.vercel.ai) is a free open-source library that gives you the tools you need to build AI-powered products. Mastra has great integration with AI SDK UI, including model routing, streaming support, custom React hooks, custom tool/UI, and more.
|
|
12
12
|
|
|
13
13
|
:::note
|
|
14
14
|
Migrating from AI SDK v4 to v5? See the [migration guide](/guides/v1/migrations/ai-sdk-v4-to-v5).
|
|
@@ -142,6 +142,12 @@ const { error, status, sendMessage, messages, regenerate, stop } = useChat({
|
|
|
142
142
|
});
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
+
:::tip Agent streaming in workflows
|
|
146
|
+
When a workflow step pipes an agent's stream to the workflow writer (e.g., `await response.fullStream.pipeTo(writer)`), the agent's text chunks and tool calls are automatically streamed to the UI in real-time. This provides a seamless streaming experience even when agents are running inside workflow steps.
|
|
147
|
+
|
|
148
|
+
Learn more in [Workflow Streaming](/docs/v1/streaming/workflow-streaming#streaming-agent-text-chunks-to-ui).
|
|
149
|
+
:::
|
|
150
|
+
|
|
145
151
|
### `networkRoute()`
|
|
146
152
|
|
|
147
153
|
Use the `networkRoute()` utility to create a route handler that automatically formats the agent network stream into an AI SDK-compatible format.
|
|
@@ -278,12 +284,12 @@ For more information about tool streaming see [Tool streaming documentation](/do
|
|
|
278
284
|
|
|
279
285
|
### Stream Transformations
|
|
280
286
|
|
|
281
|
-
To manually transform Mastra's streams to AI SDK-compatible format, use the `
|
|
287
|
+
To manually transform Mastra's streams to AI SDK-compatible format, use the `toAISdkStream()` utility.
|
|
282
288
|
|
|
283
289
|
```typescript title="app/api/chat/route.ts" copy {3,13}
|
|
284
290
|
import { mastra } from "../../mastra";
|
|
285
291
|
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
286
|
-
import {
|
|
292
|
+
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
287
293
|
|
|
288
294
|
export async function POST(req: Request) {
|
|
289
295
|
const { messages } = await req.json();
|
|
@@ -292,8 +298,9 @@ export async function POST(req: Request) {
|
|
|
292
298
|
|
|
293
299
|
// Transform stream into AI SDK format and create UI messages stream
|
|
294
300
|
const uiMessageStream = createUIMessageStream({
|
|
301
|
+
originalMessages: messages,
|
|
295
302
|
execute: async ({ writer }) => {
|
|
296
|
-
for await (const part of
|
|
303
|
+
for await (const part of toAISdkStream(stream, { from: "agent" })!) {
|
|
297
304
|
writer.write(part);
|
|
298
305
|
}
|
|
299
306
|
},
|
|
@@ -306,13 +313,108 @@ export async function POST(req: Request) {
|
|
|
306
313
|
}
|
|
307
314
|
```
|
|
308
315
|
|
|
316
|
+
#### Stream Transformation Options
|
|
317
|
+
|
|
318
|
+
The `toAISdkStream()` function accepts the following options:
|
|
319
|
+
|
|
320
|
+
<PropertiesTable
|
|
321
|
+
content={[
|
|
322
|
+
{
|
|
323
|
+
name: "from",
|
|
324
|
+
type: "'agent' | 'network' | 'workflow'",
|
|
325
|
+
isRequired: true,
|
|
326
|
+
description: "The type of Mastra stream being converted.",
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "lastMessageId",
|
|
330
|
+
type: "string",
|
|
331
|
+
isOptional: true,
|
|
332
|
+
description: "(Agent only) The ID of the last message in the conversation.",
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "sendStart",
|
|
336
|
+
type: "boolean",
|
|
337
|
+
isOptional: true,
|
|
338
|
+
defaultValue: "true",
|
|
339
|
+
description: "(Agent only) Whether to send start events.",
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "sendFinish",
|
|
343
|
+
type: "boolean",
|
|
344
|
+
isOptional: true,
|
|
345
|
+
defaultValue: "true",
|
|
346
|
+
description: "(Agent only) Whether to send finish events.",
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "sendReasoning",
|
|
350
|
+
type: "boolean",
|
|
351
|
+
isOptional: true,
|
|
352
|
+
defaultValue: "false",
|
|
353
|
+
description: "(Agent only) Whether to include reasoning-delta chunks in the stream. Set to true to stream the actual reasoning content from models that support extended thinking.",
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "sendSources",
|
|
357
|
+
type: "boolean",
|
|
358
|
+
isOptional: true,
|
|
359
|
+
defaultValue: "false",
|
|
360
|
+
description: "(Agent only) Whether to include source citations in the output.",
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "messageMetadata",
|
|
364
|
+
type: "Function",
|
|
365
|
+
isOptional: true,
|
|
366
|
+
description: "(Agent only) A function that receives the current stream part and returns metadata to attach to start and finish chunks.",
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "onError",
|
|
370
|
+
type: "Function",
|
|
371
|
+
isOptional: true,
|
|
372
|
+
description: "(Agent only) A function to handle errors during stream conversion. Receives the error and should return a string representation.",
|
|
373
|
+
},
|
|
374
|
+
]}
|
|
375
|
+
/>
|
|
376
|
+
|
|
377
|
+
**Example with reasoning enabled:**
|
|
378
|
+
|
|
379
|
+
```typescript title="app/api/chat/route.ts" copy {11-14}
|
|
380
|
+
import { mastra } from "../../mastra";
|
|
381
|
+
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
382
|
+
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
383
|
+
|
|
384
|
+
export async function POST(req: Request) {
|
|
385
|
+
const { messages } = await req.json();
|
|
386
|
+
const myAgent = mastra.getAgent("reasoningAgent");
|
|
387
|
+
const stream = await myAgent.stream(messages, {
|
|
388
|
+
providerOptions: {
|
|
389
|
+
openai: { reasoningEffort: "high" },
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
const uiMessageStream = createUIMessageStream({
|
|
394
|
+
initialMessages: messages,
|
|
395
|
+
execute: async ({ writer }) => {
|
|
396
|
+
for await (const part of toAISdkStream(stream, {
|
|
397
|
+
from: "agent",
|
|
398
|
+
sendReasoning: true, // Enable reasoning content streaming
|
|
399
|
+
})!) {
|
|
400
|
+
writer.write(part);
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
return createUIMessageStreamResponse({
|
|
406
|
+
stream: uiMessageStream,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
309
411
|
### Client Side Stream Transformations
|
|
310
412
|
|
|
311
|
-
If you have a client-side `response` from `agent.stream(...)` and want AI SDK-formatted parts without custom SSE parsing, wrap `response.processDataStream` into a `ReadableStream<ChunkType>` and pipe it through `
|
|
413
|
+
If you have a client-side `response` from `agent.stream(...)` and want AI SDK-formatted parts without custom SSE parsing, wrap `response.processDataStream` into a `ReadableStream<ChunkType>` and pipe it through `toAISdkStream`:
|
|
312
414
|
|
|
313
415
|
```typescript title="client-stream-to-ai-sdk.ts" copy
|
|
314
416
|
import { createUIMessageStream } from "ai";
|
|
315
|
-
import {
|
|
417
|
+
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
316
418
|
import type { ChunkType, MastraModelOutput } from "@mastra/core/stream";
|
|
317
419
|
|
|
318
420
|
// Client SDK agent stream
|
|
@@ -334,7 +436,7 @@ const chunkStream: ReadableStream<ChunkType> = new ReadableStream<ChunkType>({
|
|
|
334
436
|
|
|
335
437
|
const uiMessageStream = createUIMessageStream({
|
|
336
438
|
execute: async ({ writer }) => {
|
|
337
|
-
for await (const part of
|
|
439
|
+
for await (const part of toAISdkStream(
|
|
338
440
|
chunkStream as unknown as MastraModelOutput,
|
|
339
441
|
{ from: "agent" },
|
|
340
442
|
)) {
|
|
@@ -572,4 +674,4 @@ export const mastra = new Mastra({
|
|
|
572
674
|
```
|
|
573
675
|
|
|
574
676
|
> You can then access this data in your tools via the `requestContext` parameter. See the [Request Context documentation](/docs/v1/server-db/request-context) for more details.
|
|
575
|
-
|
|
677
|
+
|
|
@@ -31,34 +31,34 @@ This guide assumes you're using Astro's Actions with React and the Vercel adapte
|
|
|
31
31
|
|
|
32
32
|
<StepItem>
|
|
33
33
|
|
|
34
|
-
Install the required
|
|
34
|
+
Install the required packages:
|
|
35
35
|
|
|
36
36
|
<Tabs>
|
|
37
37
|
<TabItem value="npm" label="npm">
|
|
38
38
|
|
|
39
39
|
```bash copy
|
|
40
|
-
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
40
|
+
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
</TabItem>
|
|
44
44
|
<TabItem value="yarn" label="yarn">
|
|
45
45
|
|
|
46
46
|
```bash copy
|
|
47
|
-
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
47
|
+
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
</TabItem>
|
|
51
51
|
<TabItem value="pnpm" label="pnpm">
|
|
52
52
|
|
|
53
53
|
```bash copy
|
|
54
|
-
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
54
|
+
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
</TabItem>
|
|
58
58
|
<TabItem value="bun" label="bun">
|
|
59
59
|
|
|
60
60
|
```bash copy
|
|
61
|
-
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
61
|
+
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
</TabItem>
|
|
@@ -140,14 +140,13 @@ Add `.mastra` and `.vercel` to your `.gitignore` file:
|
|
|
140
140
|
|
|
141
141
|
Astro uses Vite, which accesses environment variables via `import.meta.env` rather than `process.env`. As a result, the model constructor must explicitly receive the `apiKey` from the Vite environment like this:
|
|
142
142
|
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
+ import { createOpenAI } from "@ai-sdk/openai";
|
|
143
|
+
```typescript title="src/mastra/agents/weather-agent.ts"
|
|
144
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
146
145
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
const openai = createOpenAI({
|
|
147
|
+
apiKey: import.meta.env?.OPENAI_API_KEY,
|
|
148
|
+
compatibility: "strict"
|
|
149
|
+
});
|
|
151
150
|
```
|
|
152
151
|
|
|
153
152
|
> More configuration details are available in the AI SDK docs. See [Provider Instance](https://ai-sdk.dev/providers/ai-sdk-providers/openai#provider-instance) for more information.
|
|
@@ -324,34 +323,34 @@ Before proceeding, ensure your Astro project is configured as follows:
|
|
|
324
323
|
|
|
325
324
|
<StepItem>
|
|
326
325
|
|
|
327
|
-
Install the required
|
|
326
|
+
Install the required packages:
|
|
328
327
|
|
|
329
328
|
<Tabs>
|
|
330
329
|
<TabItem value="npm" label="npm">
|
|
331
330
|
|
|
332
331
|
```bash copy
|
|
333
|
-
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
332
|
+
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
334
333
|
```
|
|
335
334
|
|
|
336
335
|
</TabItem>
|
|
337
336
|
<TabItem value="yarn" label="yarn">
|
|
338
337
|
|
|
339
338
|
```bash copy
|
|
340
|
-
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
339
|
+
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
341
340
|
```
|
|
342
341
|
|
|
343
342
|
</TabItem>
|
|
344
343
|
<TabItem value="pnpm" label="pnpm">
|
|
345
344
|
|
|
346
345
|
```bash copy
|
|
347
|
-
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
346
|
+
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
348
347
|
```
|
|
349
348
|
|
|
350
349
|
</TabItem>
|
|
351
350
|
<TabItem value="bun" label="bun">
|
|
352
351
|
|
|
353
352
|
```bash copy
|
|
354
|
-
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
353
|
+
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
355
354
|
```
|
|
356
355
|
|
|
357
356
|
</TabItem>
|
|
@@ -433,14 +432,13 @@ Add `.mastra` to your `.gitignore` file:
|
|
|
433
432
|
|
|
434
433
|
Astro uses Vite, which accesses environment variables via `import.meta.env` rather than `process.env`. As a result, the model constructor must explicitly receive the `apiKey` from the Vite environment like this:
|
|
435
434
|
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
+ import { createOpenAI } from "@ai-sdk/openai";
|
|
435
|
+
```typescript title="src/mastra/agents/weather-agent.ts"
|
|
436
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
439
437
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
438
|
+
const openai = createOpenAI({
|
|
439
|
+
apiKey: import.meta.env?.OPENAI_API_KEY,
|
|
440
|
+
compatibility: "strict"
|
|
441
|
+
});
|
|
444
442
|
```
|
|
445
443
|
|
|
446
444
|
> More configuration details are available in the AI SDK docs. See [Provider Instance](https://ai-sdk.dev/providers/ai-sdk-providers/openai#provider-instance) for more information.
|
|
@@ -599,4 +597,4 @@ Let me know if you need more information!
|
|
|
599
597
|
## Next Steps
|
|
600
598
|
|
|
601
599
|
- [Deployment | With Astro on Vercel](/docs/v1/deployment/web-framework#with-astro-on-vercel)
|
|
602
|
-
- [Monorepo Deployment](
|
|
600
|
+
- [Monorepo Deployment](/docs/v1/deployment/monorepo)
|
|
@@ -26,7 +26,7 @@ In this guide you'll learn how to install the necessary Mastra dependencies, cre
|
|
|
26
26
|
First, install the necessary Mastra dependencies to run an Agent. This guide uses OpenAI as its model but you can use any supported [model provider](/models/v1).
|
|
27
27
|
|
|
28
28
|
```bash copy
|
|
29
|
-
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta zod@^3.0.0
|
|
29
|
+
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta zod@^3.0.0
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
If not existent yet, create an `.env` file and add your OpenAI API key:
|
|
@@ -37,7 +37,7 @@ OPENAI_API_KEY=<your-api-key>
|
|
|
37
37
|
|
|
38
38
|
:::note
|
|
39
39
|
|
|
40
|
-
Each LLM provider uses a different env var. See [Model
|
|
40
|
+
Each LLM provider uses a different env var. See [Model Providers](/models/v1/providers/) for more information.
|
|
41
41
|
|
|
42
42
|
:::
|
|
43
43
|
|
|
@@ -75,7 +75,6 @@ export const weatherTool = createTool({
|
|
|
75
75
|
Add a `weatherAgent` at `src/mastra/agents/weather-agent.ts`:
|
|
76
76
|
|
|
77
77
|
```ts title="src/mastra/agents/weather-agent.ts" copy
|
|
78
|
-
import { openai } from "@ai-sdk/openai";
|
|
79
78
|
import { Agent } from "@mastra/core/agent";
|
|
80
79
|
import { weatherTool } from "../tools/weather-tool";
|
|
81
80
|
|
|
@@ -94,7 +93,7 @@ export const weatherAgent = new Agent({
|
|
|
94
93
|
|
|
95
94
|
Use the weatherTool to fetch current weather data.
|
|
96
95
|
`,
|
|
97
|
-
model: openai
|
|
96
|
+
model: "openai/gpt-5.1",
|
|
98
97
|
tools: { weatherTool },
|
|
99
98
|
});
|
|
100
99
|
```
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Next.js
|
|
3
|
-
description: "Get started with Mastra
|
|
2
|
+
title: "Next.js | Frameworks"
|
|
3
|
+
description: "Get started with Mastra and Next.js"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Next.js
|
|
6
|
+
# Integrate Mastra in your Next.js project
|
|
7
7
|
|
|
8
|
-
In this
|
|
8
|
+
In this guide, you'll build a tool-calling AI agent using Mastra, then connect it to Next.js by importing and calling the agent directly from your routes.
|
|
9
9
|
|
|
10
10
|
You'll use [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and [AI Elements](https://ai-sdk.dev/elements) to create a beautiful, interactive chat experience.
|
|
11
11
|
|
|
12
|
-
In about 5 minutes, you'll have a functional AI-powered app ready to extend with your own tools and logic.
|
|
13
|
-
|
|
14
12
|
<figure>
|
|
15
13
|

|
|
16
14
|
<figcaption class="text-sm text-center">What you'll build: an agent that can call a weather tool, display the JSON result, stream a weather summary in the chat UI, and persist conversation history across reloads.</figcaption>
|
|
@@ -20,7 +18,9 @@ In about 5 minutes, you'll have a functional AI-powered app ready to extend with
|
|
|
20
18
|
|
|
21
19
|
* You'll need an API key from a supported [model provider](/models/v1). If you don't have a preference, use [OpenAI](/models/v1/providers/openai).
|
|
22
20
|
|
|
23
|
-
## Create a new Next.js app
|
|
21
|
+
## Create a new Next.js app (optional)
|
|
22
|
+
|
|
23
|
+
If you already have a Next.js app, skip to the next step.
|
|
24
24
|
|
|
25
25
|
Run the following command to [create a new Next.js app](https://nextjs.org/docs/app/getting-started/installation):
|
|
26
26
|
|
|
@@ -41,7 +41,7 @@ npx create-next-app \
|
|
|
41
41
|
This creates a project called `my-nextjs-agent`, but you can replace it with any name you want.
|
|
42
42
|
|
|
43
43
|
## Initialize Mastra
|
|
44
|
-
`cd` and run [`mastra init`](/reference/v1/cli/create-mastra).
|
|
44
|
+
`cd` into your Next.js project and run [`mastra init`](/reference/v1/cli/create-mastra).
|
|
45
45
|
|
|
46
46
|
When prompted, choose a provider (e.g. OpenAI) and enter your key:
|
|
47
47
|
|
|
@@ -85,7 +85,7 @@ Create `src/app/api/chat/route.ts`:
|
|
|
85
85
|
```ts title="src/app/api/chat/route.ts"
|
|
86
86
|
import { mastra } from "@/mastra";
|
|
87
87
|
import { NextResponse } from "next/server";
|
|
88
|
-
import {
|
|
88
|
+
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
89
89
|
import { convertMessages } from "@mastra/core/agent";
|
|
90
90
|
import { createUIMessageStreamResponse } from "ai";
|
|
91
91
|
|
|
@@ -102,7 +102,7 @@ export async function POST(req: Request) {
|
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
return createUIMessageStreamResponse({
|
|
105
|
-
stream:
|
|
105
|
+
stream: toAISdkStream(stream, { from: "agent" }),
|
|
106
106
|
})
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -271,6 +271,6 @@ From here, you can extend the project with your own tools and logic:
|
|
|
271
271
|
|
|
272
272
|
When you're ready, read more about how Mastra integrates with AI SDK and Next.js, and how to deploy your agent anywhere, including Vercel:
|
|
273
273
|
|
|
274
|
-
- Integrate Mastra with [AI SDK](/
|
|
274
|
+
- Integrate Mastra with [AI SDK](/guides/v1/build-your-ui/ai-sdk-ui)
|
|
275
275
|
- Deploy your agent to [Vercel](/docs/v1/deployment/cloud-providers/vercel-deployer)
|
|
276
276
|
- Deploy your agent [anywhere](/docs/v1/deployment/overview)
|
package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
description: Get started with Mastra using the create mastra CLI to build a
|
|
2
|
+
title: "Quickstart"
|
|
3
|
+
description: Get started with Mastra using the create mastra CLI to build a server with agents, workflows, and tools.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import Tabs from "@theme/Tabs";
|
|
@@ -9,11 +9,11 @@ import Steps from "@site/src/components/Steps";
|
|
|
9
9
|
import StepItem from "@site/src/components/StepItem";
|
|
10
10
|
import { VideoPlayer } from "@site/src/components/video-player";
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# Mastra Quickstart
|
|
13
13
|
|
|
14
|
-
The `create mastra` CLI command is the quickest way to
|
|
14
|
+
The `create mastra` CLI command is the quickest way to get started. It walks you through setup and creates example agents, workflows, and tools for you to run locally or adapt
|
|
15
15
|
|
|
16
|
-
If you need more control over the setup, see the [manual installation guide](/
|
|
16
|
+
If you need more control over the setup, see the [manual installation guide](/docs/v1/getting-started/manual-install). You can also use [`mastra init`](/reference/v1/cli/mastra#mastra-init) for existing projects.
|
|
17
17
|
|
|
18
18
|
## Before you begin
|
|
19
19
|
|
|
@@ -64,7 +64,7 @@ This creates a new directory for your project with a `src/mastra` folder contain
|
|
|
64
64
|
|
|
65
65
|
:::tip
|
|
66
66
|
|
|
67
|
-
You can use [flags](/reference/v1/cli/create-mastra#cli-flags) with `create mastra` like `--no-example` to skip the example weather agent or `--template` to start from a specific [template](/
|
|
67
|
+
You can use [flags](/reference/v1/cli/create-mastra#cli-flags) with `create mastra` like `--no-example` to skip the example weather agent or `--template` to start from a specific [template](https://mastra.ai/templates)
|
|
68
68
|
|
|
69
69
|
:::
|
|
70
70
|
|
|
@@ -80,7 +80,7 @@ Try asking about the weather. If your API key is set up correctly, you'll get a
|
|
|
80
80
|
|
|
81
81
|
## Next steps
|
|
82
82
|
|
|
83
|
-
- Integrate Mastra with your frontend framework: [Next.js](/
|
|
83
|
+
- Integrate Mastra with your frontend framework: [Next.js](/guides/v1/getting-started/next-js), [React](/guides/v1/getting-started/vite-react), or [Astro](/guides/v1/getting-started/astro)
|
|
84
84
|
- Read more about [Mastra's features](/docs/v1#why-mastra)
|
|
85
85
|
- Build an agent from scratch following one of our [guides](/guides/v1)
|
|
86
86
|
- Watch conceptual guides on our [YouTube channel](https://www.youtube.com/@mastra-ai) and [subscribe](https://www.youtube.com/@mastra-ai?sub_confirmation=1)
|
|
@@ -27,27 +27,27 @@ Use this guide to scaffold and integrate Mastra with your SvelteKit project.
|
|
|
27
27
|
|
|
28
28
|
Install Mastra
|
|
29
29
|
|
|
30
|
-
Install the required
|
|
30
|
+
Install the required packages:
|
|
31
31
|
|
|
32
32
|
<Tabs>
|
|
33
33
|
<TabItem value="npm" label="npm">
|
|
34
34
|
```bash copy
|
|
35
|
-
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
35
|
+
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
36
36
|
```
|
|
37
37
|
</TabItem>
|
|
38
38
|
<TabItem value="yarn" label="yarn">
|
|
39
39
|
```bash copy
|
|
40
|
-
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
40
|
+
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
41
41
|
```
|
|
42
42
|
</TabItem>
|
|
43
43
|
<TabItem value="pnpm" label="pnpm">
|
|
44
44
|
```bash copy
|
|
45
|
-
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
45
|
+
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
46
46
|
```
|
|
47
47
|
</TabItem>
|
|
48
48
|
<TabItem value="bun" label="bun">
|
|
49
49
|
```bash copy
|
|
50
|
-
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
50
|
+
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
51
51
|
```
|
|
52
52
|
</TabItem>
|
|
53
53
|
</Tabs>
|
|
@@ -128,14 +128,13 @@ Add `.mastra` to your `.gitignore` file:
|
|
|
128
128
|
|
|
129
129
|
Update the Mastra Agent
|
|
130
130
|
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
+ import { createOpenAI } from "@ai-sdk/openai";
|
|
131
|
+
```typescript title="src/mastra/agents/weather-agent.ts"
|
|
132
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
const openai = createOpenAI({
|
|
135
|
+
apiKey: import.meta.env?.VITE_OPENAI_API_KEY || process.env.VITE_OPENAI_API_KEY,
|
|
136
|
+
compatibility: "strict"
|
|
137
|
+
});
|
|
139
138
|
```
|
|
140
139
|
|
|
141
140
|
By reading env vars from both `import.meta.env` and `process.env`, we ensure that the API key is available in both the SvelteKit dev server and the Mastra Dev Server.
|
|
@@ -258,27 +257,27 @@ If you need more details or information about a different location, feel free to
|
|
|
258
257
|
|
|
259
258
|
<StepItem>
|
|
260
259
|
|
|
261
|
-
Install the required
|
|
260
|
+
Install the required packages:
|
|
262
261
|
|
|
263
262
|
<Tabs>
|
|
264
263
|
<TabItem value="npm" label="npm">
|
|
265
264
|
```bash copy
|
|
266
|
-
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
265
|
+
npm install mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
267
266
|
```
|
|
268
267
|
</TabItem>
|
|
269
268
|
<TabItem value="yarn" label="yarn">
|
|
270
269
|
```bash copy
|
|
271
|
-
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
270
|
+
yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
272
271
|
```
|
|
273
272
|
</TabItem>
|
|
274
273
|
<TabItem value="pnpm" label="pnpm">
|
|
275
274
|
```bash copy
|
|
276
|
-
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
275
|
+
pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
277
276
|
```
|
|
278
277
|
</TabItem>
|
|
279
278
|
<TabItem value="bun" label="bun">
|
|
280
279
|
```bash copy
|
|
281
|
-
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta
|
|
280
|
+
bun add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
|
|
282
281
|
```
|
|
283
282
|
</TabItem>
|
|
284
283
|
</Tabs>
|
|
@@ -359,14 +358,13 @@ Add `.mastra` to your `.gitignore` file:
|
|
|
359
358
|
|
|
360
359
|
Update the Mastra Agent
|
|
361
360
|
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
+ import { createOpenAI } from "@ai-sdk/openai";
|
|
361
|
+
```typescript title="src/mastra/agents/weather-agent.ts"
|
|
362
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
365
363
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
364
|
+
const openai = createOpenAI({
|
|
365
|
+
apiKey: import.meta.env?.VITE_OPENAI_API_KEY || process.env.VITE_OPENAI_API_KEY,
|
|
366
|
+
compatibility: "strict"
|
|
367
|
+
});
|
|
370
368
|
```
|
|
371
369
|
|
|
372
370
|
By reading env vars from both `import.meta.env` and `process.env`, we ensure that the API key is available in both the SvelteKit dev server and the Mastra Dev Server.
|
|
@@ -499,4 +497,4 @@ If you need more details or information about a different location, feel free to
|
|
|
499
497
|
|
|
500
498
|
## Next steps
|
|
501
499
|
|
|
502
|
-
- [Monorepo Deployment](
|
|
500
|
+
- [Monorepo Deployment](/docs/v1/deployment/monorepo)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Integrate Mastra in your
|
|
3
|
-
description: A step-by-step guide to integrating Mastra with
|
|
2
|
+
title: "Integrate Mastra in your React + Vite project | Frameworks"
|
|
3
|
+
description: A step-by-step guide to integrating Mastra with React and Vite.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import Tabs from "@theme/Tabs";
|
|
7
7
|
import TabItem from "@theme/TabItem";
|
|
8
8
|
|
|
9
|
-
# Integrate Mastra in your
|
|
9
|
+
# Integrate Mastra in your React + Vite project
|
|
10
10
|
|
|
11
11
|
Mastra integrates with Vite, making it easy to:
|
|
12
12
|
|
|
@@ -14,11 +14,11 @@ Mastra integrates with Vite, making it easy to:
|
|
|
14
14
|
- Simplify deployment with a unified codebase for frontend and backend
|
|
15
15
|
- Take advantage of Mastra's Client SDK
|
|
16
16
|
|
|
17
|
-
Use this guide to scaffold and integrate Mastra with your
|
|
17
|
+
Use this guide to scaffold and integrate Mastra with your React + Vite project.
|
|
18
18
|
|
|
19
19
|
:::warning
|
|
20
20
|
|
|
21
|
-
This guide assumes you're using
|
|
21
|
+
This guide assumes you're using React + Vite with React Router v7 at the root of your project, e.g., `app`.
|
|
22
22
|
|
|
23
23
|
:::
|
|
24
24
|
|
|
@@ -81,7 +81,7 @@ npx mastra@latest init
|
|
|
81
81
|
|
|
82
82
|
:::warning
|
|
83
83
|
|
|
84
|
-
By default, `mastra init` suggests `src` as the install location. If you're using
|
|
84
|
+
By default, `mastra init` suggests `src` as the install location. If you're using React + Vite at the root of your project (e.g., `app`, not `src/app`), enter `.` when prompted:
|
|
85
85
|
|
|
86
86
|
:::
|
|
87
87
|
|
|
@@ -252,4 +252,4 @@ The current weather in London is partly cloudy with a temperature of 19.3°C, fe
|
|
|
252
252
|
|
|
253
253
|
## Next steps
|
|
254
254
|
|
|
255
|
-
- [Monorepo Deployment](
|
|
255
|
+
- [Monorepo Deployment](/docs/v1/deployment/monorepo)
|
|
@@ -16,7 +16,7 @@ You'll create a workflow that gathers information from a candidate's resume, the
|
|
|
16
16
|
|
|
17
17
|
- Node.js `v22.13.0` or later installed
|
|
18
18
|
- An API key from a supported [Model Provider](/models/v1)
|
|
19
|
-
- An existing Mastra project (Follow the [installation guide](/guides/v1/
|
|
19
|
+
- An existing Mastra project (Follow the [installation guide](/guides/v1/getting-started/quickstart) to set up a new project)
|
|
20
20
|
|
|
21
21
|
## Building the Workflow
|
|
22
22
|
|
|
@@ -58,13 +58,12 @@ To the existing `src/mastra/workflows/candidate-workflow.ts` file add the follow
|
|
|
58
58
|
|
|
59
59
|
```ts copy title="src/mastra/workflows/candidate-workflow.ts"
|
|
60
60
|
import { Agent } from "@mastra/core/agent";
|
|
61
|
-
import { openai } from "@ai-sdk/openai";
|
|
62
61
|
|
|
63
62
|
const recruiter = new Agent({
|
|
64
63
|
id: "recruiter-agent",
|
|
65
64
|
name: "Recruiter Agent",
|
|
66
65
|
instructions: `You are a recruiter.`,
|
|
67
|
-
model: openai
|
|
66
|
+
model: "openai/gpt-5.1",
|
|
68
67
|
});
|
|
69
68
|
|
|
70
69
|
const gatherCandidateInfo = createStep({
|