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-r1131,072
alibaba-cn/deepseek-r1-0528131,072
alibaba-cn/deepseek-r1-distill-llama-70b32,768
alibaba-cn/deepseek-r1-distill-llama-8b32,768
alibaba-cn/deepseek-r1-distill-qwen-1-5b32,768
alibaba-cn/deepseek-r1-distill-qwen-14b32,768
alibaba-cn/deepseek-r1-distill-qwen-32b32,768
alibaba-cn/deepseek-r1-distill-qwen-7b32,768
alibaba-cn/deepseek-v365,536
alibaba-cn/deepseek-v3-1131,072
alibaba-cn/deepseek-v3-2-exp131,072
alibaba-cn/moonshot-kimi-k2-instruct131,072
alibaba-cn/qvq-max131,072
alibaba-cn/qwen-deep-research1,000,000
alibaba-cn/qwen-doc-turbo131,072
alibaba-cn/qwen-flash1,000,000
alibaba-cn/qwen-long10,000,000
alibaba-cn/qwen-math-plus4,096
alibaba-cn/qwen-math-turbo4,096
alibaba-cn/qwen-max131,072
alibaba-cn/qwen-mt-plus16,384
alibaba-cn/qwen-mt-turbo16,384
alibaba-cn/qwen-omni-turbo32,768
alibaba-cn/qwen-omni-turbo-realtime32,768
alibaba-cn/qwen-plus1,000,000
alibaba-cn/qwen-plus-character32,768
alibaba-cn/qwen-turbo1,000,000
alibaba-cn/qwen-vl-max131,072
alibaba-cn/qwen-vl-ocr34,096
alibaba-cn/qwen-vl-plus131,072
alibaba-cn/qwen2-5-14b-instruct131,072
alibaba-cn/qwen2-5-32b-instruct131,072
alibaba-cn/qwen2-5-72b-instruct131,072
alibaba-cn/qwen2-5-7b-instruct131,072
alibaba-cn/qwen2-5-coder-32b-instruct131,072
alibaba-cn/qwen2-5-coder-7b-instruct131,072
alibaba-cn/qwen2-5-math-72b-instruct4,096
alibaba-cn/qwen2-5-math-7b-instruct4,096
alibaba-cn/qwen2-5-omni-7b32,768
alibaba-cn/qwen2-5-vl-72b-instruct131,072
alibaba-cn/qwen2-5-vl-7b-instruct131,072
alibaba-cn/qwen3-14b131,072
alibaba-cn/qwen3-235b-a22b131,072
alibaba-cn/qwen3-32b131,072
alibaba-cn/qwen3-8b131,072
alibaba-cn/qwen3-asr-flash53,248
alibaba-cn/qwen3-coder-30b-a3b-instruct262,144
alibaba-cn/qwen3-coder-480b-a35b-instruct262,144
alibaba-cn/qwen3-coder-flash1,000,000
alibaba-cn/qwen3-coder-plus1,048,576
alibaba-cn/qwen3-max262,144
alibaba-cn/qwen3-next-80b-a3b-instruct131,072
alibaba-cn/qwen3-next-80b-a3b-thinking131,072
alibaba-cn/qwen3-omni-flash65,536
alibaba-cn/qwen3-omni-flash-realtime65,536
alibaba-cn/qwen3-vl-235b-a22b131,072
alibaba-cn/qwen3-vl-30b-a3b131,072
alibaba-cn/qwen3-vl-plus262,144
alibaba-cn/qwq-32b131,072
alibaba-cn/qwq-plus131,072
alibaba-cn/tongyi-intent-detect-v38,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