LowRouter
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.
ModelsModels的直接链接
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
lowrouter/auto/mistralai/codestral-2508 | 128K | $0.31 | $0.94 | |||||
lowrouter/auto/mistralai/ministral-14b-2512 | 262K | $0.21 | $0.21 | |||||
lowrouter/auto/mistralai/ministral-3b-2512 | 262K | $0.10 | $0.10 | |||||
lowrouter/auto/mistralai/ministral-8b-2512 | 262K | $0.16 | $0.16 | |||||
lowrouter/auto/mistralai/mistral-large-2512 | 262K | $0.52 | $2 | |||||
lowrouter/auto/mistralai/mistral-large-4 | 524K | $0.71 | $2 | |||||
lowrouter/auto/mistralai/mistral-medium-3.5 | 262K | $2 | $8 | |||||
lowrouter/auto/mistralai/mistral-small-2603 | 256K | $0.16 | $0.63 | |||||
lowrouter/auto/openai/gpt-4.1 | 1.0M | $2 | $8 | |||||
lowrouter/auto/openai/gpt-4.1-mini | 1.0M | $0.40 | $2 | |||||
lowrouter/auto/openai/gpt-4o | 128K | $3 | $10 | |||||
lowrouter/auto/openai/gpt-4o-mini | 128K | $0.15 | $0.60 | |||||
lowrouter/auto/openai/gpt-5 | 400K | $1 | $10 | |||||
lowrouter/auto/openai/gpt-5-mini | 400K | $0.25 | $2 | |||||
lowrouter/auto/openai/gpt-5-nano | 400K | $0.05 | $0.40 | |||||
lowrouter/auto/openai/gpt-5.2 | 400K | $2 | $14 | |||||
lowrouter/auto/openai/gpt-5.4 | 1.1M | $3 | $15 | |||||
lowrouter/auto/openai/gpt-5.4-mini | 400K | $0.75 | $5 | |||||
lowrouter/auto/openai/gpt-5.5 | 1.1M | $5 | $30 | |||||
lowrouter/auto/openai/gpt-5.6-luna | 1.1M | $0.20 | $1 | |||||
lowrouter/auto/openai/gpt-5.6-sol | 1.1M | $4 | $20 | |||||
lowrouter/auto/openai/gpt-5.6-terra | 1.1M | $2 | $12 | |||||
lowrouter/auto/openai/gpt-6-astra | 1.1M | $10 | $50 | |||||
lowrouter/auto/openai/gpt-6-luna | 1.1M | $0.10 | $0.50 | |||||
lowrouter/auto/openai/gpt-6-sol | 1.1M | $2 | $10 | |||||
lowrouter/auto/openai/gpt-6.1-sol | 1.1M | $2 | $10 | |||||
lowrouter/auto/openai/gpt-oss-120b | 131K | $0.17 | $0.68 | |||||
lowrouter/auto/openai/gpt-oss-20b | 131K | $0.11 | $0.47 | |||||
lowrouter/auto/openai/gpt-oss-safeguard-120b | 131K | $0.18 | $0.73 | |||||
lowrouter/auto/openai/gpt-oss-safeguard-20b | 131K | $0.08 | $0.24 | |||||
lowrouter/auto/openai/o3 | 200K | $2 | $8 |
Model availability, capabilities, context windows, and pricing are sourced from models.dev and may change.
Advanced configurationAdvanced configuration的直接链接
Custom headersCustom 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 selectionDynamic 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";
}
});