Mastra
Mastra is a framework for building and deploying AI-powered features using a modern JavaScript stack powered by the Vercel AI SDK. Integrating with AI Gateway provides unified model management and routing capabilities.
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. and more. Feel free to use the default settings.
To use the AI Gateway provider, install the package along with Mastra:
Create or update your file with your Vercel AI Gateway API key:
Now, swap out the package (or your existing model provider) for the package.
Update your agent configuration file, typically to the following code:
Since your agent is now configured to use AI Gateway, run the Mastra development server:
Open the Mastra Playground and Mastra API to test your agents, workflows, and tools.
Was this helpful?