Skip to main content
Mastra 1.0 is available 🎉 Read announcement

AIHubMix logoAIHubMix

Access 34 AIHubMix models through Mastra's model router. Authentication is handled automatically using the AIHUBMIX_API_KEY environment variable.

Learn more in the AIHubMix documentation.

AIHUBMIX_API_KEY=your-api-key
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "aihubmix/Kimi-K2-0905"
});

// 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 AIHubMix documentation for details.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
aihubmix/claude-haiku-4-5200K$1$6
aihubmix/claude-opus-4-1200K$17$83
aihubmix/claude-opus-4-5200K$5$25
aihubmix/claude-sonnet-4-5200K$3$17
aihubmix/coding-glm-4.7-free205K——
aihubmix/coding-minimax-m2.1-free205K——
aihubmix/deepseek-v3.2131K$0.30$0.45
aihubmix/deepseek-v3.2-fast128K$1$3
aihubmix/deepseek-v3.2-speciale128K$0.58$2
aihubmix/deepseek-v3.2-think131K$0.30$0.45
aihubmix/gemini-2.5-flash1.0M$0.07$0.30
aihubmix/gemini-2.5-pro2.0M$1$5
aihubmix/gemini-3-pro-preview1.0M$2$12
aihubmix/glm-4.7205K$0.27$1
aihubmix/gpt-4.11.0M$2$8
aihubmix/gpt-4.1-mini1.0M$0.40$2
aihubmix/gpt-4.1-nano1.0M$0.10$0.40
aihubmix/gpt-4o128K$3$10
aihubmix/gpt-5400K$5$20
aihubmix/gpt-5-codex400K$1$10
aihubmix/gpt-5-mini200K$2$6
aihubmix/gpt-5-nano128K$0.50$2
aihubmix/gpt-5-pro400K$7$28
aihubmix/gpt-5.1400K$1$10
aihubmix/gpt-5.1-codex400K$1$10
aihubmix/gpt-5.1-codex-max400K$1$10
aihubmix/gpt-5.1-codex-mini400K$0.25$2
aihubmix/gpt-5.2400K$2$14
aihubmix/Kimi-K2-0905262K$0.55$2
aihubmix/minimax-m2.1205K$0.29$1
aihubmix/o4-mini200K$2$6
aihubmix/qwen3-235b-a22b-instruct-2507262K$0.28$1
aihubmix/qwen3-235b-a22b-thinking-2507262K$0.28$3
aihubmix/qwen3-coder-480b-a35b-instruct262K$0.82$3
34 available models

Advanced Configuration
Direct link to Advanced Configuration

Custom Headers
Direct link to Custom Headers

const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://aihubmix.com/v1",
id: "aihubmix/Kimi-K2-0905",
apiKey: process.env.AIHUBMIX_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic Model Selection
Direct link to Dynamic Model Selection

const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "aihubmix/qwen3-coder-480b-a35b-instruct"
: "aihubmix/Kimi-K2-0905";
}
});
On this page