# Getting Started with Mastra

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.

If you need more control over the setup, see the [manual installation guide](/content/docs/getting-started/manual-install/index.html). You can also use [`mastra init`](/content/reference/cli/mastra#mastra-init/index.html) for existing projects.

## Create New Mastra Project
Make new Mastra project. Mastra = framework for AI apps + agents on modern TypeScript stack. Before run command, ask these questions one by one. Wait for answers unless already given:

1. Project name? (default: "my-mastra-app")
2. Provider? (default: "openai", options: "openai", "anthropic", "groq", "google", "cerebras", "mistral")

### Provider Rules:
- Allowed provider -> use it.
- Any other value -> use "openai".

Run with answers: `npm create mastra@latest <project-name> --default --llm <provider>`

After project created, go to project dir. Start dev server: `npx bgproc start -n <project-name> -w -- npm run dev`

Start Mastra Studio at `http://localhost:4111`. Studio = UI for build, test, manage agents, workflows, tools.

Mastra model router gives 3000+ models from many providers: [Mastra Models](/content/models/index.html)

## Before You Begin
- You'll need an API key from a supported [model provider](/content/models/index.html). If you don't have a preference, use [OpenAI](/content/models/providers/openai/index.html).

## Initialize Mastra
You can run `create mastra` anywhere on your machine.

When prompted, choose a provider (e.g. OpenAI) and enter your key:

```bash
npm create mastra@latest
```

```bash
pnpm create mastra
```

```bash
yarn create mastra
```

```bash
bunx create-mastra
```

This creates a new directory for your project with a `src/mastra` folder containing an example weather agent and the following files:
- `index.ts`: Entry point for all Mastra-related code and configuration
- `agents/weather-agent.ts`: A weather agent with a prompt that uses the tool
- `tools/weather-tool.ts`: A tool to fetch weather for a given location
- `workflows/weather-workflow.ts`: A workflow that runs the weather agent
- `scorers/weather-scorer.ts`: A scorer to evaluate the weather agent's responses

Depending on your choices, you'll also end up with [Mastra Skills](/content/docs/build-with-ai/skills/index.html) or the [MCP Docs Server](/content/docs/build-with-ai/mcp-docs-server/index.html) installed.

You can use [flags](/content/reference/cli/create-mastra#cli-flags/index.html) with `create mastra` like `--no-example` to skip the example weather agent or `--template` to start from a specific [template](/content/templates/index.html).

## Test Your Agent
Once setup is complete, follow the instructions in your terminal to start the Mastra dev server, then open Studio at [localhost:4111](http://localhost:4111/).

Try asking about the weather. If your API key is set up correctly, you'll get a response:

[Studio](/content/docs/studio/overview/index.html) lets you rapidly build and prototype agents without needing to build a UI. Once you're ready, you can integrate your Mastra agent into your app using the guides below.

## Next Steps
- Integrate Mastra with your frontend framework: [Next.js](/content/guides/getting-started/next-js/index.html), [React](/content/guides/getting-started/vite-react/index.html), or [Astro](/content/guides/getting-started/astro/index.html)
- Read more about [Mastra's features](/content/docs#what-you-can-build/index.html)
- Learn how you can [build Mastra with AI](/content/docs/getting-started/build-with-ai/index.html)
- Build an agent from scratch following one of our [guides](/content/guides/index.html)
- Watch conceptual guides on our [YouTube channel](https://www.youtube.com/@mastra-ai) and [subscribe](https://www.youtube.com/@mastra-ai?sub_confirmation=1)
