跳转到主要内容
客户端与工具

Dify

低代码 LLM 应用平台

Dify 是一个通过可视化工作流构建 LLM 应用的低代码平台。将其连接到千问云的按量付费 API,即可创建由 Qwen 模型驱动的聊天助手、智能体和知识库。

快速开始

几分钟即可上手:
# 1. 安装插件
进入 Dify 插件市场 → Models → 搜索 "TONGYI" → 安装

# 2. 配置(Settings → Model Providers → TONGYI → Settings)
API Key: sk-xxx
Use international endpoint: No

# 3. 测试(创建空白应用 → 聊天助手)
选择模型:qwen3.5-plus
输入消息:"写一个 Python hello world 程序"
预期结果:模型返回 Python 代码

配置

基本设置

配置 Dify 连接千问云:
  • 插件:TONGYI(从 Dify 插件市场安装)
  • 使用国际端点:No
  • 认证方式:需要 API key
  • 模型选择:从插件中选择可用模型

详细配置步骤

1

安装 TONGYI 插件

进入 Dify 插件市场ModelsTONGYI → 安装
2

配置 API key

点击头像 → SettingsModel ProvidersTONGYISettings
  • API Key:您的 API key
  • Use international endpoint:No
3

启用模型

点击 TONGYI 卡片上的模型列表 → 开启所需模型
如果 TONGYI 插件中没有最新模型,可使用 OpenAI-API-compatible 插件,端点填写 https://dashscope.aliyuncs.com/compatible-mode/v1
使用千问云提供的 DeepSeek 模型也请使用 TONGYI 插件。

限制

  • 插件维护:TONGYI 插件由 Dify 维护,而非由千问云维护
  • 模型可用性:部分最新模型可能需要通过 OpenAI-compatible 插件接入

使用示例

  • 聊天助手
  • 包含 LLM 节点的工作流
  • 知识库
  • 视觉模型
1

创建应用

工作区 → Create blank appChat assistant
2

配置模型

选择 qwen3.5-plus → 如可用,开启思考模式
3

测试对话

输入:"解释神经网络的工作原理"

常见问题

"Invalid API-key provided" 错误
解决方法:
  • 尝试安装早期版本的 TONGYI 插件
  • 使用默认工作区(非子工作区)的 API key。0.0.41 版本的千问插件会校验 qwen-turbo 模型调用权限,建议使用默认业务空间的 API Key。
  • 确认 "Use international endpoint" 已设为 No
-latest 后缀的模型不可用
解决方法:使用 OpenAI-API-compatible 插件,配置如下:
  • Endpoint:https://dashscope.aliyuncs.com/compatible-mode/v1
  • API key:您的千问云 API key
  • Model:手动输入模型 ID
Token 消耗过高
解决方法:
  • 根据任务选择合适的模型
  • 设置合理的上下文窗口大小
  • 定期清理对话历史
Vision 开关未显示
解决方法:确认已选择支持视觉的模型(qwen3.5-plusqwen3-vl-plus
如何使用 Qwen-Omni / Qwen-Audio / Qwen-OCR 模型?
以上模型均不支持直接在 Dify 上配置,您可通过 Chatflow 或工作流的 HTTP 节点接入,接入细节请参见文档中的 curl 命令。为了降低 HTTP 节点的超时风险,建议您通过流式输出方式调用。
如何使用万相模型?
Dify 没有提供万相模型相关的插件,通过 Dify 的 Chatflow/工作流的 HTTP 节点可达到文生图/视频的功能。步骤:
  1. 下载并导入工作流模板(万相-文生图Demo.yml 或 万相-文生视频Demo.yml),在工作室点击导入 DSL 文件并选择模板。
  2. 进入工作流界面,将 DASHSCOPE_API_KEY 的值修改为您的 API Key。
  3. 点击运行按钮即可生成作品。视频生成时间一般在 5 分钟以上。
  4. (可选)发布为工具,以便在其他大模型应用中使用。
模板默认使用 wanx2.1-t2i-turbo(文生图)/ wanx2.1-t2v-turbo(文生视频)。您可以在 STEP1 节点修改模型。

进阶功能

思考模式

对于支持推理的模型:
  1. 选择支持思考模式的模型
  2. 开启思考模式开关
  3. 设为 "True" 启用逐步推理

代码执行节点

从响应中提取推理过程:
  • 在代码执行节点中使用正则表达式
  • 将思考过程与最终答案分离
  • 按需格式化输出

相关资源

语音识别

录音文件转写

将音视频文件转为文字

千问云提供三个模型系列用于录音文件转写:Fun-ASR 支持高精度多语言转写与歌曲识别,Qwen-ASR 具备增强的语义理解能力,Qwen-Omni 支持基于提示词的上下文感知转写。
有关模型可用性、支持语言和功能对比,请参见语音识别模型

快速开始

  • Fun-ASR
  • Qwen-ASR
  • Qwen-Omni

模型列表

模型版本单价免费额度 (说明)
fun-asr
当前指向 fun-asr-2025-11-07
稳定版0.00022元/秒36,000 秒(10 小时)
有效期 90 天
fun-asr-2025-11-07
相比 fun-asr-2025-08-25 改进了远场 VAD 以提升准确率
快照版0.00022元/秒36,000 秒(10 小时)
有效期 90 天
fun-asr-2025-08-25快照版0.00022元/秒36,000 秒(10 小时)
有效期 90 天
fun-asr-mtl
当前指向 fun-asr-mtl-2025-08-25
稳定版0.00022元/秒36,000 秒(10 小时)
有效期 90 天
fun-asr-mtl-2025-08-25快照版0.00022元/秒36,000 秒(10 小时)
有效期 90 天
  • 支持语言
    • fun-asr 和 fun-asr-2025-11-07:普通话、粤语、吴语、闽南语、客家话、赣语、湘语、晋语、英语、日语、韩语、越南语、泰语、印尼语、马来语、菲律宾语、印地语、阿拉伯语、法语、德语、西班牙语、葡萄牙语、俄语、意大利语、荷兰语、瑞典语、丹麦语、芬兰语、挪威语、希腊语、波兰语、捷克语、匈牙利语、罗马尼亚语、保加利亚语、克罗地亚语、斯洛伐克语。同时支持中原、西南、冀鲁、江淮、兰银、胶辽、东北、北京、港台等地区的普通话口音。
    • fun-asr-2025-08-25:普通话和英语。
    • fun-asr-mtl 和 fun-asr-mtl-2025-08-25:普通话、粤语、英语、日语、韩语、越南语、泰语、印尼语、马来语、菲律宾语、印地语、阿拉伯语、法语、德语、西班牙语、葡萄牙语、俄语、意大利语、荷兰语、瑞典语、丹麦语、芬兰语、挪威语、希腊语、波兰语、捷克语、匈牙利语、罗马尼亚语、保加利亚语、克罗地亚语和斯洛伐克语。
  • 支持采样率:任意
  • 支持音频格式:aac、amr、avi、flac、flv、m4a、mkv、mov、mp3、mp4、mpeg、ogg、opus、wav、webm、wma、wmv

发起首次调用

获取 API Key将其设置为环境变量。如需使用 SDK,请先安装 SDK由于音视频文件通常较大,文件传输和语音识别可能需要较长时间。录音文件识别 API 采用异步调用方式提交任务。识别完成后,需要通过查询接口获取识别结果。

异步提交并同步等待

提交任务后阻塞等待,直到任务完成。
from http import HTTPStatus
from dashscope.audio.asr import Transcription
from urllib import request
import dashscope
import os
import json

dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

# 如果您没有配置环境变量,请用 API Key 替换下行代码:dashscope.api_key = "sk-xxx"
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")

task_response = Transcription.async_call(
  model='fun-asr',
  file_urls=['https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav',
      'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav'],
  language_hints=['zh', 'en']  # language_hints 为可选参数,用于指定音频的语言代码。取值范围请参见 API 参考文档。
)

transcription_response = Transcription.wait(task=task_response.output.task_id)

if transcription_response.status_code == HTTPStatus.OK:
  for transcription in transcription_response.output['results']:
    if transcription['subtask_status'] == 'SUCCEEDED':
      url = transcription['transcription_url']
      result = json.loads(request.urlopen(url).read().decode('utf8'))
      print(json.dumps(result, indent=4,
      ensure_ascii=False))
    else:
      print('转写失败!')
      print(transcription)
else:
  print('错误:', transcription_response.output.message)
第一条结果
{
  "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav",
  "properties": {
    "audio_format": "pcm_s16le",
    "channels": [
      0
    ],
    "original_sampling_rate": 24000,
    "original_duration_in_milliseconds": 3280
  },
  "transcripts": [
    {
      "channel_id": 0,
      "content_duration_in_milliseconds": 3000,
      "text": "Hello world, this is Alibaba Speech Lab. ",
      "sentences": [
        {
          "begin_time": 240,
          "end_time": 3240,
          "text": "Hello world, this is Alibaba Speech Lab. ",
          "sentence_id": 1,
          "words": [
            {
              "begin_time": 240,
              "end_time": 640,
              "text": "Hello",
              "punctuation": ""
            },
            {
              "begin_time": 640,
              "end_time": 960,
              "text": " world",
              "punctuation": ","
            },
            {
              "begin_time": 1280,
              "end_time": 1480,
              "text": " this",
              "punctuation": ""
            },
            {
              "begin_time": 1480,
              "end_time": 1840,
              "text": " is",
              "punctuation": ""
            },
            {
              "begin_time": 1840,
              "end_time": 2520,
              "text": " Alibaba",
              "punctuation": ""
            },
            {
              "begin_time": 2520,
              "end_time": 2920,
              "text": " Speech",
              "punctuation": ""
            },
            {
              "begin_time": 2920,
              "end_time": 3240,
              "text": " Lab",
              "punctuation": ". "
            }
          ]
        }
      ]
    }
  ]
}
第二条结果
{
  "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav",
  "properties": {
    "audio_format": "pcm_s16le",
    "channels": [
      0
    ],
    "original_sampling_rate": 24000,
    "original_duration_in_milliseconds": 4000
  },
  "transcripts": [
    {
      "channel_id": 0,
      "content_duration_in_milliseconds": 3160,
      "text": "Hello world, this is Alibaba Speech Lab. ",
      "sentences": [
        {
          "begin_time": 800,
          "end_time": 3960,
          "text": "Hello world, this is Alibaba Speech Lab. ",
          "sentence_id": 1,
          "words": [
            {
              "begin_time": 800,
              "end_time": 1200,
              "text": "Hello",
              "punctuation": ""
            },
            {
              "begin_time": 1200,
              "end_time": 1640,
              "text": " world",
              "punctuation": ","
            },
            {
              "begin_time": 1880,
              "end_time": 2120,
              "text": " this",
              "punctuation": ""
            },
            {
              "begin_time": 2120,
              "end_time": 2560,
              "text": " is",
              "punctuation": ""
            },
            {
              "begin_time": 2560,
              "end_time": 3360,
              "text": " Alibaba",
              "punctuation": ""
            },
            {
              "begin_time": 3360,
              "end_time": 3720,
              "text": " Speech",
              "punctuation": ""
            },
            {
              "begin_time": 3720,
              "end_time": 3960,
              "text": " Lab",
              "punctuation": ". "
            }
          ]
        }
      ]
    }
  ]
}

异步提交并轮询查询

提交任务后通过轮询获取结果,而非阻塞等待。
from http import HTTPStatus
from dashscope.audio.asr import Transcription
import dashscope
import os
import json

dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

# 如果您没有配置环境变量,请用 API Key 替换下行代码:dashscope.api_key = "sk-xxx"
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")

transcribe_response = Transcription.async_call(
  model='fun-asr',
  file_urls=['https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav',
      'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav']
)

while True:
  if transcribe_response.output.task_status == 'SUCCEEDED' or transcribe_response.output.task_status == 'FAILED':
    break
  transcribe_response = Transcription.fetch(task=transcribe_response.output.task_id)

if transcribe_response.status_code == HTTPStatus.OK:
  print(json.dumps(transcribe_response.output, indent=4, ensure_ascii=False))
  print('转写完成!')

RESTful API

使用任意 HTTP 库提交任务并轮询获取结果。以下 Python 示例演示了完整流程:
import requests
import json
import os
import time

# 如果您没有配置环境变量,请用 API Key 替换下行代码:api_key = "sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
file_urls = [
  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav",
  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav",
]

region = "dashscope.aliyuncs.com"

# 提交录音文件转写任务,包含待转写的文件 URL 列表
def submit_task(apikey, file_urls) -> str:

  headers = {
    "Authorization": f"Bearer {
  • 运行与扩展
    模型生产