# ![AIHubMix logo](https://models.dev/logos/aihubmix.svg)AIHubMix Access 37 AIHubMix models through Mastra's model router. Authentication is handled automatically using the `AIHUBMIX_API_KEY` environment variable. Learn more in the [AIHubMix documentation](https://docs.aihubmix.com). ```bash AIHUBMIX_API_KEY=your-api-key ``` ```typescript 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](https://docs.aihubmix.com) for details. ## Models | Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M | | ----------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- | | `aihubmix/claude-haiku-4-5` | 200K | | | | | | $1 | $6 | | `aihubmix/claude-opus-4-1` | 200K | | | | | | $17 | $83 | | `aihubmix/claude-opus-4-5` | 200K | | | | | | $5 | $25 | | `aihubmix/claude-sonnet-4-5` | 200K | | | | | | $3 | $17 | | `aihubmix/coding-glm-4.7` | 205K | | | | | | $0.27 | $1 | | `aihubmix/coding-glm-4.7-free` | 205K | | | | | | — | — | | `aihubmix/coding-minimax-m2.1-free` | 205K | | | | | | — | — | | `aihubmix/deepseek-v3.2` | 131K | | | | | | $0.30 | $0.45 | | `aihubmix/deepseek-v3.2-fast` | 128K | | | | | | $1 | $3 | | `aihubmix/deepseek-v3.2-think` | 131K | | | | | | $0.30 | $0.45 | | `aihubmix/gemini-2.5-flash` | 1.0M | | | | | | $0.07 | $0.30 | | `aihubmix/gemini-2.5-pro` | 2.0M | | | | | | $1 | $5 | | `aihubmix/gemini-3-pro-preview` | 1.0M | | | | | | $2 | $12 | | `aihubmix/glm-4.6v` | 128K | | | | | | $0.14 | $0.41 | | `aihubmix/glm-4.7` | 205K | | | | | | $0.27 | $1 | | `aihubmix/gpt-4.1` | 1.0M | | | | | | $2 | $8 | | `aihubmix/gpt-4.1-mini` | 1.0M | | | | | | $0.40 | $2 | | `aihubmix/gpt-4.1-nano` | 1.0M | | | | | | $0.10 | $0.40 | | `aihubmix/gpt-4o` | 128K | | | | | | $3 | $10 | | `aihubmix/gpt-5` | 400K | | | | | | $5 | $20 | | `aihubmix/gpt-5-codex` | 400K | | | | | | $1 | $10 | | `aihubmix/gpt-5-mini` | 200K | | | | | | $2 | $6 | | `aihubmix/gpt-5-nano` | 128K | | | | | | $0.50 | $2 | | `aihubmix/gpt-5-pro` | 400K | | | | | | $7 | $28 | | `aihubmix/gpt-5.1` | 400K | | | | | | $1 | $10 | | `aihubmix/gpt-5.1-codex` | 400K | | | | | | $1 | $10 | | `aihubmix/gpt-5.1-codex-max` | 400K | | | | | | $1 | $10 | | `aihubmix/gpt-5.1-codex-mini` | 400K | | | | | | $0.25 | $2 | | `aihubmix/gpt-5.2` | 400K | | | | | | $2 | $14 | | `aihubmix/Kimi-K2-0905` | 262K | | | | | | $0.55 | $2 | | `aihubmix/kimi-k2.5` | 262K | | | | | | $0.60 | $3 | | `aihubmix/minimax-m2.1` | 205K | | | | | | $0.29 | $1 | | `aihubmix/o4-mini` | 200K | | | | | | $2 | $6 | | `aihubmix/qwen3-235b-a22b-instruct-2507` | 262K | | | | | | $0.28 | $1 | | `aihubmix/qwen3-235b-a22b-thinking-2507` | 262K | | | | | | $0.28 | $3 | | `aihubmix/qwen3-coder-480b-a35b-instruct` | 262K | | | | | | $0.82 | $3 | | `aihubmix/qwen3-max-2026-01-23` | 262K | | | | | | $0.34 | $1 | ## Advanced Configuration ### Custom Headers ```typescript 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 ```typescript 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"; } }); ```