阿里巴巴
🌐 Alibaba
通过 Mastra 的模型路由访问 39 个阿里巴巴模型。身份验证会自动使用 DASHSCOPE_API_KEY 环境变量处理。
🌐 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.
.env
DASHSCOPE_API_KEY=your-api-key
src/mastra/agents/my-agent.ts
import { Agent } from "@mastra/core/agent";
const agent = new Agent({
id: "my-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 使用与 OpenAI 兼容的 /chat/completions 端点。某些特定于提供商的功能可能无法使用。详见 阿里巴巴文档。
🌐 Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Alibaba documentation for details.
模型Direct link to 模型
🌐 Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
alibaba/qvq-max | 131K | $1 | $5 | |||||
alibaba/qwen-flash | 1.0M | $0.05 | $0.40 | |||||
alibaba/qwen-max | 33K | $2 | $6 | |||||
alibaba/qwen-mt-plus | 16K | $2 | $7 | |||||
alibaba/qwen-mt-turbo | 16K | $0.16 | $0.49 | |||||
alibaba/qwen-omni-turbo | 33K | $0.07 | $0.27 | |||||
alibaba/qwen-omni-turbo-realtime | 33K | $0.27 | $1 | |||||
alibaba/qwen-plus | 1.0M | $0.40 | $1 | |||||
alibaba/qwen-plus-character-ja | 8K | $0.50 | $1 | |||||
alibaba/qwen-turbo | 1.0M | $0.05 | $0.20 | |||||
alibaba/qwen-vl-max | 131K | $0.80 | $3 | |||||
alibaba/qwen-vl-ocr | 34K | $0.72 | $0.72 | |||||
alibaba/qwen-vl-plus | 131K | $0.21 | $0.63 | |||||
alibaba/qwen2-5-14b-instruct | 131K | $0.35 | $1 | |||||
alibaba/qwen2-5-32b-instruct | 131K | $0.70 | $3 | |||||
alibaba/qwen2-5-72b-instruct | 131K | $1 | $6 | |||||
alibaba/qwen2-5-7b-instruct | 131K | $0.17 | $0.70 | |||||
alibaba/qwen2-5-omni-7b | 33K | $0.10 | $0.40 | |||||
alibaba/qwen2-5-vl-72b-instruct | 131K | $3 | $8 | |||||
alibaba/qwen2-5-vl-7b-instruct | 131K | $0.35 | $1 | |||||
alibaba/qwen3-14b | 131K | $0.35 | $1 | |||||
alibaba/qwen3-235b-a22b | 131K | $0.70 | $3 | |||||
alibaba/qwen3-32b | 131K | $0.70 | $3 | |||||
alibaba/qwen3-8b | 131K | $0.18 | $0.70 | |||||
alibaba/qwen3-asr-flash | 53K | $0.04 | $0.04 | |||||
alibaba/qwen3-coder-30b-a3b-instruct | 262K | $0.45 | $2 | |||||
alibaba/qwen3-coder-480b-a35b-instruct | 262K | $2 | $8 | |||||
alibaba/qwen3-coder-flash | 1.0M | $0.30 | $2 | |||||
alibaba/qwen3-coder-plus | 1.0M | $1 | $5 | |||||
alibaba/qwen3-livetranslate-flash-realtime | 53K | $10 | $10 | |||||
alibaba/qwen3-max | 262K | $1 | $6 | |||||
alibaba/qwen3-next-80b-a3b-instruct | 131K | $0.50 | $2 | |||||
alibaba/qwen3-next-80b-a3b-thinking | 131K | $0.50 | $6 | |||||
alibaba/qwen3-omni-flash | 66K | $0.43 | $2 | |||||
alibaba/qwen3-omni-flash-realtime | 66K | $0.52 | $2 | |||||
alibaba/qwen3-vl-235b-a22b | 131K | $0.70 | $3 | |||||
alibaba/qwen3-vl-30b-a3b | 131K | $0.20 | $0.80 | |||||
alibaba/qwen3-vl-plus | 262K | $0.20 | $2 | |||||
alibaba/qwq-plus | 131K | $0.80 | $2 |
高级配置Direct link to 高级配置
🌐 Advanced Configuration
自定义头Direct link to 自定义头
🌐 Custom Headers
src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-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"
}
}
});
动态模型选择Direct link to 动态模型选择
🌐 Dynamic Model Selection
src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "alibaba/qwq-plus"
: "alibaba/qvq-max";
}
});