Opper
Access 57 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/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/claude-fable-5 | 1.0M | $10 | $50 | |||||
opper/claude-fable-5-1 | 1.0M | $10 | $50 | |||||
opper/claude-haiku-4-5 | 200K | $1 | $6 | |||||
opper/claude-opus-4-5 | 200K | $5 | $25 | |||||
opper/claude-opus-4-6 | 1.0M | $5 | $25 | |||||
opper/claude-opus-4-7 | 1.0M | $6 | $28 | |||||
opper/claude-opus-4-8 | 1.0M | $5 | $25 | |||||
opper/claude-opus-5 | 1.0M | $6 | $28 | |||||
opper/claude-sonnet-4-5 | 200K | $3 | $17 | |||||
opper/claude-sonnet-4-6 | 1.0M | $3 | $17 | |||||
opper/claude-sonnet-5 | 1.0M | $2 | $11 | |||||
opper/deepseek-v4-flash | 1.0M | $0.25 | $0.66 | |||||
opper/deepseek-v4-pro | 1.0M | $2 | $4 | |||||
opper/devstral-2512 | 256K | $0.40 | $2 | |||||
opper/gemini-3-flash-preview | 1.0M | $0.50 | $3 | |||||
opper/gemini-3.1-pro-preview | 1.0M | $2 | $12 | |||||
opper/gemini-3.5-flash | 1.0M | $2 | $9 | |||||
opper/gemini-3.5-flash-lite | 1.0M | $0.30 | $3 | |||||
opper/gemini-3.7-flash | 1.0M | $0.75 | $4 | |||||
opper/gemini-3.8-flash | 1.0M | $0.82 | $4 | |||||
opper/gemma-4-31b-it | 256K | $0.46 | $2 | |||||
opper/glm-5.2 | 1.0M | $2 | $6 | |||||
opper/glm-5.3 | 1.0M | $2 | $5 | |||||
opper/glm-5.3-flash | 1.0M | $0.20 | $0.50 | |||||
opper/gpt-5.3-codex | 400K | $2 | $14 | |||||
opper/gpt-5.4 | 1.1M | $3 | $15 | |||||
opper/gpt-5.4-mini | 400K | $0.75 | $5 | |||||
opper/gpt-5.4-nano | 400K | $0.20 | $1 | |||||
opper/gpt-5.4-pro | 1.1M | $30 | $180 | |||||
opper/gpt-5.5 | 1.1M | $5 | $30 | |||||
opper/gpt-5.5-pro | 1.1M | $30 | $180 | |||||
opper/gpt-5.6-luna | 1.0M | $0.20 | $1 | |||||
opper/gpt-5.6-sol | 1.0M | $5 | $30 | |||||
opper/gpt-5.6-terra | 1.0M | $2 | $12 | |||||
opper/gpt-6-astra | 1.1M | $10 | $50 | |||||
opper/gpt-oss-120b | 128K | $1 | $5 | |||||
opper/gpt-oss-20b | 128K | $0.12 | $0.49 | |||||
opper/grok-4.3 | 1.0M | $1 | $3 | |||||
opper/grok-4.5 | 500K | $2 | $6 | |||||
opper/grok-4.6 | 500K | $2 | $6 | |||||
opper/grok-build-0.1 | 256K | $1 | $2 | |||||
opper/kimi-k3 | 1.0M | $3 | $15 | |||||
opper/minimax-m2.7 | 197K | $0.70 | $3 | |||||
opper/minimax-m3 | 1.0M | $0.60 | $2 | |||||
opper/mistral-large-2512 | 256K | $0.50 | $2 | |||||
opper/mistral-small-2603 | 256K | $0.58 | $2 | |||||
opper/muse-spark-1.2 | 1.0M | $1 | $4 | |||||
opper/muse-spark-1.3 | 1.0M | $1 | $4 | |||||
opper/qwen3-coder-next | 262K | $0.58 | $2 | |||||
opper/qwen3.6-35b-a3b | 262K | $0.25 | $1 | |||||
opper/qwen3.8-2.4t-a95b | 262K | $3 | $6 | |||||
opper/qwen3.8-27b | 262K | $0.58 | $3 | |||||
opper/qwen3.8-max | 984K | $2 | $6 | |||||
opper/sonar | 128K | $1 | $1 | |||||
opper/sonar-pro | 200K | $3 | $15 | |||||
opper/sonar-reasoning-pro | 128K | $2 | $8 |
Model availability, capabilities, context windows, and pricing are sourced from models.dev and may change.
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/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/sonar-reasoning-pro"
: "opper/claude-fable-5";
}
});