Tempr
Access 29 Tempr models through Mastra's model router. Authentication is handled automatically using the TEMPR_API_KEY environment variable.
Learn more in the Tempr documentation.
.env
TEMPR_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: "tempr/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 Tempr documentation for details.
ModelsDirect link to Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
tempr/anthropic/claude-fable-5 | 1.0M | $10 | $50 | |||||
tempr/anthropic/claude-fable-5-1 | 1.0M | $10 | $50 | |||||
tempr/anthropic/claude-haiku-4-5 | 200K | $1 | $5 | |||||
tempr/anthropic/claude-haiku-4-5-20251001 | 200K | $1 | $5 | |||||
tempr/anthropic/claude-opus-4-5 | 200K | $5 | $25 | |||||
tempr/anthropic/claude-opus-4-5-20251101 | 200K | $5 | $25 | |||||
tempr/anthropic/claude-opus-4-6 | 1.0M | $5 | $25 | |||||
tempr/anthropic/claude-opus-4-7 | 1.0M | $5 | $25 | |||||
tempr/anthropic/claude-opus-4-8 | 1.0M | $5 | $25 | |||||
tempr/anthropic/claude-opus-5 | 1.0M | $5 | $25 | |||||
tempr/anthropic/claude-sonnet-4-5 | 200K | $3 | $15 | |||||
tempr/anthropic/claude-sonnet-4-5-20250929 | 200K | $3 | $15 | |||||
tempr/anthropic/claude-sonnet-4-6 | 1.0M | $3 | $15 | |||||
tempr/anthropic/claude-sonnet-5 | 1.0M | $2 | $10 | |||||
tempr/google/gemini-3-flash-preview | 1.0M | $0.50 | $3 | |||||
tempr/google/gemini-3.1-flash-lite | 1.0M | $0.25 | $2 | |||||
tempr/google/gemini-3.1-pro-preview | 1.0M | $2 | $12 | |||||
tempr/google/gemini-3.1-pro-preview-customtools | 1.0M | $2 | $12 | |||||
tempr/google/gemini-3.5-flash | 1.0M | $2 | $9 | |||||
tempr/google/gemini-3.5-flash-lite | 1.0M | $0.30 | $3 | |||||
tempr/google/gemini-3.6-flash | 1.0M | $0.75 | $4 | |||||
tempr/google/gemini-3.7-flash | 1.0M | $0.75 | $4 | |||||
tempr/google/gemini-3.8-flash | 1.0M | $0.75 | $4 | |||||
tempr/google/gemini-embedding-001 | 2K | $0.15 | — | |||||
tempr/google/gemini-embedding-2 | 8K | $0.20 | — | |||||
tempr/google/gemini-flash-latest | 1.0M | $0.75 | $4 | |||||
tempr/google/gemini-flash-lite-latest | 1.0M | $0.30 | $3 | |||||
tempr/google/gemma-4-26b-a4b-it | 262K | — | — | |||||
tempr/google/gemma-4-31b-it | 262K | — | — |
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.temprhq.io/v1",
id: "tempr/anthropic/claude-fable-5",
apiKey: process.env.TEMPR_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
? "tempr/google/gemma-4-31b-it"
: "tempr/anthropic/claude-fable-5";
}
});