DashScope (Alibaba Cloud Bailian / 阿里云百炼) integration — image generation (qwen-image-2.0-pro), text-to-speech (qwen3-tts-flash), and ASR with word-level timesta
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-dashscope-6f35f426af5c ,按照其中的说明把「dashscope」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Requires DASHSCOPE_API_KEY in .env. Get one at https://dashscope.aliyun.com/.
CRITICAL: DashScope's /compatible-mode/v1/ only supports /chat/completions and /embeddings. Image generation, TTS, and ASR all use DashScope-native endpoints — not OpenAI-compatible paths.
All three tools use Authorization: Bearer $DASHSCOPE_API_KEY.
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
qwen-image-2.0-pro (default), qwen-image-max, wan2.7-image, z-image-turbo{model, input: {messages: [{role: "user", content: [{text: "prompt"}]}]}, parameters: {size: "W*H", n, prompt_extend, watermark}}"1024*1024" not "1024x1024"output.choices[0].message.content[0].image (URL, valid ~24h) — must download separatelyPOST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
Same endpoint as image gen, different body.
qwen3-tts-flash (default), qwen3-tts-instruct-flash, qwen-tts-2025-05-22{model, input: {text, voice: "Cherry", language_type: "Auto"}}output.audio.url (WAV, valid ~24h) — must download separatelyPOST https://dashscope.aliyuncs.com/api/v1/services/audio/asr/transcription
Header: X-DashScope-Async: enable
qwen3-asr-flash-filetrans (NOT qwen3-asr-flash — the sync version has no word timestamps){model, input: {file_url: "https://public-url/audio.mp3"}, parameters: {enable_words: true, language_hints: ["zh","en"]}}task_id → poll GET /api/v1/tasks/{task_id} until SUCCEEDED → download output.result.transcription_url → JSON with transcripts[].sentences[].words[]begin_time/end_time are in milliseconds — the tool normalizes to secondsfrom tools.graphics.image_selector import ImageSelector
result = ImageSelector().execute({
"preferred_provider": "dashscope",
"prompt": "一只猫坐在沙发上",
"output_path": "projects/my-video/assets/images/cat.png",
})
from tools.audio.tts_selector import TTSSelector
result = TTSSelector().execute({
"preferred_provider": "dashscope",
"text": "如果 AI 真的会改变未来,普通人到底该怎么参与?",
"voice": "Cherry",
"output_path": "projects/my-video/assets/audio/narration.wav",
})
from tools.analysis.dashscope_asr import DashscopeAsr
result = DashscopeAsr().execute({
"audio_url": "https://example.com/narration.wav",
"output_path": "projects/my-video/assets/audio/transcription.json",
})
# result.data["words"] is a flat list of {text, begin_time_seconds, end_time_seconds}
prompt_extend: true (default) — DashScope rewrites your prompt for better results. Disable if you need literal prompt adherence.result.data["words"] — each word has begin_time_seconds and end_time_seconds. Group words into caption phrases by language semantics, not fixed character count.dashscope_image)prompt (required): text promptmodel: default qwen-image-2.0-prosize: default "1024*1024" — asterisk separator, not "x"n: 1-6 imagesnegative_prompt: things to avoid (max 500 chars)prompt_extend: default true — auto-rewrite prompt for better resultswatermark: default falseseed: for reproducibilitydashscope_tts)text (required): text to synthesize (max 600 chars for qwen3-tts-flash)model: default qwen3-tts-flashvoice: default "Cherry" — other voices: "Ethan", "Chelsie", etc.language_type: default "Auto" — "Chinese", "English", "Japanese", "Korean"instructions: natural language delivery instructions (only for qwen3-tts-instruct-flash)dashscope_asr)audio_url (required): must be publicly accessible URLmodel: qwen3-asr-flash-filetrans (only model that supports word timestamps)language_hints: default ["zh", "en"]enable_words: default true — required for word-level timestampspoll_interval_seconds: default 5.0timeout_seconds: default 300"W*H" with asterisk, not "WxH". Example: "2048*2048".output.audio.url — if empty, the model name or voice may be wrong.audio_url must be publicly reachable. DashScope servers fetch the file; local paths and auth-gated URLs don't work.timeout_seconds (default 300). Long audio files take longer to transcribe.enable_words: true and model is qwen3-asr-flash-filetrans (not the sync qwen3-asr-flash).DASHSCOPE_API_KEY is set. Use Authorization: Bearer $KEY header.Never print or write the API key to logs, metadata, patches, or project artifacts. .env.example should contain only empty variable names. The tool's _safe_error() method redacts the key from error messages.