@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
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Using OpenRouter | Frameworks"
|
|
3
|
-
description: "Learn how to integrate OpenRouter with Mastra"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import Steps from "@site/src/components/Steps";
|
|
7
|
-
import StepItem from "@site/src/components/StepItem";
|
|
8
|
-
|
|
9
|
-
# Using OpenRouter
|
|
10
|
-
|
|
11
|
-
Integrate [OpenRouter](https://openrouter.ai/) with Mastra to leverage the numerous models available on OpenRouter.
|
|
12
|
-
|
|
13
|
-
<Steps>
|
|
14
|
-
|
|
15
|
-
<StepItem>
|
|
16
|
-
|
|
17
|
-
The simplest way to get started with Mastra is to use the `mastra` CLI to initialize a new project:
|
|
18
|
-
|
|
19
|
-
```bash copy
|
|
20
|
-
npx create-mastra@beta
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
You'll be guided through prompts to set up your project. For this example, select:
|
|
24
|
-
|
|
25
|
-
- Name your project: my-mastra-openrouter-app
|
|
26
|
-
- Components: Agents (recommended)
|
|
27
|
-
- For default provider, select OpenAI (recommended) - we'll configure OpenRouter manually later
|
|
28
|
-
- Optionally include example code
|
|
29
|
-
|
|
30
|
-
</StepItem>
|
|
31
|
-
|
|
32
|
-
<StepItem>
|
|
33
|
-
|
|
34
|
-
After creating your project with `create-mastra`, you'll find a `.env` file in your project root.
|
|
35
|
-
Since we selected OpenAI during setup, we'll configure OpenRouter manually:
|
|
36
|
-
|
|
37
|
-
```bash title=".env" copy
|
|
38
|
-
OPENROUTER_API_KEY=
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
We remove the `@ai-sdk/openai` package from the project:
|
|
42
|
-
|
|
43
|
-
```bash copy
|
|
44
|
-
npm uninstall @ai-sdk/openai
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Then, we install the `@openrouter/ai-sdk-provider` package:
|
|
48
|
-
|
|
49
|
-
```bash copy
|
|
50
|
-
npm install @openrouter/ai-sdk-provider
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
</StepItem>
|
|
54
|
-
|
|
55
|
-
<StepItem>
|
|
56
|
-
|
|
57
|
-
We will now configure our agent to use OpenRouter.
|
|
58
|
-
|
|
59
|
-
```typescript title="src/mastra/agents/assistant.ts" copy showLineNumbers {4-6,11}
|
|
60
|
-
import { Agent } from "@mastra/core/agent";
|
|
61
|
-
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
62
|
-
|
|
63
|
-
const openrouter = createOpenRouter({
|
|
64
|
-
apiKey: process.env.OPENROUTER_API_KEY,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export const assistant = new Agent({
|
|
68
|
-
id: "assistant",
|
|
69
|
-
name: "assistant",
|
|
70
|
-
instructions: "You are a helpful assistant.",
|
|
71
|
-
model: openrouter("anthropic/claude-sonnet-4"),
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Make sure to register your agent to the Mastra instance:
|
|
76
|
-
|
|
77
|
-
```typescript title="src/mastra/index.ts" copy showLineNumbers {4}
|
|
78
|
-
import { assistant } from "./agents/assistant";
|
|
79
|
-
|
|
80
|
-
export const mastra = new Mastra({
|
|
81
|
-
agents: { assistant },
|
|
82
|
-
});
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
</StepItem>
|
|
86
|
-
|
|
87
|
-
<StepItem>
|
|
88
|
-
|
|
89
|
-
```bash copy
|
|
90
|
-
npm run dev
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
This will start the Mastra development server.
|
|
94
|
-
|
|
95
|
-
You can now test your agent by visiting [http://localhost:4111](http://localhost:4111) and using Studio or via the Mastra API at [http://localhost:4111/api/agents/assistant/stream](http://localhost:4111/api/agents/assistant/stream).
|
|
96
|
-
|
|
97
|
-
</StepItem>
|
|
98
|
-
|
|
99
|
-
</Steps>
|
|
100
|
-
|
|
101
|
-
## Advanced Configuration
|
|
102
|
-
|
|
103
|
-
For more control over your OpenRouter requests, you can pass additional configuration options.
|
|
104
|
-
|
|
105
|
-
### Provider-wide options:
|
|
106
|
-
|
|
107
|
-
You can pass provider-wide options to the OpenRouter provider:
|
|
108
|
-
|
|
109
|
-
```typescript title="src/mastra/agents/assistant.ts" {6-10} copy showLineNumbers
|
|
110
|
-
import { Agent } from "@mastra/core/agent";
|
|
111
|
-
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
112
|
-
|
|
113
|
-
const openrouter = createOpenRouter({
|
|
114
|
-
apiKey: process.env.OPENROUTER_API_KEY,
|
|
115
|
-
extraBody: {
|
|
116
|
-
reasoning: {
|
|
117
|
-
max_tokens: 10,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
export const assistant = new Agent({
|
|
123
|
-
id: "assistant",
|
|
124
|
-
name: "assistant",
|
|
125
|
-
instructions: "You are a helpful assistant.",
|
|
126
|
-
model: openrouter("anthropic/claude-sonnet-4"),
|
|
127
|
-
});
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Model-specific options:
|
|
131
|
-
|
|
132
|
-
You can pass model-specific options to the OpenRouter provider:
|
|
133
|
-
|
|
134
|
-
```typescript title="src/mastra/agents/assistant.ts" {11-17} copy showLineNumbers
|
|
135
|
-
import { Agent } from "@mastra/core/agent";
|
|
136
|
-
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
137
|
-
|
|
138
|
-
const openrouter = createOpenRouter({
|
|
139
|
-
apiKey: process.env.OPENROUTER_API_KEY,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
export const assistant = new Agent({
|
|
143
|
-
id: "assistant",
|
|
144
|
-
name: "assistant",
|
|
145
|
-
instructions: "You are a helpful assistant.",
|
|
146
|
-
model: openrouter("anthropic/claude-sonnet-4", {
|
|
147
|
-
extraBody: {
|
|
148
|
-
reasoning: {
|
|
149
|
-
max_tokens: 10,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
}),
|
|
153
|
-
});
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Provider-specific options:
|
|
157
|
-
|
|
158
|
-
You can pass provider-specific options to the OpenRouter provider:
|
|
159
|
-
|
|
160
|
-
```typescript copy showLineNumbers {7-12}
|
|
161
|
-
// Get a response with provider-specific options
|
|
162
|
-
const response = await assistant.generate([
|
|
163
|
-
{
|
|
164
|
-
role: "system",
|
|
165
|
-
content:
|
|
166
|
-
"You are Chef Michel, a culinary expert specializing in ketogenic (keto) diet...",
|
|
167
|
-
providerOptions: {
|
|
168
|
-
// Provider-specific options - key can be 'anthropic' or 'openrouter'
|
|
169
|
-
anthropic: {
|
|
170
|
-
cacheControl: { type: "ephemeral" },
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
role: "user",
|
|
176
|
-
content: "Can you suggest a keto breakfast?",
|
|
177
|
-
},
|
|
178
|
-
]);
|
|
179
|
-
```
|
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Integrate Mastra in your Next.js project | Frameworks"
|
|
3
|
-
description: A step-by-step guide to integrating Mastra with Next.js.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import Tabs from "@theme/Tabs";
|
|
7
|
-
import TabItem from "@theme/TabItem";
|
|
8
|
-
import Steps from "@site/src/components/Steps";
|
|
9
|
-
import StepItem from "@site/src/components/StepItem";
|
|
10
|
-
|
|
11
|
-
# Integrate Mastra in your Next.js project
|
|
12
|
-
|
|
13
|
-
Mastra integrates with Next.js, making it easy to:
|
|
14
|
-
|
|
15
|
-
- Build flexible APIs to serve AI-powered features
|
|
16
|
-
- Simplify deployment with a unified codebase for frontend and backend
|
|
17
|
-
- Take advantage of Next.js's built-in server actions (App Router) or API Routes (Pages Router) for efficient server-client workflows
|
|
18
|
-
|
|
19
|
-
Use this guide to scaffold and integrate Mastra with your Next.js project.
|
|
20
|
-
|
|
21
|
-
<Tabs>
|
|
22
|
-
<TabItem value="app-router" label="App Router">
|
|
23
|
-
|
|
24
|
-
:::warning
|
|
25
|
-
|
|
26
|
-
This guide assumes you're using the Next.js App Router at the root of your project, e.g., `app` rather than `src/app`.
|
|
27
|
-
|
|
28
|
-
:::
|
|
29
|
-
|
|
30
|
-
<Steps>
|
|
31
|
-
|
|
32
|
-
<StepItem>
|
|
33
|
-
|
|
34
|
-
To integrate Mastra into your project, you have two options:
|
|
35
|
-
|
|
36
|
-
- Use the One-Liner
|
|
37
|
-
|
|
38
|
-
Run the following command to quickly scaffold the default Weather agent with sensible defaults:
|
|
39
|
-
|
|
40
|
-
```bash copy
|
|
41
|
-
npx mastra@beta init --dir . --components agents,tools --example --llm openai
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
> See [mastra init](/reference/v1/cli/create-mastra) for more information.
|
|
45
|
-
|
|
46
|
-
- Use the Interactive CLI
|
|
47
|
-
|
|
48
|
-
If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
|
|
49
|
-
|
|
50
|
-
```bash copy
|
|
51
|
-
npx mastra@beta init
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
:::warning
|
|
55
|
-
|
|
56
|
-
By default, `mastra init` suggests `src` as the install location. If you're using the App Router at the root of your project (e.g., `app`, not `src/app`), enter `.` when prompted:
|
|
57
|
-
|
|
58
|
-
:::
|
|
59
|
-
|
|
60
|
-
</StepItem>
|
|
61
|
-
|
|
62
|
-
<StepItem>
|
|
63
|
-
|
|
64
|
-
Set Up API Key
|
|
65
|
-
|
|
66
|
-
```bash title=".env" copy
|
|
67
|
-
OPENAI_API_KEY=<your-api-key>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
> Each LLM provider uses a different env var. See [Model Capabilities](https://sdk.vercel.ai/providers) for more information.
|
|
71
|
-
|
|
72
|
-
</StepItem>
|
|
73
|
-
|
|
74
|
-
<StepItem>
|
|
75
|
-
|
|
76
|
-
Add to your `next.config.ts`:
|
|
77
|
-
|
|
78
|
-
```typescript title="next.config.ts" showLineNumbers copy
|
|
79
|
-
import type { NextConfig } from "next";
|
|
80
|
-
|
|
81
|
-
const nextConfig: NextConfig = {
|
|
82
|
-
serverExternalPackages: ["@mastra/*"],
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export default nextConfig;
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
</StepItem>
|
|
89
|
-
|
|
90
|
-
<StepItem>
|
|
91
|
-
|
|
92
|
-
You can start your Next.js app in the usual way.
|
|
93
|
-
|
|
94
|
-
</StepItem>
|
|
95
|
-
|
|
96
|
-
<StepItem>
|
|
97
|
-
|
|
98
|
-
Create a new directory that will contain a Page, Action, and Form for testing purposes.
|
|
99
|
-
|
|
100
|
-
```bash copy
|
|
101
|
-
mkdir app/test
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
</StepItem>
|
|
105
|
-
|
|
106
|
-
<StepItem>
|
|
107
|
-
|
|
108
|
-
Create a new Action, and add the example code:
|
|
109
|
-
|
|
110
|
-
```bash copy
|
|
111
|
-
touch app/test/action.ts
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
```typescript title="app/test/action.ts" showLineNumbers copy
|
|
115
|
-
"use server";
|
|
116
|
-
|
|
117
|
-
import { mastra } from "../../mastra";
|
|
118
|
-
|
|
119
|
-
export async function getWeatherInfo(formData: FormData) {
|
|
120
|
-
const city = formData.get("city")?.toString();
|
|
121
|
-
const agent = mastra.getAgent("weatherAgent");
|
|
122
|
-
|
|
123
|
-
const result = await agent.generate(`What's the weather like in ${city}?`);
|
|
124
|
-
|
|
125
|
-
return result.text;
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
</StepItem>
|
|
130
|
-
|
|
131
|
-
<StepItem>
|
|
132
|
-
|
|
133
|
-
Create a new Form component, and add the example code:
|
|
134
|
-
|
|
135
|
-
```bash copy
|
|
136
|
-
touch app/test/form.tsx
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
```typescript title="app/test/form.tsx" showLineNumbers copy
|
|
140
|
-
"use client";
|
|
141
|
-
|
|
142
|
-
import { useState } from "react";
|
|
143
|
-
import { getWeatherInfo } from "./action";
|
|
144
|
-
|
|
145
|
-
export function Form() {
|
|
146
|
-
const [result, setResult] = useState<string | null>(null);
|
|
147
|
-
|
|
148
|
-
async function handleSubmit(formData: FormData) {
|
|
149
|
-
const res = await getWeatherInfo(formData);
|
|
150
|
-
setResult(res);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<>
|
|
155
|
-
<form action={handleSubmit}>
|
|
156
|
-
<input name="city" placeholder="Enter city" required />
|
|
157
|
-
<button type="submit">Get Weather</button>
|
|
158
|
-
</form>
|
|
159
|
-
{result && <pre>{result}</pre>}
|
|
160
|
-
</>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
</StepItem>
|
|
166
|
-
|
|
167
|
-
<StepItem>
|
|
168
|
-
|
|
169
|
-
Create a new Page, and add the example code:
|
|
170
|
-
|
|
171
|
-
```bash copy
|
|
172
|
-
touch app/test/page.tsx
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
```typescript title="app/test/page.tsx" showLineNumbers copy
|
|
176
|
-
import { Form } from "./form";
|
|
177
|
-
|
|
178
|
-
export default async function Page() {
|
|
179
|
-
return (
|
|
180
|
-
<>
|
|
181
|
-
<h1>Test</h1>
|
|
182
|
-
<Form />
|
|
183
|
-
</>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
> You can now navigate to `/test` in your browser to try it out.
|
|
189
|
-
|
|
190
|
-
Submitting **London** as the city would return a result similar to:
|
|
191
|
-
|
|
192
|
-
```plaintext
|
|
193
|
-
Agent response: The current weather in London is as follows:
|
|
194
|
-
|
|
195
|
-
- **Temperature:** 12.9°C (Feels like 9.7°C)
|
|
196
|
-
- **Humidity:** 63%
|
|
197
|
-
- **Wind Speed:** 14.7 km/h
|
|
198
|
-
- **Wind Gusts:** 32.4 km/h
|
|
199
|
-
- **Conditions:** Overcast
|
|
200
|
-
|
|
201
|
-
Let me know if you need more information!
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
</StepItem>
|
|
205
|
-
|
|
206
|
-
</Steps>
|
|
207
|
-
</TabItem>
|
|
208
|
-
|
|
209
|
-
<TabItem value="pages-router" label="Pages Router">
|
|
210
|
-
|
|
211
|
-
:::warning
|
|
212
|
-
|
|
213
|
-
This guide assumes you're using the Next.js Pages Router at the root of your project, e.g., `pages` rather than `src/pages`.
|
|
214
|
-
|
|
215
|
-
:::
|
|
216
|
-
|
|
217
|
-
<Steps>
|
|
218
|
-
|
|
219
|
-
<StepItem>
|
|
220
|
-
|
|
221
|
-
To integrate Mastra into your project, you have two options:
|
|
222
|
-
|
|
223
|
-
- Use the One-Liner
|
|
224
|
-
|
|
225
|
-
Run the following command to quickly scaffold the default Weather agent with sensible defaults:
|
|
226
|
-
|
|
227
|
-
```bash copy
|
|
228
|
-
npx mastra@beta init --dir . --components agents,tools --example --llm openai
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
> See [mastra init](/reference/v1/cli/create-mastra) for more information.
|
|
232
|
-
|
|
233
|
-
- Use the Interactive CLI
|
|
234
|
-
|
|
235
|
-
If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
|
|
236
|
-
|
|
237
|
-
```bash copy
|
|
238
|
-
npx mastra@beta init
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
:::warning
|
|
242
|
-
|
|
243
|
-
By default, `mastra init` suggests `src` as the install location. If you're using the Pages Router at the root of your project (e.g., `pages`, not `src/pages`), enter `.` when prompted:
|
|
244
|
-
|
|
245
|
-
:::
|
|
246
|
-
|
|
247
|
-
</StepItem>
|
|
248
|
-
|
|
249
|
-
<StepItem>
|
|
250
|
-
|
|
251
|
-
Set Up API Key
|
|
252
|
-
|
|
253
|
-
```bash title=".env" copy
|
|
254
|
-
OPENAI_API_KEY=<your-api-key>
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
> Each LLM provider uses a different env var. See [Model Capabilities](https://sdk.vercel.ai/providers) for more information.
|
|
258
|
-
|
|
259
|
-
</StepItem>
|
|
260
|
-
|
|
261
|
-
<StepItem>
|
|
262
|
-
|
|
263
|
-
Add to your `next.config.ts`:
|
|
264
|
-
|
|
265
|
-
```typescript title="next.config.ts" showLineNumbers copy
|
|
266
|
-
import type { NextConfig } from "next";
|
|
267
|
-
|
|
268
|
-
const nextConfig: NextConfig = {
|
|
269
|
-
serverExternalPackages: ["@mastra/*"],
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
export default nextConfig;
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
</StepItem>
|
|
276
|
-
|
|
277
|
-
<StepItem>
|
|
278
|
-
|
|
279
|
-
You can start your Next.js app in the usual way.
|
|
280
|
-
|
|
281
|
-
</StepItem>
|
|
282
|
-
|
|
283
|
-
<StepItem>
|
|
284
|
-
|
|
285
|
-
Create a new API Route, and add the example code:
|
|
286
|
-
|
|
287
|
-
```bash copy
|
|
288
|
-
touch pages/api/test.ts
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
```typescript title="pages/api/test.ts" showLineNumbers copy
|
|
292
|
-
import type { NextApiRequest, NextApiResponse } from "next";
|
|
293
|
-
|
|
294
|
-
import { mastra } from "../../mastra";
|
|
295
|
-
|
|
296
|
-
export default async function getWeatherInfo(
|
|
297
|
-
req: NextApiRequest,
|
|
298
|
-
res: NextApiResponse,
|
|
299
|
-
) {
|
|
300
|
-
const city = req.body.city;
|
|
301
|
-
const agent = mastra.getAgent("weatherAgent");
|
|
302
|
-
|
|
303
|
-
const result = await agent.generate(`What's the weather like in ${city}?`);
|
|
304
|
-
|
|
305
|
-
return res.status(200).json(result.text);
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
</StepItem>
|
|
310
|
-
|
|
311
|
-
<StepItem>
|
|
312
|
-
|
|
313
|
-
Create a new Page, and add the example code:
|
|
314
|
-
|
|
315
|
-
```bash copy
|
|
316
|
-
touch pages/test.tsx
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
```typescript title="pages/test.tsx" showLineNumbers copy
|
|
320
|
-
import { useState } from "react";
|
|
321
|
-
|
|
322
|
-
export default function Test() {
|
|
323
|
-
const [result, setResult] = useState<string | null>(null);
|
|
324
|
-
|
|
325
|
-
async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
|
326
|
-
event.preventDefault();
|
|
327
|
-
|
|
328
|
-
const formData = new FormData(event.currentTarget);
|
|
329
|
-
const city = formData.get("city")?.toString();
|
|
330
|
-
|
|
331
|
-
const response = await fetch("/api/test", {
|
|
332
|
-
method: "POST",
|
|
333
|
-
headers: { "Content-Type": "application/json" },
|
|
334
|
-
body: JSON.stringify({ city })
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
const text = await response.json();
|
|
338
|
-
setResult(text);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return (
|
|
342
|
-
<>
|
|
343
|
-
<h1>Test</h1>
|
|
344
|
-
<form onSubmit={handleSubmit}>
|
|
345
|
-
<input name="city" placeholder="Enter city" required />
|
|
346
|
-
<button type="submit">Get Weather</button>
|
|
347
|
-
</form>
|
|
348
|
-
{result && <pre>{result}</pre>}
|
|
349
|
-
</>
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
> You can now navigate to `/test` in your browser to try it out.
|
|
355
|
-
|
|
356
|
-
Submitting **London** as the city would return a result similar to:
|
|
357
|
-
|
|
358
|
-
```plaintext
|
|
359
|
-
Agent response: The current weather in London is as follows:
|
|
360
|
-
|
|
361
|
-
- **Temperature:** 12.9°C (Feels like 9.7°C)
|
|
362
|
-
- **Humidity:** 63%
|
|
363
|
-
- **Wind Speed:** 14.7 km/h
|
|
364
|
-
- **Wind Gusts:** 32.4 km/h
|
|
365
|
-
- **Conditions:** Overcast
|
|
366
|
-
|
|
367
|
-
Let me know if you need more information!
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
</StepItem>
|
|
371
|
-
|
|
372
|
-
</Steps>
|
|
373
|
-
</TabItem>
|
|
374
|
-
</Tabs>
|
|
375
|
-
|
|
376
|
-
## Next Steps
|
|
377
|
-
|
|
378
|
-
- [Deployment | With Next.js on Vercel](/docs/v1/deployment/web-framework#with-nextjs-on-vercel)
|
|
379
|
-
- [Monorepo Deployment](../../deployment/monorepo)
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Quickstart | Getting Started"
|
|
3
|
-
description: Choose how to get started with Mastra - standalone server or Next.js integration.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { CardGrid, CardGridItem } from "@site/src/components/cards/card-grid";
|
|
7
|
-
|
|
8
|
-
# Quickstart
|
|
9
|
-
|
|
10
|
-
Choose how you want to get started with Mastra:
|
|
11
|
-
|
|
12
|
-
<CardGrid columns={2}>
|
|
13
|
-
<CardGridItem
|
|
14
|
-
title="Standalone Server (Recommended)"
|
|
15
|
-
href="/guides/v1/quickstarts/standalone-server"
|
|
16
|
-
>
|
|
17
|
-
The fastest way to get started - spin up a standalone Mastra server and interact with your agents in Studio
|
|
18
|
-
</CardGridItem>
|
|
19
|
-
<CardGridItem
|
|
20
|
-
title="Next.js"
|
|
21
|
-
href="/guides/v1/quickstarts/nextjs"
|
|
22
|
-
>
|
|
23
|
-
Integrate Mastra into a Next.js app and use the AI SDK UI to build an in-app chat interface for your agents
|
|
24
|
-
</CardGridItem>
|
|
25
|
-
</CardGrid>
|
|
26
|
-
|
|
27
|
-
For more control over setup, or to add Mastra to an existing project, see the [manual installation guide](/guides/v1/guide/manual-install). You can also use [`mastra init`](/reference/v1/cli/mastra#mastra-init) for existing projects.
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Templates | Getting Started"
|
|
3
|
-
description: Pre-built project structures that demonstrate common Mastra use cases and patterns
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import Tabs from "@theme/Tabs";
|
|
7
|
-
import TabItem from "@theme/TabItem";
|
|
8
|
-
|
|
9
|
-
# Templates
|
|
10
|
-
|
|
11
|
-
Templates are pre-built Mastra projects that demonstrate specific use cases and patterns. Browse available templates in the [templates directory](https://mastra.ai/templates).
|
|
12
|
-
|
|
13
|
-
## Using Templates
|
|
14
|
-
|
|
15
|
-
Install a template using the `create-mastra` command:
|
|
16
|
-
|
|
17
|
-
<Tabs>
|
|
18
|
-
<TabItem value="npm" label="npm">
|
|
19
|
-
```bash copy
|
|
20
|
-
npx create-mastra@beta --template template-name
|
|
21
|
-
```
|
|
22
|
-
</TabItem>
|
|
23
|
-
<TabItem value="yarn" label="yarn">
|
|
24
|
-
```bash copy
|
|
25
|
-
yarn dlx create-mastra@beta --template template-name
|
|
26
|
-
```
|
|
27
|
-
</TabItem>
|
|
28
|
-
<TabItem value="pnpm" label="pnpm">
|
|
29
|
-
```bash copy
|
|
30
|
-
pnpm create mastra@beta --template template-name
|
|
31
|
-
```
|
|
32
|
-
</TabItem>
|
|
33
|
-
<TabItem value="bun" label="bun">
|
|
34
|
-
```bash copy
|
|
35
|
-
bun create mastra@beta --template template-name
|
|
36
|
-
```
|
|
37
|
-
</TabItem>
|
|
38
|
-
</Tabs>
|
|
39
|
-
|
|
40
|
-
For example, to create a text-to-SQL application:
|
|
41
|
-
|
|
42
|
-
```bash copy
|
|
43
|
-
npx create-mastra@beta --template text-to-sql
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Setting Up a Template
|
|
47
|
-
|
|
48
|
-
After installation:
|
|
49
|
-
|
|
50
|
-
1. **Navigate to your project**:
|
|
51
|
-
|
|
52
|
-
```bash copy
|
|
53
|
-
cd your-project-name
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
2. **Configure environment variables**:
|
|
57
|
-
|
|
58
|
-
```bash copy
|
|
59
|
-
cp .env.example .env
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Edit `.env` with your API keys as specified in the template's README.
|
|
63
|
-
|
|
64
|
-
3. **Start development**:
|
|
65
|
-
```bash copy
|
|
66
|
-
npm run dev
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
:::info
|
|
70
|
-
Each template includes a comprehensive README with specific setup instructions and usage examples.
|
|
71
|
-
:::
|
|
72
|
-
|
|
73
|
-
For detailed information on creating templates, see the [Templates Reference](/reference/v1/templates/overview).
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Run.observeStreamVNext() (Experimental) | Streaming"
|
|
3
|
-
description: Documentation for the `Run.observeStreamVNext()` method in workflows, which enables reopening the stream of an already active workflow run.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Run.observeStreamVNext() (Experimental)
|
|
7
|
-
|
|
8
|
-
The `.observeStreamVNext()` method opens a new `ReadableStream` to a workflow run that is currently running, allowing you to observe the stream of events if the original stream is no longer available.
|
|
9
|
-
|
|
10
|
-
## Usage example
|
|
11
|
-
|
|
12
|
-
```typescript showLineNumbers copy
|
|
13
|
-
const run = await workflow.createRun();
|
|
14
|
-
|
|
15
|
-
run.streamVNext({
|
|
16
|
-
inputData: {
|
|
17
|
-
value: "initial data",
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const stream = await run.observeStreamVNext();
|
|
22
|
-
|
|
23
|
-
for await (const chunk of stream) {
|
|
24
|
-
console.log(chunk);
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Returns
|
|
29
|
-
|
|
30
|
-
`ReadableStream<ChunkType>`
|
|
31
|
-
|
|
32
|
-
## Stream Events
|
|
33
|
-
|
|
34
|
-
The stream emits various event types during workflow execution. Each event has a `type` field and a `payload` containing relevant data:
|
|
35
|
-
|
|
36
|
-
- **`workflow-start`**: Workflow execution begins
|
|
37
|
-
- **`workflow-step-start`**: A step begins execution
|
|
38
|
-
- **`workflow-step-output`**: Custom output from a step
|
|
39
|
-
- **`workflow-step-result`**: A step completes with results
|
|
40
|
-
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
41
|
-
|
|
42
|
-
## Related
|
|
43
|
-
|
|
44
|
-
- [Workflows overview](/docs/v1/workflows/overview#running-workflows)
|
|
45
|
-
- [Workflow.createRun()](/reference/v1/workflows/workflow-methods/create-run)
|
|
46
|
-
- [Run.streamVNext()](./streamVNext)
|
|
47
|
-
- [Run.resumeStreamVNext()](./resumeStreamVNext)
|