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

LowRouter logoLowRouter

Access 31 LowRouter models through Mastra's model router. Authentication is handled automatically using the LOWROUTER_API_KEY environment variable.

Learn more in the LowRouter documentation.

.env
LOWROUTER_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: "lowrouter/auto/mistralai/codestral-2508"
});

// 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 LowRouter documentation for details.

Models
Models的直接链接

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
lowrouter/auto/mistralai/codestral-2508128K$0.31$0.94
lowrouter/auto/mistralai/ministral-14b-2512262K$0.21$0.21
lowrouter/auto/mistralai/ministral-3b-2512262K$0.10$0.10
lowrouter/auto/mistralai/ministral-8b-2512262K$0.16$0.16
lowrouter/auto/mistralai/mistral-large-2512262K$0.52$2
lowrouter/auto/mistralai/mistral-large-4524K$0.71$2
lowrouter/auto/mistralai/mistral-medium-3.5262K$2$8
lowrouter/auto/mistralai/mistral-small-2603256K$0.16$0.63
lowrouter/auto/openai/gpt-4.11.0M$2$8
lowrouter/auto/openai/gpt-4.1-mini1.0M$0.40$2
lowrouter/auto/openai/gpt-4o128K$3$10
lowrouter/auto/openai/gpt-4o-mini128K$0.15$0.60
lowrouter/auto/openai/gpt-5400K$1$10
lowrouter/auto/openai/gpt-5-mini400K$0.25$2
lowrouter/auto/openai/gpt-5-nano400K$0.05$0.40
lowrouter/auto/openai/gpt-5.2400K$2$14
lowrouter/auto/openai/gpt-5.41.1M$3$15
lowrouter/auto/openai/gpt-5.4-mini400K$0.75$5
lowrouter/auto/openai/gpt-5.51.1M$5$30
lowrouter/auto/openai/gpt-5.6-luna1.1M$0.20$1
lowrouter/auto/openai/gpt-5.6-sol1.1M$4$20
lowrouter/auto/openai/gpt-5.6-terra1.1M$2$12
lowrouter/auto/openai/gpt-6-astra1.1M$10$50
lowrouter/auto/openai/gpt-6-luna1.1M$0.10$0.50
lowrouter/auto/openai/gpt-6-sol1.1M$2$10
lowrouter/auto/openai/gpt-6.1-sol1.1M$2$10
lowrouter/auto/openai/gpt-oss-120b131K$0.17$0.68
lowrouter/auto/openai/gpt-oss-20b131K$0.11$0.47
lowrouter/auto/openai/gpt-oss-safeguard-120b131K$0.18$0.73
lowrouter/auto/openai/gpt-oss-safeguard-20b131K$0.08$0.24
lowrouter/auto/openai/o3200K$2$8
31 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.lowrouter.ai/v1",
id: "lowrouter/auto/mistralai/codestral-2508",
apiKey: process.env.LOWROUTER_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
? "lowrouter/auto/openai/o3"
: "lowrouter/auto/mistralai/codestral-2508";
}
});