跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Tempr Gateway logoTempr Gateway

Access 82 Tempr Gateway models through Mastra's model router. Authentication is handled automatically using the TEMPR_API_KEY environment variable.

Learn more in the Tempr Gateway 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);
}
备注

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Tempr Gateway documentation for details.

Models
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/cerebras/gpt-oss-120b131K$0.35$0.75
tempr/cerebras/qwen-3.8-27b131K$0.99$1
tempr/deepseek/deepseek-flash1.0M$0.15$0.60
tempr/deepseek/deepseek-v4-pro1.0M$0.66$2
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——
tempr/groq/allam-2-7b4K——
tempr/groq/openai/gpt-oss-120b131K$0.15$0.60
tempr/groq/openai/gpt-oss-20b131K$0.07$0.30
tempr/groq/qwen/qwen3.8-27b131K$0.80$4
tempr/minimax/MiniMax-M2.7205K$0.30$1
tempr/minimax/MiniMax-M2.7-highspeed205K$0.60$2
tempr/minimax/MiniMax-M31.0M$0.30$1
tempr/mistral/mistral-embed8K$0.10—
tempr/mistral/mistral-large-2512262K$0.50$2
tempr/mistral/mistral-large-latest262K$0.50$2
tempr/mistral/mistral-medium-2604262K$2$8
tempr/mistral/mistral-medium-latest262K$2$8
tempr/mistral/mistral-small-2603256K$0.15$0.60
tempr/mistral/mistral-small-latest256K$0.15$0.60
tempr/mistral/voxtral-small-latest32K$0.10$0.30
tempr/mistral/zai-glm-5-21.0M$1$4
tempr/mistral/zai-glm-5-31.0M$1$4
tempr/moonshot/kimi-k2.6262K$0.95$4
tempr/moonshot/kimi-k2.7-code262K$0.95$4
tempr/moonshot/kimi-k2.7-code-highspeed262K$2$8
tempr/moonshot/kimi-k31.0M$3$15
tempr/xai/grok-4.20-0309-non-reasoning1.0M$1$3
tempr/xai/grok-4.20-0309-reasoning1.0M$1$3
tempr/xai/grok-4.31.0M$1$3
tempr/xai/grok-4.5500K$2$6
tempr/xai/grok-4.6500K$2$6
tempr/xai/grok-4.7500K$2$6
tempr/xai/grok-build-0.1256K$1$2
tempr/xiaomi-mimo/mimo-v2.6-flash1.0M$0.14$0.28
tempr/xiaomi-mimo/mimo-v2.6-pro1.0M$0.43$0.87
tempr/xiaomi-mimo/mimo-v2.6-pro-ultraspeed1.0M$4$9
tempr/zai/glm-4.5131K$0.60$2
tempr/zai/glm-4.5-air131K$0.20$1
tempr/zai/glm-4.5-flash131K——
tempr/zai/glm-4.5v64K$0.60$2
tempr/zai/glm-4.6205K$0.60$2
tempr/zai/glm-4.6v128K$0.30$0.90
tempr/zai/glm-4.6v-flash128K——
tempr/zai/glm-4.7205K$0.60$2
tempr/zai/glm-4.7-flash200K——
tempr/zai/glm-4.7-flashx200K$0.07$0.40
tempr/zai/glm-5205K$1$3
tempr/zai/glm-5-turbo200K$1$4
tempr/zai/glm-5.1200K$1$4
tempr/zai/glm-5.21.0M$1$4
tempr/zai/glm-5.31.0M$1$4
tempr/zai/glm-5.3-flash1.0M$0.15$0.50
tempr/zai/glm-5.3-flashx1.0M$0.37$1
tempr/zai/glm-5v-turbo200K$1$4
82 available models

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

Advanced configuration
Advanced configuration的直接链接

Custom headers
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
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/zai/glm-5v-turbo"
: "tempr/anthropic/claude-fable-5";
}
});