Skip to main content

ZenMux logoZenMux

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

ModelImageAudioVideoToolsStreamingContext Window
zenmux/anthropic/claude-haiku-4.5200,000
zenmux/anthropic/claude-opus-4.1200,000
zenmux/anthropic/claude-sonnet-4.51,000,000
zenmux/deepseek/deepseek-chat128,000
zenmux/google/gemini-2.5-pro1,048,576
zenmux/inclusionai/lint-1t128,000
zenmux/inclusionai/ring-1t128,000
zenmux/kuaishou/kat-coder-pro-v1256,000
zenmux/moonshotai/kimi-k2-0905262,144
zenmux/openai/gpt-5400,000
zenmux/openai/gpt-5-codex400,000
zenmux/qwen/qwen3-coder-plus1,000,000
zenmux/x-ai/grok-4256,000
zenmux/x-ai/grok-4-fast2,000,000
zenmux/x-ai/grok-4-fast-non-reasoning2,000,000
zenmux/x-ai/grok-code-fast-1256,000
zenmux/z-ai/glm-4.5-air128,000
zenmux/z-ai/glm-4.6200,000

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";
}
});

On this page