Opper
Access 40 Opper models through Mastra's model router. Authentication is handled automatically using the OPPER_API_KEY environment variable.
Learn more in the Opper documentation.
.env
OPPER_API_KEY=your-api-key
src/mastra/agents/my-agent.ts
import { Agent } from "@mastra/core/agent";
const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "opper/anthropic/claude-fable-5"
});
// Generate a response
const response = await agent.generate("Hello!");
// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
console.log(chunk);
}
note
Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Opper documentation for details.
ModelsDirect link to Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
opper/anthropic/claude-fable-5 | 1.0M | $10 | $50 | |||||
opper/anthropic/claude-haiku-4-5 | 200K | $1 | $5 | |||||
opper/anthropic/claude-opus-4-5 | 200K | $5 | $25 | |||||
opper/anthropic/claude-opus-4-6 | 1.0M | $5 | $25 | |||||
opper/anthropic/claude-opus-4-7 | 1.0M | $5 | $25 | |||||
opper/anthropic/claude-opus-4-8 | 1.0M | $5 | $25 | |||||
opper/anthropic/claude-opus-5 | 1.0M | $5 | $25 | |||||
opper/anthropic/claude-sonnet-4-5 | 200K | $3 | $15 | |||||
opper/anthropic/claude-sonnet-4-6 | 1.0M | $3 | $15 | |||||
opper/anthropic/claude-sonnet-5 | 1.0M | $2 | $10 | |||||
opper/gemini/gemini-3-flash-preview | 1.0M | $0.50 | $3 | |||||
opper/gemini/gemini-3.1-pro-preview | 1.0M | $2 | $12 | |||||
opper/gemini/gemini-3.5-flash | 1.0M | $2 | $9 | |||||
opper/gemini/gemini-3.5-flash-lite | 1.0M | $0.30 | $3 | |||||
opper/meta/muse-spark-1.2 | 1.0M | $1 | $4 | |||||
opper/minimax/m3 | 1.0M | $0.60 | $2 | |||||
opper/mistral/devstral-2512 | 262K | $0.40 | $2 | |||||
opper/mistral/mistral-large-2512 | 262K | $0.50 | $2 | |||||
opper/mistral/mistral-small-2603 | 256K | $0.15 | $0.60 | |||||
opper/moonshot/kimi-k3 | 1.0M | $3 | $15 | |||||
opper/openai/gpt-5.3-chat-latest | 128K | $2 | $14 | |||||
opper/openai/gpt-5.3-codex | 400K | $2 | $14 | |||||
opper/openai/gpt-5.4 | 1.1M | $3 | $15 | |||||
opper/openai/gpt-5.4-mini | 400K | $0.75 | $5 | |||||
opper/openai/gpt-5.4-nano | 400K | $0.20 | $1 | |||||
opper/openai/gpt-5.4-pro | 1.1M | $30 | $180 | |||||
opper/openai/gpt-5.5 | 1.1M | $5 | $30 | |||||
opper/openai/gpt-5.5-pro | 1.1M | $30 | $180 | |||||
opper/openai/gpt-5.6-luna | 1.1M | $0.20 | $1 | |||||
opper/openai/gpt-5.6-sol | 1.1M | $5 | $30 | |||||
opper/openai/gpt-5.6-terra | 1.1M | $2 | $12 | |||||
opper/perplexity/sonar | 128K | $1 | $1 | |||||
opper/perplexity/sonar-pro | 200K | $3 | $15 | |||||
opper/perplexity/sonar-reasoning-pro | 128K | $2 | $8 | |||||
opper/vertexai/gemini-3.7-flash | 1.0M | $0.75 | $4 | |||||
opper/vertexai/gemini-3.7-flash-eu | 1.0M | $0.75 | $4 | |||||
opper/xai/grok-4.3 | 1.0M | $1 | $3 | |||||
opper/xai/grok-4.5 | 500K | $2 | $6 | |||||
opper/xai/grok-4.6 | 500K | $2 | $6 | |||||
opper/xai/grok-build-0.1 | 256K | $1 | $2 |
Advanced configurationDirect link to Advanced configuration
Custom headersDirect link to Custom headers
src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://api.opper.ai/v3/compat",
id: "opper/anthropic/claude-fable-5",
apiKey: process.env.OPPER_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});
Dynamic model selectionDirect link to Dynamic model selection
src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "opper/xai/grok-build-0.1"
: "opper/anthropic/claude-fable-5";
}
});