--- name: bailian-vlm-setup description: 阿里云百炼 VLM (qwen-vl) 配置与故障排查 category: mlops --- # 阿里云百炼 VLM (qwen-vl) 配置 ## 关键发现 **重要**: 阿里云百炼的视觉模型名称是 `qwen-vl-plus`,而不是网上常见文档中提到的 `qwen-vl-latest` 或 `qwen-vl2-7b-instruct`。使用错误的模型名会返回 404 错误。 ## 快速配置 ```python from openai import OpenAI client = OpenAI( api_key=os.getenv("DASHSCOPE_API_KEY"), # 或 ALIBABA_CLOUD_API_KEY base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", ) # VL 视觉理解 completion = client.chat.completions.create( model="qwen-vl-plus", # ✓ 正确 messages=[{"role": "user", "content": [ {"type": "image_url", "image_url": {"url": "https://..."}}, {"type": "text", "text": "这是什么"}, ]}] ) # 纯文本 LLM completion = client.chat.completions.create( model="qwen-plus", # 或 qwen-max, qwen-turbo messages=[{"role": "user", "content": "hello"}] ) ``` ## 可用模型 ### VLM (视觉理解) | 模型 | 说明 | |-----|------| | `qwen-vl-plus` | 推荐,VL 理解 | | `qwen-vl-max` | 更高精度 | ### LLM (文本) | 模型 | 说明 | |-----|------| | `qwen-plus` | 推荐,平衡 | | `qwen-max` | 高质量 | | `qwen-turbo` | 快速响应 | ## 环境变量 ```bash export DASHSCOPE_API_KEY=your-api-key # 或 export ALIBABA_CLOUD_API_KEY=your-api-key ``` API Key 获取: https://bailian.console.aliyun.com/cn-beijing#/APIKey ## 常见错误 | 错误 | 原因 | 解决 | |-----|------|------| | 404 Not Found | 模型名错误 | 使用 `qwen-vl-plus` | | 401 Unauthorized | API Key 未设置 | 设置环境变量 | ## 百炼控制台 - 主页: https://bailian.console.aliyun.com/ - 模型市场: https://bailian.console.aliyun.com/cn-beijing#/model-market - API Key: https://bailian.console.aliyun.com/cn-beijing#/APIKey