CrossModel
透過 Mastra 的模型路由器存取 50 個 CrossModel 模型。系統會自動使用 CROSSMODEL_API_KEY 環境變數進行驗證。
詳情請參閱CrossModel 文件。
.env
CROSSMODEL_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: 'crossmodel/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 使用與 OpenAI 相容的 /chat/completions 端點。部分 Provider 專屬功能可能無法使用,詳情請參閱CrossModel 文件。
模型模型 的直接連結
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
crossmodel/anthropic/claude-fable-5 | 1.0M | $10 | $50 | |||||
crossmodel/anthropic/claude-haiku-4-5 | 200K | $1 | $5 | |||||
crossmodel/anthropic/claude-opus-4-7 | 1.0M | $5 | $25 | |||||
crossmodel/anthropic/claude-opus-4-8 | 1.0M | $5 | $25 | |||||
crossmodel/anthropic/claude-opus-5 | 1.0M | $5 | $25 | |||||
crossmodel/anthropic/claude-sonnet-4-6 | 1.0M | $3 | $15 | |||||
crossmodel/anthropic/claude-sonnet-5 | 1.0M | $2 | $10 | |||||
crossmodel/deepseek/deepseek-v4-flash | 1.0M | $0.16 | $0.32 | |||||
crossmodel/deepseek/deepseek-v4-pro | 1.0M | $0.47 | $0.94 | |||||
crossmodel/gemini/gemini-2.5-flash | 1.0M | $0.30 | $3 | |||||
crossmodel/gemini/gemini-2.5-flash-lite | 1.0M | $0.10 | $0.40 | |||||
crossmodel/gemini/gemini-2.5-pro | 1.0M | $1 | $10 | |||||
crossmodel/gemini/gemini-3-flash-preview | 1.0M | $0.50 | $3 | |||||
crossmodel/gemini/gemini-3.1-pro-preview | 1.0M | $2 | $12 | |||||
crossmodel/gemini/gemini-3.5-flash | 1.0M | $2 | $9 | |||||
crossmodel/gemini/gemini-3.5-flash-lite | 1.0M | $0.30 | $3 | |||||
crossmodel/gemini/gemini-3.6-flash | 1.0M | $2 | $8 | |||||
crossmodel/minimax/minimax-m2.7 | 205K | $0.33 | $1 | |||||
crossmodel/minimax/minimax-m3 | 1.0M | $0.33 | $1 | |||||
crossmodel/moonshot/kimi-k2.5 | 262K | $0.62 | $3 | |||||
crossmodel/moonshot/kimi-k2.6 | 262K | $1 | $4 | |||||
crossmodel/moonshot/kimi-k2.7-code | 262K | $1 | $4 | |||||
crossmodel/moonshot/kimi-k3 | 1.0M | $3 | $15 | |||||
crossmodel/openai/gpt-4o-mini | 128K | $0.15 | $0.60 | |||||
crossmodel/openai/gpt-5.4 | 1.1M | $3 | $15 | |||||
crossmodel/openai/gpt-5.4-mini | 400K | $0.75 | $5 | |||||
crossmodel/openai/gpt-5.4-nano | 400K | $0.20 | $1 | |||||
crossmodel/openai/gpt-5.5 | 1.1M | $5 | $30 | |||||
crossmodel/openai/gpt-5.5-pro | 1.1M | $30 | $180 | |||||
crossmodel/openai/gpt-5.6-luna | 1.1M | $0.20 | $1 | |||||
crossmodel/openai/gpt-5.6-sol | 1.1M | $5 | $30 | |||||
crossmodel/openai/gpt-5.6-terra | 1.1M | $2 | $12 | |||||
crossmodel/qwen/qwen3.6-flash | 1.0M | $0.19 | $1 | |||||
crossmodel/qwen/qwen3.6-plus | 1.0M | $0.32 | $2 | |||||
crossmodel/qwen/qwen3.7-flash | 1.0M | $0.04 | $0.13 | |||||
crossmodel/qwen/qwen3.7-max | 1.0M | $2 | $5 | |||||
crossmodel/qwen/qwen3.7-plus | 1.0M | $0.29 | $1 | |||||
crossmodel/qwen/qwen3.8-max | 1.0M | $2 | $6 | |||||
crossmodel/tencent/hy3 | 262K | $0.16 | $0.64 | |||||
crossmodel/tencent/hy3-preview | 262K | $0.19 | $0.63 | |||||
crossmodel/x-ai/grok-4.3 | 1.0M | $1 | $3 | |||||
crossmodel/x-ai/grok-4.5 | 500K | $2 | $6 | |||||
crossmodel/x-ai/grok-build-0.1 | 256K | $1 | $2 | |||||
crossmodel/xiaomi/mimo-v2.5 | 1.0M | $0.16 | $0.32 | |||||
crossmodel/xiaomi/mimo-v2.5-pro | 1.0M | $0.47 | $0.94 | |||||
crossmodel/z-ai/glm-4.7 | 200K | $0.47 | $2 | |||||
crossmodel/z-ai/glm-5 | 200K | $0.60 | $3 | |||||
crossmodel/z-ai/glm-5-turbo | 200K | $0.90 | $4 | |||||
crossmodel/z-ai/glm-5.1 | 200K | $1 | $4 | |||||
crossmodel/z-ai/glm-5.2 | 1.0M | $1 | $4 |
進階設定進階設定 的直接連結
自訂標頭自訂標頭 的直接連結
src/mastra/agents/my-agent.ts
const agent = new Agent({
id: 'custom-agent',
name: 'custom-agent',
model: {
url: 'https://api.crossmodel.ai/v1',
id: 'crossmodel/anthropic/claude-fable-5',
apiKey: process.env.CROSSMODEL_API_KEY,
headers: {
'X-Custom-Header': 'value',
},
},
})
動態選擇模型動態選擇模型 的直接連結
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 ? 'crossmodel/z-ai/glm-5.2' : 'crossmodel/anthropic/claude-fable-5'
},
})