Skip to main content

Alibaba logoAlibaba

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

Learn more in the Alibaba 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/qvq-max"
});

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

Models​

ModelImageAudioVideoToolsStreamingContext Window
alibaba/qvq-max✓✗✗✓✗131,072
alibaba/qwen-flash✗✗✗✓✗1,000,000
alibaba/qwen-max✗✗✗✓✗32,768
alibaba/qwen-mt-plus✗✗✗✗✗16,384
alibaba/qwen-mt-turbo✗✗✗✗✗16,384
alibaba/qwen-omni-turbo✓✓✓✓✗32,768
alibaba/qwen-omni-turbo-realtime✓✓✗✓✗32,768
alibaba/qwen-plus✗✗✗✓✗1,000,000
alibaba/qwen-plus-character-ja✗✗✗✓✗8,192
alibaba/qwen-turbo✗✗✗✓✗1,000,000
alibaba/qwen-vl-max✓✗✗✓✗131,072
alibaba/qwen-vl-ocr✓✗✗✗✗34,096
alibaba/qwen-vl-plus✓✗✗✓✗131,072
alibaba/qwen2-5-14b-instruct✗✗✗✓✗131,072
alibaba/qwen2-5-32b-instruct✗✗✗✓✗131,072
alibaba/qwen2-5-72b-instruct✗✗✗✓✗131,072
alibaba/qwen2-5-7b-instruct✗✗✗✓✗131,072
alibaba/qwen2-5-omni-7b✓✓✓✓✗32,768
alibaba/qwen2-5-vl-72b-instruct✓✗✗✓✗131,072
alibaba/qwen2-5-vl-7b-instruct✓✗✗✓✗131,072
alibaba/qwen3-14b✗✗✗✓✗131,072
alibaba/qwen3-235b-a22b✗✗✗✓✗131,072
alibaba/qwen3-32b✗✗✗✓✗131,072
alibaba/qwen3-8b✗✗✗✓✗131,072
alibaba/qwen3-asr-flash✗✓✗✗✗53,248
alibaba/qwen3-coder-30b-a3b-instruct✗✗✗✓✗262,144
alibaba/qwen3-coder-480b-a35b-instruct✗✗✗✓✗262,144
alibaba/qwen3-coder-flash✗✗✗✓✗1,000,000
alibaba/qwen3-coder-plus✗✗✗✓✗1,048,576
alibaba/qwen3-livetranslate-flash-realtime✓✓✓✗✗53,248
alibaba/qwen3-max✗✗✗✓✗262,144
alibaba/qwen3-next-80b-a3b-instruct✗✗✗✓✗131,072
alibaba/qwen3-next-80b-a3b-thinking✗✗✗✓✗131,072
alibaba/qwen3-omni-flash✓✓✓✓✗65,536
alibaba/qwen3-omni-flash-realtime✓✓✓✓✗65,536
alibaba/qwen3-vl-235b-a22b✓✗✗✓✗131,072
alibaba/qwen3-vl-30b-a3b✓✗✗✓✗131,072
alibaba/qwen3-vl-plus✓✗✗✓✗262,144
alibaba/qwq-plus✗✗✗✓✗131,072

Advanced Configuration​

Custom Headers​

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

On this page