# ![Alibaba (China) logo](https://models.dev/logos/alibaba-cn.svg)Alibaba (China)

Access 80 Alibaba (China) models through Mastra's model router. Authentication is handled automatically using the `DASHSCOPE_API_KEY` environment variable.

Learn more in the [Alibaba (China) documentation](https://www.alibabacloud.com/help/en/model-studio/models).

```bash
DASHSCOPE_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: "alibaba-cn/MiniMax-M2.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 [Alibaba (China) documentation](https://www.alibabacloud.com/help/en/model-studio/models) for details.

## Models

| Model                                           | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
| ----------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
| `alibaba-cn/deepseek-r1`                        | 131K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/deepseek-r1-0528`                   | 131K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/deepseek-r1-distill-llama-70b`      | 33K     |       |           |       |       |       | $0.29      | $0.86       |
| `alibaba-cn/deepseek-r1-distill-llama-8b`       | 33K     |       |           |       |       |       | —          | —           |
| `alibaba-cn/deepseek-r1-distill-qwen-1-5b`      | 33K     |       |           |       |       |       | —          | —           |
| `alibaba-cn/deepseek-r1-distill-qwen-14b`       | 33K     |       |           |       |       |       | $0.14      | $0.43       |
| `alibaba-cn/deepseek-r1-distill-qwen-32b`       | 33K     |       |           |       |       |       | $0.29      | $0.86       |
| `alibaba-cn/deepseek-r1-distill-qwen-7b`        | 33K     |       |           |       |       |       | $0.07      | $0.14       |
| `alibaba-cn/deepseek-v3`                        | 66K     |       |           |       |       |       | $0.29      | $1          |
| `alibaba-cn/deepseek-v3-1`                      | 131K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/deepseek-v3-2-exp`                  | 131K    |       |           |       |       |       | $0.29      | $0.43       |
| `alibaba-cn/deepseek-v4-flash`                  | 1.0M    |       |           |       |       |       | $0.14      | $0.28       |
| `alibaba-cn/deepseek-v4-pro`                    | 1.0M    |       |           |       |       |       | $2         | $3          |
| `alibaba-cn/glm-5`                              | 203K    |       |           |       |       |       | $0.86      | $3          |
| `alibaba-cn/glm-5.1`                            | 203K    |       |           |       |       |       | $0.87      | $3          |
| `alibaba-cn/kimi-k2-thinking`                   | 262K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/kimi-k2.5`                          | 262K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/kimi-k2.6`                          | 262K    |       |           |       |       |       | $0.93      | $4          |
| `alibaba-cn/kimi/kimi-k2.5`                     | 262K    |       |           |       |       |       | $0.60      | $3          |
| `alibaba-cn/MiniMax-M2.5`                       | 205K    |       |           |       |       |       | $0.30      | $1          |
| `alibaba-cn/MiniMax/MiniMax-M2.7`               | 205K    |       |           |       |       |       | $0.30      | $1          |
| `alibaba-cn/moonshot-kimi-k2-instruct`          | 131K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/qvq-max`                            | 131K    |       |           |       |       |       | $1         | $5          |
| `alibaba-cn/qwen-deep-research`                 | 1.0M    |       |           |       |       |       | $8         | $23         |
| `alibaba-cn/qwen-doc-turbo`                     | 131K    |       |           |       |       |       | $0.09      | $0.14       |
| `alibaba-cn/qwen-flash`                         | 1.0M    |       |           |       |       |       | $0.02      | $0.22       |
| `alibaba-cn/qwen-long`                          | 10.0M   |       |           |       |       |       | $0.07      | $0.29       |
| `alibaba-cn/qwen-math-plus`                     | 4K      |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/qwen-math-turbo`                    | 4K      |       |           |       |       |       | $0.29      | $0.86       |
| `alibaba-cn/qwen-max`                           | 131K    |       |           |       |       |       | $0.34      | $1          |
| `alibaba-cn/qwen-mt-plus`                       | 16K     |       |           |       |       |       | $0.26      | $0.78       |
| `alibaba-cn/qwen-mt-turbo`                      | 16K     |       |           |       |       |       | $0.10      | $0.28       |
| `alibaba-cn/qwen-omni-turbo`                    | 33K     |       |           |       |       |       | $0.06      | $0.23       |
| `alibaba-cn/qwen-omni-turbo-realtime`           | 33K     |       |           |       |       |       | $0.23      | $0.92       |
| `alibaba-cn/qwen-plus`                          | 1.0M    |       |           |       |       |       | $0.12      | $0.29       |
| `alibaba-cn/qwen-plus-character`                | 33K     |       |           |       |       |       | $0.12      | $0.29       |
| `alibaba-cn/qwen-turbo`                         | 1.0M    |       |           |       |       |       | $0.04      | $0.09       |
| `alibaba-cn/qwen-vl-max`                        | 131K    |       |           |       |       |       | $0.23      | $0.57       |
| `alibaba-cn/qwen-vl-ocr`                        | 34K     |       |           |       |       |       | $0.72      | $0.72       |
| `alibaba-cn/qwen-vl-plus`                       | 131K    |       |           |       |       |       | $0.12      | $0.29       |
| `alibaba-cn/qwen2-5-14b-instruct`               | 131K    |       |           |       |       |       | $0.14      | $0.43       |
| `alibaba-cn/qwen2-5-32b-instruct`               | 131K    |       |           |       |       |       | $0.29      | $0.86       |
| `alibaba-cn/qwen2-5-72b-instruct`               | 131K    |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/qwen2-5-7b-instruct`                | 131K    |       |           |       |       |       | $0.07      | $0.14       |
| `alibaba-cn/qwen2-5-coder-32b-instruct`         | 131K    |       |           |       |       |       | $0.29      | $0.86       |
| `alibaba-cn/qwen2-5-coder-7b-instruct`          | 131K    |       |           |       |       |       | $0.14      | $0.29       |
| `alibaba-cn/qwen2-5-math-72b-instruct`          | 4K      |       |           |       |       |       | $0.57      | $2          |
| `alibaba-cn/qwen2-5-math-7b-instruct`           | 4K      |       |           |       |       |       | $0.14      | $0.29       |
| `alibaba-cn/qwen2-5-omni-7b`                    | 33K     |       |           |       |       |       | $0.09      | $0.34       |
| `alibaba-cn/qwen2-5-vl-72b-instruct`            | 131K    |       |           |       |       |       | $2         | $7          |
| `alibaba-cn/qwen2-5-vl-7b-instruct`             | 131K    |       |           |       |       |       | $0.29      | $0.72       |
| `alibaba-cn/qwen3-14b`                          | 131K    |       |           |       |       |       | $0.14      | $0.57       |
| `alibaba-cn/qwen3-235b-a22b`                    | 131K    |       |           |       |       |       | $0.29      | $1          |
| `alibaba-cn/qwen3-32b`                          | 131K    |       |           |       |       |       | $0.29      | $1          |
| `alibaba-cn/qwen3-8b`                           | 131K    |       |           |       |       |       | $0.07      | $0.29       |
| `alibaba-cn/qwen3-asr-flash`                    | 53K     |       |           |       |       |       | $0.03      | $0.03       |
| `alibaba-cn/qwen3-coder-30b-a3b-instruct`       | 262K    |       |           |       |       |       | $0.22      | $0.86       |
| `alibaba-cn/qwen3-coder-480b-a35b-instruct`     | 262K    |       |           |       |       |       | $0.86      | $3          |
| `alibaba-cn/qwen3-coder-flash`                  | 1.0M    |       |           |       |       |       | $0.14      | $0.57       |
| `alibaba-cn/qwen3-coder-plus`                   | 1.0M    |       |           |       |       |       | $1         | $5          |
| `alibaba-cn/qwen3-max`                          | 262K    |       |           |       |       |       | $0.86      | $3          |
| `alibaba-cn/qwen3-next-80b-a3b-instruct`        | 131K    |       |           |       |       |       | $0.14      | $0.57       |
| `alibaba-cn/qwen3-next-80b-a3b-thinking`        | 131K    |       |           |       |       |       | $0.14      | $1          |
| `alibaba-cn/qwen3-omni-flash`                   | 66K     |       |           |       |       |       | $0.06      | $0.23       |
| `alibaba-cn/qwen3-omni-flash-realtime`          | 66K     |       |           |       |       |       | $0.23      | $0.92       |
| `alibaba-cn/qwen3-vl-235b-a22b`                 | 131K    |       |           |       |       |       | $0.29      | $1          |
| `alibaba-cn/qwen3-vl-30b-a3b`                   | 131K    |       |           |       |       |       | $0.11      | $0.43       |
| `alibaba-cn/qwen3-vl-plus`                      | 262K    |       |           |       |       |       | $0.14      | $1          |
| `alibaba-cn/qwen3.5-397b-a17b`                  | 262K    |       |           |       |       |       | $0.43      | $3          |
| `alibaba-cn/qwen3.5-flash`                      | 1.0M    |       |           |       |       |       | $0.17      | $2          |
| `alibaba-cn/qwen3.5-plus`                       | 1.0M    |       |           |       |       |       | $0.57      | $3          |
| `alibaba-cn/qwen3.6-max-preview`                | 246K    |       |           |       |       |       | $1         | $8          |
| `alibaba-cn/qwen3.6-plus`                       | 1.0M    |       |           |       |       |       | $0.50      | $3          |
| `alibaba-cn/qwq-32b`                            | 131K    |       |           |       |       |       | $0.29      | $0.86       |
| `alibaba-cn/qwq-plus`                           | 131K    |       |           |       |       |       | $0.23      | $0.57       |
| `alibaba-cn/siliconflow/deepseek-r1-0528`       | 164K    |       |           |       |       |       | $0.50      | $2          |
| `alibaba-cn/siliconflow/deepseek-v3-0324`       | 164K    |       |           |       |       |       | $0.25      | $1          |
| `alibaba-cn/siliconflow/deepseek-v3.1-terminus` | 164K    |       |           |       |       |       | $0.27      | $1          |
| `alibaba-cn/siliconflow/deepseek-v3.2`          | 164K    |       |           |       |       |       | $0.27      | $0.42       |
| `alibaba-cn/tongyi-intent-detect-v3`            | 8K      |       |           |       |       |       | $0.06      | $0.14       |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://dashscope.aliyuncs.com/compatible-mode/v1",
    id: "alibaba-cn/MiniMax-M2.5",
    apiKey: process.env.DASHSCOPE_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
      ? "alibaba-cn/tongyi-intent-detect-v3"
      : "alibaba-cn/MiniMax-M2.5";
  }
});
```