既存のプロジェクトに追加する
CLIを使用して既存のプロジェクトにMastraを追加できます:
npm install -g mastra@latest
mastra init
プロジェクトに加えられる変更:
- エントリーポイントを含む
src/mastra
ディレクトリを作成 - 必要な依存関係を追加
- TypeScriptコンパイラオプションを設定
インタラクティブセットアップ
引数なしでコマンドを実行すると、以下のためのCLIプロンプトが開始されます:
- コンポーネントの選択
- LLMプロバイダーの設定
- APIキーのセットアップ
- サンプルコードの組み込み
非対話式セットアップ
非対話モードでmastraを初期化するには、以下のコマンド引数を使用します:
Arguments:
--components Specify components: agents, tools, workflows
--llm LLM provider: openai, anthropic, groq, google or cerebras
--llm-api-key Provider API key
--example Include example implementation
--dir Directory for Mastra files (defaults to src/)
詳細については、mastra init CLIドキュメントを参照してください。