Skip to main content

Alibaba (China) logoAlibaba (China)

Access 61 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.

DASHSCOPE_API_KEY=your-api-key
import { Agent } from "@mastra/core";

const agent = new Agent({
name: "my-agent",
instructions: "You are a helpful assistant",
model: "alibaba-cn/deepseek-r1"
});

// 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 for details.

Models​

ModelImageAudioVideoToolsStreamingContext Window
alibaba-cn/deepseek-r1✗✗✗✓✗131,072
alibaba-cn/deepseek-r1-0528✗✗✗✓✗131,072
alibaba-cn/deepseek-r1-distill-llama-70b✗✗✗✓✗32,768
alibaba-cn/deepseek-r1-distill-llama-8b✗✗✗✓✗32,768
alibaba-cn/deepseek-r1-distill-qwen-1-5b✗✗✗✓✗32,768
alibaba-cn/deepseek-r1-distill-qwen-14b✗✗✗✓✗32,768
alibaba-cn/deepseek-r1-distill-qwen-32b✗✗✗✓✗32,768
alibaba-cn/deepseek-r1-distill-qwen-7b✗✗✗✓✗32,768
alibaba-cn/deepseek-v3✗✗✗✓✗65,536
alibaba-cn/deepseek-v3-1✗✗✗✓✗131,072
alibaba-cn/deepseek-v3-2-exp✗✗✗✓✗131,072
alibaba-cn/moonshot-kimi-k2-instruct✗✗✗✓✗131,072
alibaba-cn/qvq-max✓✗✗✓✗131,072
alibaba-cn/qwen-deep-research✗✗✗✓✗1,000,000
alibaba-cn/qwen-doc-turbo✗✗✗✓✗131,072
alibaba-cn/qwen-flash✗✗✗✓✗1,000,000
alibaba-cn/qwen-long✗✗✗✓✗10,000,000
alibaba-cn/qwen-math-plus✗✗✗✓✗4,096
alibaba-cn/qwen-math-turbo✗✗✗✓✗4,096
alibaba-cn/qwen-max✗✗✗✓✗131,072
alibaba-cn/qwen-mt-plus✗✗✗✗✗16,384
alibaba-cn/qwen-mt-turbo✗✗✗✗✗16,384
alibaba-cn/qwen-omni-turbo✓✓✓✓✗32,768
alibaba-cn/qwen-omni-turbo-realtime✓✓✗✓✗32,768
alibaba-cn/qwen-plus✗✗✗✓✗1,000,000
alibaba-cn/qwen-plus-character✗✗✗✓✗32,768
alibaba-cn/qwen-turbo✗✗✗✓✗1,000,000
alibaba-cn/qwen-vl-max✓✗✗✓✗131,072
alibaba-cn/qwen-vl-ocr✓✗✗✗✗34,096
alibaba-cn/qwen-vl-plus✓✗✗✓✗131,072
alibaba-cn/qwen2-5-14b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen2-5-32b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen2-5-72b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen2-5-7b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen2-5-coder-32b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen2-5-coder-7b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen2-5-math-72b-instruct✗✗✗✓✗4,096
alibaba-cn/qwen2-5-math-7b-instruct✗✗✗✓✗4,096
alibaba-cn/qwen2-5-omni-7b✓✓✓✓✗32,768
alibaba-cn/qwen2-5-vl-72b-instruct✓✗✗✓✗131,072
alibaba-cn/qwen2-5-vl-7b-instruct✓✗✗✓✗131,072
alibaba-cn/qwen3-14b✗✗✗✓✗131,072
alibaba-cn/qwen3-235b-a22b✗✗✗✓✗131,072
alibaba-cn/qwen3-32b✗✗✗✓✗131,072
alibaba-cn/qwen3-8b✗✗✗✓✗131,072
alibaba-cn/qwen3-asr-flash✗✓✗✗✗53,248
alibaba-cn/qwen3-coder-30b-a3b-instruct✗✗✗✓✗262,144
alibaba-cn/qwen3-coder-480b-a35b-instruct✗✗✗✓✗262,144
alibaba-cn/qwen3-coder-flash✗✗✗✓✗1,000,000
alibaba-cn/qwen3-coder-plus✗✗✗✓✗1,048,576
alibaba-cn/qwen3-max✗✗✗✓✗262,144
alibaba-cn/qwen3-next-80b-a3b-instruct✗✗✗✓✗131,072
alibaba-cn/qwen3-next-80b-a3b-thinking✗✗✗✓✗131,072
alibaba-cn/qwen3-omni-flash✓✓✓✓✗65,536
alibaba-cn/qwen3-omni-flash-realtime✓✓✗✓✗65,536
alibaba-cn/qwen3-vl-235b-a22b✓✗✗✓✗131,072
alibaba-cn/qwen3-vl-30b-a3b✓✗✗✓✗131,072
alibaba-cn/qwen3-vl-plus✓✗✗✓✗262,144
alibaba-cn/qwq-32b✗✗✗✓✗131,072
alibaba-cn/qwq-plus✗✗✗✓✗131,072
alibaba-cn/tongyi-intent-detect-v3✗✗✗✗✗8,192

Advanced Configuration​

Custom Headers​

const agent = new Agent({
name: "custom-agent",
model: {
url: "https://dashscope.aliyuncs.com/compatible-mode/v1",
id: "alibaba-cn/deepseek-r1",
apiKey: process.env.DASHSCOPE_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic Model Selection​

const agent = new Agent({
name: "dynamic-agent",
model: ({ runtimeContext }) => {
const useAdvanced = runtimeContext.task === "complex";
return useAdvanced
? "alibaba-cn/tongyi-intent-detect-v3"
: "alibaba-cn/deepseek-r1";
}
});

On this page