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

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
alibaba-cn/deepseek-r1131K$0.57$2
alibaba-cn/deepseek-r1-0528131K$0.57$2
alibaba-cn/deepseek-r1-distill-llama-70b33K$0.29$0.86
alibaba-cn/deepseek-r1-distill-llama-8b33K
alibaba-cn/deepseek-r1-distill-qwen-1-5b33K
alibaba-cn/deepseek-r1-distill-qwen-14b33K$0.14$0.43
alibaba-cn/deepseek-r1-distill-qwen-32b33K$0.29$0.86
alibaba-cn/deepseek-r1-distill-qwen-7b33K$0.07$0.14
alibaba-cn/deepseek-v366K$0.29$1
alibaba-cn/deepseek-v3-1131K$0.57$2
alibaba-cn/deepseek-v3-2-exp131K$0.29$0.43
alibaba-cn/moonshot-kimi-k2-instruct131K$0.57$2
alibaba-cn/qvq-max131K$1$5
alibaba-cn/qwen-deep-research1.0M$8$23
alibaba-cn/qwen-doc-turbo131K$0.09$0.14
alibaba-cn/qwen-flash1.0M$0.02$0.22
alibaba-cn/qwen-long10.0M$0.07$0.29
alibaba-cn/qwen-math-plus4K$0.57$2
alibaba-cn/qwen-math-turbo4K$0.29$0.86
alibaba-cn/qwen-max131K$0.34$1
alibaba-cn/qwen-mt-plus16K$0.26$0.78
alibaba-cn/qwen-mt-turbo16K$0.10$0.28
alibaba-cn/qwen-omni-turbo33K$0.06$0.23
alibaba-cn/qwen-omni-turbo-realtime33K$0.23$0.92
alibaba-cn/qwen-plus1.0M$0.12$0.29
alibaba-cn/qwen-plus-character33K$0.12$0.29
alibaba-cn/qwen-turbo1.0M$0.04$0.09
alibaba-cn/qwen-vl-max131K$0.23$0.57
alibaba-cn/qwen-vl-ocr34K$0.72$0.72
alibaba-cn/qwen-vl-plus131K$0.12$0.29
alibaba-cn/qwen2-5-14b-instruct131K$0.14$0.43
alibaba-cn/qwen2-5-32b-instruct131K$0.29$0.86
alibaba-cn/qwen2-5-72b-instruct131K$0.57$2
alibaba-cn/qwen2-5-7b-instruct131K$0.07$0.14
alibaba-cn/qwen2-5-coder-32b-instruct131K$0.29$0.86
alibaba-cn/qwen2-5-coder-7b-instruct131K$0.14$0.29
alibaba-cn/qwen2-5-math-72b-instruct4K$0.57$2
alibaba-cn/qwen2-5-math-7b-instruct4K$0.14$0.29
alibaba-cn/qwen2-5-omni-7b33K$0.09$0.34
alibaba-cn/qwen2-5-vl-72b-instruct131K$2$7
alibaba-cn/qwen2-5-vl-7b-instruct131K$0.29$0.72
alibaba-cn/qwen3-14b131K$0.14$0.57
alibaba-cn/qwen3-235b-a22b131K$0.29$1
alibaba-cn/qwen3-32b131K$0.29$1
alibaba-cn/qwen3-8b131K$0.07$0.29
alibaba-cn/qwen3-asr-flash53K$0.03$0.03
alibaba-cn/qwen3-coder-30b-a3b-instruct262K$0.22$0.86
alibaba-cn/qwen3-coder-480b-a35b-instruct262K$0.86$3
alibaba-cn/qwen3-coder-flash1.0M$0.14$0.57
alibaba-cn/qwen3-coder-plus1.0M$1$5
alibaba-cn/qwen3-max262K$0.86$3
alibaba-cn/qwen3-next-80b-a3b-instruct131K$0.14$0.57
alibaba-cn/qwen3-next-80b-a3b-thinking131K$0.14$1
alibaba-cn/qwen3-omni-flash66K$0.06$0.23
alibaba-cn/qwen3-omni-flash-realtime66K$0.23$0.92
alibaba-cn/qwen3-vl-235b-a22b131K$0.29$1
alibaba-cn/qwen3-vl-30b-a3b131K$0.11$0.43
alibaba-cn/qwen3-vl-plus262K$0.14$1
alibaba-cn/qwq-32b131K$0.29$0.86
alibaba-cn/qwq-plus131K$0.23$0.57
alibaba-cn/tongyi-intent-detect-v38K$0.06$0.14
61 available models

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