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-max131,072
alibaba/qwen-flash1,000,000
alibaba/qwen-max32,768
alibaba/qwen-mt-plus16,384
alibaba/qwen-mt-turbo16,384
alibaba/qwen-omni-turbo32,768
alibaba/qwen-omni-turbo-realtime32,768
alibaba/qwen-plus1,000,000
alibaba/qwen-plus-character-ja8,192
alibaba/qwen-turbo1,000,000
alibaba/qwen-vl-max131,072
alibaba/qwen-vl-ocr34,096
alibaba/qwen-vl-plus131,072
alibaba/qwen2-5-14b-instruct131,072
alibaba/qwen2-5-32b-instruct131,072
alibaba/qwen2-5-72b-instruct131,072
alibaba/qwen2-5-7b-instruct131,072
alibaba/qwen2-5-omni-7b32,768
alibaba/qwen2-5-vl-72b-instruct131,072
alibaba/qwen2-5-vl-7b-instruct131,072
alibaba/qwen3-14b131,072
alibaba/qwen3-235b-a22b131,072
alibaba/qwen3-32b131,072
alibaba/qwen3-8b131,072
alibaba/qwen3-asr-flash53,248
alibaba/qwen3-coder-30b-a3b-instruct262,144
alibaba/qwen3-coder-480b-a35b-instruct262,144
alibaba/qwen3-coder-flash1,000,000
alibaba/qwen3-coder-plus1,048,576
alibaba/qwen3-livetranslate-flash-realtime53,248
alibaba/qwen3-max262,144
alibaba/qwen3-next-80b-a3b-instruct131,072
alibaba/qwen3-next-80b-a3b-thinking131,072
alibaba/qwen3-omni-flash65,536
alibaba/qwen3-omni-flash-realtime65,536
alibaba/qwen3-vl-235b-a22b131,072
alibaba/qwen3-vl-30b-a3b131,072
alibaba/qwen3-vl-plus262,144
alibaba/qwq-plus131,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