Model policy
The Agent Builder is part of the Mastra Enterprise Edition. Production deployments require a valid EE license. Contact sales for more information.
The model policy controls which providers and models Builder-created agents can use, which model is selected by default, and whether end users can change it. The policy lives at builder.configuration.agent.models.
QuickstartDirect link to Quickstart
import { MastraEditor } from '@mastra/editor'
new MastraEditor({
builder: {
enabled: true,
configuration: {
agent: {
models: {
allowed: [
{ provider: 'openai', modelId: 'gpt-5.4-mini' },
{ provider: 'openai', modelId: 'gpt-5.4' },
{ provider: 'anthropic', modelId: 'claude-opus-4-7' },
],
},
},
},
},
})
This restricts the Builder's model picker to two OpenAI models and one Anthropic model. End users choose one when creating an agent.
Validation rulesDirect link to Validation rules
Mastra validates the model policy at server boot. Violations are surfaced as warnings through getModelPolicyWarnings().
- When
allowedis empty or omitted, every registered model is available. - When
allowedis non-empty,default(if set) must satisfy the allowlist. Adefaultthat fails this check is dropped and surfaced as a warning. - To hide the end-user model picker, set
features.agent.model: falsein AgentBuilderOptions. When the picker is hidden, provide adefaultso new agents resolve a model.
Registered providers (provider: 'openai', provider: 'anthropic', and so on) can omit modelId to allow every model from that provider.
See the builder.configuration.agent.models reference for every admin-writable field and validation rules.
RelatedDirect link to Related
- Configuration — wire the model policy into the broader Builder config.
builder.configuration.agent.models— full property list.- Provider registry — every model ID Mastra recognizes out of the box.