# ![Qiniu logo](https://models.dev/logos/qiniu-ai.svg)Qiniu

Access 91 Qiniu models through Mastra's model router. Authentication is handled automatically using the `QINIU_API_KEY` environment variable.

Learn more in the [Qiniu documentation](https://developer.qiniu.com/aitokenapi).

```bash
QINIU_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: "qiniu-ai/MiniMax-M1"
});

// 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 [Qiniu documentation](https://developer.qiniu.com/aitokenapi) for details.

## Models

| Model                                               | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
| --------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
| `qiniu-ai/claude-3.5-haiku`                         | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-3.5-sonnet`                        | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-3.7-sonnet`                        | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-4.0-opus`                          | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-4.0-sonnet`                        | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-4.1-opus`                          | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-4.5-haiku`                         | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-4.5-opus`                          | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/claude-4.5-sonnet`                        | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek-r1`                              | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek-r1-0528`                         | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek-v3`                              | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek-v3-0324`                         | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek-v3.1`                            | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek/deepseek-math-v2`                | 160K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek/deepseek-v3.1-terminus`          | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek/deepseek-v3.1-terminus-thinking` | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek/deepseek-v3.2-251201`            | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek/deepseek-v3.2-exp`               | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/deepseek/deepseek-v3.2-exp-thinking`      | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-1.5-pro-32k`                       | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-1.5-thinking-pro`                  | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-1.5-vision-pro`                    | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-1.6`                          | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-1.6-flash`                    | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-1.6-thinking`                 | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-2.0-code`                     | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-2.0-lite`                     | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-2.0-mini`                     | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/doubao-seed-2.0-pro`                      | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-2.0-flash`                         | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-2.0-flash-lite`                    | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-2.5-flash`                         | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-2.5-flash-image`                   | 33K     |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-2.5-flash-lite`                    | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-2.5-pro`                           | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-3.0-flash-preview`                 | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-3.0-pro-image-preview`             | 33K     |       |           |       |       |       | —          | —           |
| `qiniu-ai/gemini-3.0-pro-preview`                   | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/glm-4.5`                                  | 131K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/glm-4.5-air`                              | 131K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gpt-oss-120b`                             | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/gpt-oss-20b`                              | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/kimi-k2`                                  | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/kling-v2-6`                               | 100.0M  |       |           |       |       |       | —          | —           |
| `qiniu-ai/meituan/longcat-flash-chat`               | 131K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/meituan/longcat-flash-lite`               | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/mimo-v2-flash`                            | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/MiniMax-M1`                               | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/minimax/minimax-m2`                       | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/minimax/minimax-m2.1`                     | 205K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/minimax/minimax-m2.5`                     | 205K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/minimax/minimax-m2.5-highspeed`           | 205K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/moonshotai/kimi-k2-0905`                  | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/moonshotai/kimi-k2-thinking`              | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/moonshotai/kimi-k2.5`                     | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/openai/gpt-5`                             | 400K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/openai/gpt-5.2`                           | 400K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen-max-2025-01-25`                      | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen-turbo`                               | 1.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen-vl-max-2025-01-25`                   | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen2.5-vl-72b-instruct`                  | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen2.5-vl-7b-instruct`                   | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-235b-a22b`                          | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-235b-a22b-instruct-2507`            | 262K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-235b-a22b-thinking-2507`            | 262K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-30b-a3b`                            | 40K     |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-30b-a3b-instruct-2507`              | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-30b-a3b-thinking-2507`              | 126K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-32b`                                | 40K     |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-coder-480b-a35b-instruct`           | 262K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-max`                                | 262K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-max-preview`                        | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-next-80b-a3b-instruct`              | 131K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-next-80b-a3b-thinking`              | 131K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3-vl-30b-a3b-thinking`                | 128K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/qwen3.5-397b-a17b`                        | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/stepfun-ai/gelab-zero-4b-preview`         | 8K      |       |           |       |       |       | —          | —           |
| `qiniu-ai/stepfun/step-3.5-flash`                   | 64K     |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-4-fast`                         | 2.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-4-fast-non-reasoning`           | 2.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-4-fast-reasoning`               | 2.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-4.1-fast`                       | 2.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-4.1-fast-non-reasoning`         | 2.0M    |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-4.1-fast-reasoning`             | 20.0M   |       |           |       |       |       | —          | —           |
| `qiniu-ai/x-ai/grok-code-fast-1`                    | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/xiaomi/mimo-v2-flash`                     | 256K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/z-ai/autoglm-phone-9b`                    | 13K     |       |           |       |       |       | —          | —           |
| `qiniu-ai/z-ai/glm-4.6`                             | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/z-ai/glm-4.7`                             | 200K    |       |           |       |       |       | —          | —           |
| `qiniu-ai/z-ai/glm-5`                               | 200K    |       |           |       |       |       | —          | —           |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.qnaigc.com/v1",
    id: "qiniu-ai/MiniMax-M1",
    apiKey: process.env.QINIU_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
      ? "qiniu-ai/z-ai/glm-5"
      : "qiniu-ai/MiniMax-M1";
  }
});
```