Skip to main content

Tempr logoTempr

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.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
tempr/anthropic/claude-fable-51.0M$10$50
tempr/anthropic/claude-fable-5-11.0M$10$50
tempr/anthropic/claude-haiku-4-5200K$1$5
tempr/anthropic/claude-haiku-4-5-20251001200K$1$5
tempr/anthropic/claude-opus-4-5200K$5$25
tempr/anthropic/claude-opus-4-5-20251101200K$5$25
tempr/anthropic/claude-opus-4-61.0M$5$25
tempr/anthropic/claude-opus-4-71.0M$5$25
tempr/anthropic/claude-opus-4-81.0M$5$25
tempr/anthropic/claude-opus-51.0M$5$25
tempr/anthropic/claude-sonnet-4-5200K$3$15
tempr/anthropic/claude-sonnet-4-5-20250929200K$3$15
tempr/anthropic/claude-sonnet-4-61.0M$3$15
tempr/anthropic/claude-sonnet-51.0M$2$10
tempr/google/gemini-3-flash-preview1.0M$0.50$3
tempr/google/gemini-3.1-flash-lite1.0M$0.25$2
tempr/google/gemini-3.1-pro-preview1.0M$2$12
tempr/google/gemini-3.1-pro-preview-customtools1.0M$2$12
tempr/google/gemini-3.5-flash1.0M$2$9
tempr/google/gemini-3.5-flash-lite1.0M$0.30$3
tempr/google/gemini-3.6-flash1.0M$0.75$4
tempr/google/gemini-3.7-flash1.0M$0.75$4
tempr/google/gemini-3.8-flash1.0M$0.75$4
tempr/google/gemini-embedding-0012K$0.15
tempr/google/gemini-embedding-28K$0.20
tempr/google/gemini-flash-latest1.0M$0.75$4
tempr/google/gemini-flash-lite-latest1.0M$0.30$3
tempr/google/gemma-4-26b-a4b-it262K
tempr/google/gemma-4-31b-it262K
29 available models

Model availability, capabilities, context windows, and pricing are sourced from models.dev and may change.

Advanced configuration
Direct link to Advanced configuration

Custom headers
Direct 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 selection
Direct 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";
}
});
On this page