> Discover all available pages from the documentation index: https://mastra.ai/llms.txt

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

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

Learn more in the [Alibaba 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/deepseek-v4-flash-0731"
});

// 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);
}
```

> **Note:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Alibaba 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/deepseek-v4-flash-0731`             | 1.0M    |       |           |       |       |       | $0.20      | $0.40       |
| `alibaba/glm-5.2`                            | 1.0M    |       |           |       |       |       | $1         | $4          |
| `alibaba/qvq-max`                            | 131K    |       |           |       |       |       | $1         | $5          |
| `alibaba/qwen-flash`                         | 1.0M    |       |           |       |       |       | $0.05      | $0.40       |
| `alibaba/qwen-max`                           | 33K     |       |           |       |       |       | $2         | $6          |
| `alibaba/qwen-mt-plus`                       | 16K     |       |           |       |       |       | $2         | $7          |
| `alibaba/qwen-mt-turbo`                      | 16K     |       |           |       |       |       | $0.16      | $0.49       |
| `alibaba/qwen-omni-turbo`                    | 33K     |       |           |       |       |       | $0.07      | $0.27       |
| `alibaba/qwen-omni-turbo-realtime`           | 33K     |       |           |       |       |       | $0.27      | $1          |
| `alibaba/qwen-plus`                          | 1.0M    |       |           |       |       |       | $0.40      | $1          |
| `alibaba/qwen-plus-character-ja`             | 8K      |       |           |       |       |       | $0.50      | $1          |
| `alibaba/qwen-turbo`                         | 1.0M    |       |           |       |       |       | $0.05      | $0.20       |
| `alibaba/qwen-vl-max`                        | 131K    |       |           |       |       |       | $0.80      | $3          |
| `alibaba/qwen-vl-ocr`                        | 34K     |       |           |       |       |       | $0.72      | $0.72       |
| `alibaba/qwen-vl-plus`                       | 131K    |       |           |       |       |       | $0.21      | $0.63       |
| `alibaba/qwen2-5-14b-instruct`               | 131K    |       |           |       |       |       | $0.35      | $1          |
| `alibaba/qwen2-5-32b-instruct`               | 131K    |       |           |       |       |       | $0.70      | $3          |
| `alibaba/qwen2-5-72b-instruct`               | 131K    |       |           |       |       |       | $1         | $6          |
| `alibaba/qwen2-5-7b-instruct`                | 131K    |       |           |       |       |       | $0.17      | $0.70       |
| `alibaba/qwen2-5-omni-7b`                    | 33K     |       |           |       |       |       | $0.10      | $0.40       |
| `alibaba/qwen2-5-vl-72b-instruct`            | 131K    |       |           |       |       |       | $3         | $8          |
| `alibaba/qwen2-5-vl-7b-instruct`             | 131K    |       |           |       |       |       | $0.35      | $1          |
| `alibaba/qwen3-14b`                          | 131K    |       |           |       |       |       | $0.35      | $1          |
| `alibaba/qwen3-235b-a22b`                    | 131K    |       |           |       |       |       | $0.70      | $3          |
| `alibaba/qwen3-32b`                          | 131K    |       |           |       |       |       | $0.70      | $3          |
| `alibaba/qwen3-8b`                           | 131K    |       |           |       |       |       | $0.18      | $0.70       |
| `alibaba/qwen3-asr-flash`                    | 53K     |       |           |       |       |       | $0.04      | $0.04       |
| `alibaba/qwen3-coder-30b-a3b-instruct`       | 262K    |       |           |       |       |       | $0.45      | $2          |
| `alibaba/qwen3-coder-480b-a35b-instruct`     | 262K    |       |           |       |       |       | $2         | $8          |
| `alibaba/qwen3-coder-flash`                  | 1.0M    |       |           |       |       |       | $0.30      | $2          |
| `alibaba/qwen3-coder-plus`                   | 1.0M    |       |           |       |       |       | $1         | $5          |
| `alibaba/qwen3-livetranslate-flash-realtime` | 53K     |       |           |       |       |       | $10        | $10         |
| `alibaba/qwen3-max`                          | 262K    |       |           |       |       |       | $1         | $6          |
| `alibaba/qwen3-next-80b-a3b-instruct`        | 131K    |       |           |       |       |       | $0.50      | $2          |
| `alibaba/qwen3-next-80b-a3b-thinking`        | 131K    |       |           |       |       |       | $0.50      | $6          |
| `alibaba/qwen3-omni-flash`                   | 66K     |       |           |       |       |       | $0.43      | $2          |
| `alibaba/qwen3-omni-flash-realtime`          | 66K     |       |           |       |       |       | $0.52      | $2          |
| `alibaba/qwen3-vl-235b-a22b`                 | 131K    |       |           |       |       |       | $0.70      | $3          |
| `alibaba/qwen3-vl-30b-a3b`                   | 131K    |       |           |       |       |       | $0.20      | $0.80       |
| `alibaba/qwen3-vl-plus`                      | 262K    |       |           |       |       |       | $0.20      | $2          |
| `alibaba/qwen3.5-122b-a10b`                  | 262K    |       |           |       |       |       | $0.40      | $3          |
| `alibaba/qwen3.5-27b`                        | 262K    |       |           |       |       |       | $0.30      | $2          |
| `alibaba/qwen3.5-35b-a3b`                    | 262K    |       |           |       |       |       | $0.25      | $2          |
| `alibaba/qwen3.5-397b-a17b`                  | 262K    |       |           |       |       |       | $0.60      | $4          |
| `alibaba/qwen3.5-plus`                       | 1.0M    |       |           |       |       |       | $0.40      | $2          |
| `alibaba/qwen3.6-27b`                        | 262K    |       |           |       |       |       | $0.60      | $4          |
| `alibaba/qwen3.6-35b-a3b`                    | 262K    |       |           |       |       |       | $0.25      | $1          |
| `alibaba/qwen3.6-flash`                      | 1.0M    |       |           |       |       |       | $0.19      | $1          |
| `alibaba/qwen3.6-max-preview`                | 262K    |       |           |       |       |       | $1         | $8          |
| `alibaba/qwen3.6-plus`                       | 1.0M    |       |           |       |       |       | $0.50      | $3          |
| `alibaba/qwen3.7-max`                        | 1.0M    |       |           |       |       |       | $3         | $8          |
| `alibaba/qwen3.7-plus`                       | 1.0M    |       |           |       |       |       | $0.50      | $3          |
| `alibaba/qwen3.8-max`                        | 1.0M    |       |           |       |       |       | $2         | $6          |
| `alibaba/qwq-plus`                           | 131K    |       |           |       |       |       | $0.80      | $2          |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
    id: "alibaba/deepseek-v4-flash-0731",
    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/qwq-plus"
      : "alibaba/deepseek-v4-flash-0731";
  }
});
```