Skip to main content

AIHubMix logoAIHubMix

通过 Mastra 的模型路由访问 37 个 AIHubMix 模型。身份验证会自动使用 AIHUBMIX_API_KEY 环境变量处理。

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

AIHubMix 文档 中了解更多信息。

🌐 Learn more in the AIHubMix documentation.

.env
AIHUBMIX_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: "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 使用与 OpenAI 兼容的 /chat/completions 端点。一些特定于提供商的功能可能不可用。详情请查看 AIHubMix 文档

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

模型
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.7205K$0.27$1
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-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.6v128K$0.14$0.41
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/kimi-k2.5262K$0.60$3
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
aihubmix/qwen3-max-2026-01-23262K$0.34$1
37 available models

高级配置
Direct link to 高级配置

🌐 Advanced Configuration

自定义头
Direct link to 自定义头

🌐 Custom Headers

src/mastra/agents/my-agent.ts
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"
}
}
});

动态模型选择
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
? "aihubmix/qwen3-max-2026-01-23"
: "aihubmix/Kimi-K2-0905";
}
});