Skip to main content

UnoRouter logoUnoRouter

Access 23 UnoRouter models through Mastra's model router. Authentication is handled automatically using the UNOROUTER_API_KEY environment variable.

Learn more in the UnoRouter documentation.

.env
UNOROUTER_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: "unorouter/claude-haiku-4-5-20251001"
});

// 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);
}
info

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

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
unorouter/claude-haiku-4-5-20251001200K$1$6
unorouter/claude-opus-4-81.0M$0.42$2
unorouter/claude-sonnet-51.0M$1$7
unorouter/deepseek-v4-flash1.0M$0.06$0.13
unorouter/deepseek-v4-flash:free1.0M
unorouter/deepseek-v4-pro1.0M$0.90$2
unorouter/deepseek-v4-pro:free1.0M
unorouter/gemini-3.5-flash1.0M$0.19$1
unorouter/gemma-4-31b-it:free262K
unorouter/glm-4.5-flash:free131K
unorouter/glm-5.21.0M$2$5
unorouter/glm-5.2:free1.0M
unorouter/gpt-5.2400K$1$8
unorouter/gpt-5.41.1M$2$11
unorouter/gpt-5.4:free1.1M
unorouter/gpt-5.51.1M$0.19$1
unorouter/gpt-5.5:free1.1M
unorouter/kimi-k2.6262K$1$5
unorouter/minimax-m2.7205K$0.82$3
unorouter/minimax-m2.7:free205K
unorouter/nemotron-3-ultra-550b-a55b:free1.0M
unorouter/qwen3.5-397b-a17b:free262K
unorouter/step-3.7-flash:free256K
23 available models

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.unorouter.com/v1",
id: "unorouter/claude-haiku-4-5-20251001",
apiKey: process.env.UNOROUTER_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
? "unorouter/step-3.7-flash:free"
: "unorouter/claude-haiku-4-5-20251001";
}
});
On this page