ZenMux
Access 18 ZenMux models through Mastra's model router. Authentication is handled automatically using the ZENMUX_API_KEY environment variable.
Learn more in the ZenMux documentation.
ZENMUX_API_KEY=your-api-key
import { Agent } from "@mastra/core";
const agent = new Agent({
name: "my-agent",
instructions: "You are a helpful assistant",
model: "zenmux/anthropic/claude-haiku-4.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);
}
info
Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the ZenMux documentation for details.
Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
zenmux/anthropic/claude-haiku-4.5 | 200K | $1 | $5 | |||||
zenmux/anthropic/claude-opus-4.1 | 200K | $15 | $75 | |||||
zenmux/anthropic/claude-sonnet-4.5 | 1.0M | $3 | $15 | |||||
zenmux/deepseek/deepseek-chat | 128K | $0.56 | $2 | |||||
zenmux/google/gemini-2.5-pro | 1.0M | $1 | $10 | |||||
zenmux/inclusionai/lint-1t | 128K | $0.56 | $2 | |||||
zenmux/inclusionai/ring-1t | 128K | $0.56 | $2 | |||||
zenmux/kuaishou/kat-coder-pro-v1 | 256K | $0.60 | $2 | |||||
zenmux/moonshotai/kimi-k2-0905 | 262K | $0.60 | $3 | |||||
zenmux/openai/gpt-5 | 400K | $1 | $10 | |||||
zenmux/openai/gpt-5-codex | 400K | $1 | $10 | |||||
zenmux/qwen/qwen3-coder-plus | 1.0M | $1 | $5 | |||||
zenmux/x-ai/grok-4 | 256K | $3 | $15 | |||||
zenmux/x-ai/grok-4-fast | 2.0M | $0.20 | $0.50 | |||||
zenmux/x-ai/grok-4-fast-non-reasoning | 2.0M | $0.20 | $0.50 | |||||
zenmux/x-ai/grok-code-fast-1 | 256K | $0.20 | $2 | |||||
zenmux/z-ai/glm-4.5-air | 128K | $0.11 | $0.56 | |||||
zenmux/z-ai/glm-4.6 | 200K | $0.35 | $2 |
Advanced Configuration
Custom Headers
const agent = new Agent({
name: "custom-agent",
model: {
url: "https://zenmux.ai/api/v1",
id: "zenmux/anthropic/claude-haiku-4.5",
apiKey: process.env.ZENMUX_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});
Dynamic Model Selection
const agent = new Agent({
name: "dynamic-agent",
model: ({ runtimeContext }) => {
const useAdvanced = runtimeContext.task === "complex";
return useAdvanced
? "zenmux/z-ai/glm-4.6"
: "zenmux/anthropic/claude-haiku-4.5";
}
});