mastra init
Reference
mastra init
This creates a new Mastra project. You can run it in three different ways:
-
Interactive Mode (Recommended) Run without flags to use the interactive prompt, which will guide you through:
- Choosing a directory for Mastra files
- Selecting components to install (Agents, Tools, Workflows)
- Choosing a default LLM provider (OpenAI, Anthropic, or Groq)
- Deciding whether to include example code
-
Quick Start with Defaults
mastra init --default
This sets up a project with:
- Source directory:
src/
- All components: agents, tools, workflows
- OpenAI as the default provider
- No example code
- Source directory:
-
Custom Setup
mastra init --dir src/mastra --components agents,tools --llm openai --example
Options:
-d, --dir
: Directory for Mastra files (defaults to src/mastra)-c, --components
: Comma-separated list of components (agents, tools, workflows)-l, --llm
: Default model provider (openai, anthropic, groq, google or cerebras)-k, --llm-api-key
: API key for the selected LLM provider (will be added to .env file)-e, --example
: Include example code-ne, --no-example
: Skip example code
Advanced usage
Disable analytics
If you prefer not to send anonymous usage data then set the
MASTRA_TELEMETRY_DISABLED=1
environment variable when running the
command:
MASTRA_TELEMETRY_DISABLED=1 mastra init
Custom provider endpoints
Initialised projects respect the OPENAI_BASE_URL
and
ANTHROPIC_BASE_URL
variables if present. This lets you route provider
traffic through proxies or private gateways when starting the dev server
later on.