Coding

Qwen Api

Try it

通义千问 API 开发助手,精通 Qwen 模型调用、DashScope SDK、多模态、Agent 开发

What it does

简介 通义千问(Qwen)是阿里云的大语言模型系列,通过百炼平台(DashScope)提供 API。 核心优势:兼容 OpenAI SDK 调用,迁移成本极低;国际版无内容审核。

The skill document

通义千问 API - 阿里云百炼/DashScope 接入指南

简介

通义千问(Qwen)是阿里云的大语言模型系列,通过百炼平台(DashScope)提供 API。 核心优势:兼容 OpenAI SDK 调用,迁移成本极低;国际版无内容审核。

模型矩阵

模型特点适用场景
qwen-max最强能力,深度推理复杂分析、创意写作
qwen-plus性价比最优(推荐)日常对话、代码生成
qwen-turbo响应最快简单任务、高并发
qwen-long长文本(1000 万 token)超长文档分析
qwq-plus推理增强(思维链)数学、逻辑推理
qwen-vl-max视觉理解图片/视频分析
qwen-audio-turbo音频理解语音转录、音频分析

API 端点

地域Base URL说明
新加坡(国际版)https://dashscope-intl.aliyuncs.com/compatible-mode/v1推荐,无内容审核
中国(北京)https://dashscope.aliyuncs.com/compatible-mode/v1国内访问快
美国(弗吉尼亚)https://dashscope-us.aliyuncs.com/compatible-mode/v1美国节点

基础调用(兼容 OpenAI SDK)

pip install -U openai
from openai import OpenAI
client = OpenAI(
    api_key="sk-your-dashscope-api-key",
    base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
)
response = client.chat.completions.create(
    model="qwen-plus",
    messages=[
        {"role": "system", "content": "你是一个专业的编程助手。"},
        {"role": "user", "content": "用 Python 实现一个 LRU 缓存"}
    ]
)
print(response.choices[0].message.content)

多模态调用

# 图片理解
response = client.chat.completions.create(model="qwen-vl-max", messages=[{"role": "user",
    "content": [{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}},
                {"type": "text", "text": "描述图片内容"}]}])
# 视频理解
response = client.chat.completions.create(model="qwen-vl-max", messages=[{"role": "user",
    "content": [{"type": "video_url", "video_url": {"url": "https://example.com/video.mp4"}},
                {"type": "text", "text": "总结视频内容"}]}])

函数调用

tools = [{"type": "function", "function": {"name": "get_weather", "description": "获取城市天气",
    "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}]
response = client.chat.completions.create(
    model="qwen-plus", messages=[{"role": "user", "content": "北京天气?"}], tools=tools)

绕过内容审核(国际版)

import json
response = client.chat.completions.create(model="qwen-plus",
    messages=[{"role": "user", "content": "你的问题"}],
    extra_headers={"X-DashScope-DataInspection": json.dumps({"input": "disable", "output": "disable"})})

仅在国际版端点生效,国内版无法禁用审核。

长文本处理(qwen-long,支持 1000 万 token)

file = client.files.create(file=open("long_doc.pdf", "rb"), purpose="file-extract")
response = client.chat.completions.create(model="qwen-long", messages=[
    {"role": "system", "content": f"fileid://{file.id}"},
    {"role": "user", "content": "总结文档核心观点"}])

定价(每百万 token)

模型输入输出
qwen-plus¥0.8¥2.0
qwen-max¥2.0¥6.0
qwen-turbo¥0.3¥0.6

最佳实践

  • 日常推荐 qwen-plus,兼顾能力和成本
  • 国际版 + 禁用审核 = 无内容限制
  • 超长文档用 qwen-long + 文件上传

Related skills

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

More from zhangifonly

Browse all skills

Get end-to-end guidance for QQ open platform development — official Bot API, channels, Mini Programs, and OAuth2.0.

by zhangifonly67 installs

Zero-dependency Python CLI for WeChat Official Account APIs with a real production-incident pitfall guide.

by zhangifonly102 installs1 stars

AI 小红薯 — 只允许智能体发言的图文社区。发帖、评论、点赞、加入圈子。

by zhangifonly39 installs2 stars

滴滴出行决策助手。Use for: (1) 按预算/时段/人数在快车/特惠/拼车/专车间选型并估算费用区间, (2) 早晚高峰/恶劣天气/节假日的叫车策略, (3) 企业版 API 对接与用车规则配置。DiDi ride-hailing decision guide: product selection and...

by zhangifonly25 installs

伙伴云零代码平台指南。Use for: (1) 零代码数据表格应用搭建(表格/看板/仪表盘)方法, (2) 与简道云/明道云/飞书多维表格的选型对比, (3) 从 Excel 迁移到在线协作数据库的路径设计。Huoban zero-code platform guide: app building, compet...

by zhangifonly25 installs

明道云 APaaS 平台指南。Use for: (1) 零代码应用搭建与 APaaS 能力边界(工作表/工作流/API集成), (2) 私有化部署选型——明道云是国内私有化最成熟的零代码方案之一, (3) 与 SaaS 型竞品的对比决策。Mingdao APaaS guide: app building, pri...

by zhangifonly25 installs