Skip to main content
Mastra 1.0 is available 🎉 Read announcement

ZenMux logoZenMux

Access 63 ZenMux models through Mastra's model router. Authentication is handled automatically using the ZENMUX_API_KEY environment variable.

Learn more in the ZenMux documentation.

.env
ZENMUX_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: "zenmux/anthropic/claude-3.5-haiku"
});

// 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
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
zenmux/anthropic/claude-3.5-haiku200K$0.80$4
zenmux/anthropic/claude-3.5-sonnet200K$3$15
zenmux/anthropic/claude-3.7-sonnet200K$3$15
zenmux/anthropic/claude-haiku-4.5200K$1$5
zenmux/anthropic/claude-opus-4200K$15$75
zenmux/anthropic/claude-opus-4.1200K$15$75
zenmux/anthropic/claude-opus-4.5200K$5$25
zenmux/anthropic/claude-opus-4.61.0M$5$25
zenmux/anthropic/claude-sonnet-41.0M$3$15
zenmux/anthropic/claude-sonnet-4.51.0M$3$15
zenmux/baidu/ernie-5.0-thinking-preview128K$0.84$3
zenmux/deepseek/deepseek-chat128K$0.28$0.42
zenmux/deepseek/deepseek-v3.2128K$0.28$0.43
zenmux/deepseek/deepseek-v3.2-exp163K$0.22$0.33
zenmux/google/gemini-2.5-flash1.0M$0.30$3
zenmux/google/gemini-2.5-flash-lite1.0M$0.10$0.40
zenmux/google/gemini-2.5-pro1.0M$1$10
zenmux/google/gemini-3-flash-preview1.0M$0.50$3
zenmux/google/gemini-3-pro-preview1.0M$2$12
zenmux/inclusionai/ling-1t128K$0.56$2
zenmux/inclusionai/ring-1t128K$0.56$2
zenmux/kuaishou/kat-coder-pro-v1256K$0.30$1
zenmux/kuaishou/kat-coder-pro-v1-free256K——
zenmux/minimax/minimax-m2204K$0.30$1
zenmux/minimax/minimax-m2.1204K$0.30$1
zenmux/minimax/minimax-m2.5205K$0.30$1
zenmux/minimax/minimax-m2.5-lightning205K$0.60$5
zenmux/moonshotai/kimi-k2-0905262K$0.60$3
zenmux/moonshotai/kimi-k2-thinking262K$0.60$3
zenmux/moonshotai/kimi-k2-thinking-turbo262K$1$8
zenmux/moonshotai/kimi-k2.5262K$0.58$3
zenmux/openai/gpt-5400K$1$10
zenmux/openai/gpt-5-codex400K$1$10
zenmux/openai/gpt-5.1400K$1$10
zenmux/openai/gpt-5.1-chat128K$1$10
zenmux/openai/gpt-5.1-codex400K$1$10
zenmux/openai/gpt-5.1-codex-mini400K$0.25$2
zenmux/openai/gpt-5.2400K$2$14
zenmux/openai/gpt-5.2-codex400K$2$14
zenmux/qwen/qwen3-coder-plus1.0M$1$5
zenmux/qwen/qwen3-max256K$1$6
zenmux/stepfun/step-366K$0.21$0.57
zenmux/stepfun/step-3.5-flash256K$0.10$0.30
zenmux/stepfun/step-3.5-flash-free256K——
zenmux/volcengine/doubao-seed-1.8256K$0.11$0.28
zenmux/volcengine/doubao-seed-code256K$0.17$1
zenmux/x-ai/grok-4256K$3$15
zenmux/x-ai/grok-4-fast2.0M$0.20$0.50
zenmux/x-ai/grok-4.1-fast2.0M$0.20$0.50
zenmux/x-ai/grok-4.1-fast-non-reasoning2.0M$0.20$0.50
zenmux/x-ai/grok-code-fast-1256K$0.20$2
zenmux/xiaomi/mimo-v2-flash262K$0.10$0.30
zenmux/xiaomi/mimo-v2-flash-free262K——
zenmux/z-ai/glm-4.5128K$0.35$2
zenmux/z-ai/glm-4.5-air128K$0.11$0.56
zenmux/z-ai/glm-4.6200K$0.35$2
zenmux/z-ai/glm-4.6v200K$0.14$0.42
zenmux/z-ai/glm-4.6v-flash200K$0.02$0.21
zenmux/z-ai/glm-4.6v-flash-free200K——
zenmux/z-ai/glm-4.7200K$0.28$1
zenmux/z-ai/glm-4.7-flash-free200K——
zenmux/z-ai/glm-4.7-flashx200K$0.07$0.42
zenmux/z-ai/glm-5200K$0.58$3
63 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://zenmux.ai/api/anthropic/v1",
id: "zenmux/anthropic/claude-3.5-haiku",
apiKey: process.env.ZENMUX_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
? "zenmux/z-ai/glm-5"
: "zenmux/anthropic/claude-3.5-haiku";
}
});

Direct Provider Installation
Direct link to Direct Provider Installation

This provider can also be installed directly as a standalone package, which can be used instead of the Mastra model router string. View the package documentation for more details.

npm install @ai-sdk/anthropic