Mastra adds private model gateways for self-hosted models
Mastra introduced custom model gateways that route agent requests to self-hosted open-weight models, with a custom gateway ID serving as the model prefix in agent configuration. The vendor demonstrated a research agent using gpt-oss:20b through Ollama, and Studio can hide external providers so users select only models exposed by their own gateways. Mastra says self-hosting can keep sensitive data within a user’s network and simplify HIPAA or GDPR compliance, but these benefits were not independently verified.
The feature gives Mastra developers a concrete way to run agents against locally hosted open-weight models while restricting which providers appear in Studio, supporting privacy-sensitive and controlled deployments.
You can now route agent requests to self-hosted open-weight models using a custom model gateway. Give the gateway a custom ID, then use it as the model prefix in your agent's config: private/ollama/gpt-oss:20b.
Your browser does not support the video tag.A research agent in Studio runs on gpt-oss:20b through the gateway while the ollama serve logs show each request arrive locally, then the agent answers with a guide to deploying the model on AWS.
Using a hosted provider service can complicate HIPAA or GDPR compliance (unless data retention agreements are in place). Self-hosting removes the third party, preventing sensitive data from reaching models outside of your network.
Costs may also be reduced as you're only paying for infrastructure, not tokens, and you control which models your agents can use.
To hide external providers from Studio's model picker, set AUTO_BLOCK_EXTERNAL_PROVIDERS=true in your .env so users can only select models from your own gateways.
Get started
Install the latest @mastra/core and an AI SDK provider for your gateway's API:
#Mastra#Mastra Studio#Ollama#gpt-oss:20b#@mastra/core#@ai-sdk/openai-compatible