togetherai/ model string and Mastra reads your API key from the environment, with no provider package to install.
Step 1: Create a new Mastra project
Create a new Mastra project using the CLI:Step 2: Configure environment variables
Add your Together API key to the project’s.env file:
Step 3: Configure your agent to use Together AI
Update your agent configuration file, typicallysrc/mastra/agents/weather-agent.ts, to point the model router at a Together AI model. The format is togetherai/ followed by the model ID:
src/mastra/agents/weather-agent.ts
generate:
TypeScript
Mastra’s current release expects AI SDK v5 provider packages, so the latest
@ai-sdk/togetherai (built for AI SDK v6) fails with AGENT_STREAM_V1_MODEL_NOT_SUPPORTED when passed as a model instance. The togetherai/ model string avoids the version coupling entirely.Step 4: Run the application
Run the Mastra development server:Next steps
Mastra documentation
Build workflows, tools, and memory-backed agents with Mastra.
Serverless models
Browse the full catalog of models you can pass to the model router.
Vercel AI SDK quickstart
Use the AI SDK that powers Mastra’s model layer directly.
Next.js chat quickstart
Build a streaming chat app with Together AI and Next.js.