Skip to main content
Mastra is a framework for building and deploying AI-powered features using a modern JavaScript stack powered by the Vercel AI SDK. Integrating with Together AI provides access to a wide range of models for building intelligent agents.

Step 1: Create a new Mastra project

First, create a new Mastra project using the CLI:
During the setup, the system prompts you to name your project, choose a default provider, and more. Feel free to use the default settings.

Step 2: Install dependencies

To use Together AI with Mastra, install the required packages:

Step 3: Configure environment variables

Create or update your .env file with your Together AI API key:

Step 4: Configure your agent to use Together AI

Now, update your agent configuration file, typically src/mastra/agents/weather-agent.ts, to use Together AI models:
src/mastra/agents/weather-agent.ts

Step 5: Run the application

Since your agent is now configured to use Together AI, run the Mastra development server:
Open the Mastra Playground and Mastra API to test your agents, workflows, and tools.

Next steps