DashScope SDK Expert

Updated at:

The SDK intelligent assistant built into the DashScope Python SDK — describe your requirement to get version-verified runnable code, or paste an error or file path to auto-diagnose, fix, and verify.

DashScope SDK Expert (hereafter "SDK Expert") is an SDK intelligent assistant CLI built into the dashscope Python SDK (>=1.27.3). This page is the general usage guide: how to use SDK Expert for development and troubleshooting. For complete parameters of each interface, see the corresponding single-interface reference page in the sidebar; capability domains are listed in "Coverage overview" below.

Quick start

  1. Prepare API Key and base_url: Create a key (sk- prefix) in the Model Studio console under "API Key"; keys are region-specific. Configure via environment variable or /setup in the session:

    export DASHSCOPE_API_KEY=sk-xxxxxxxx
    export DASHSCOPE_HTTP_BASE_URL=https://{workspace-id}.{region}.maas.aliyuncs.com/api/v1
    

    base_url differs by region; for the domain mapping see Base URL overview.

  2. Install/upgrade the SDK: SDK Expert was introduced with dashscope Python SDK 1.27.3, and SDK Expert's CLI capabilities are provided by the separate package dashscope-agenticx.

    # 如果运行失败,可以将 pip 替换成 pip3
    pip install -U "dashscope[acli]"
    

    ImportantSDK Expert can also be installed as a standalone package: pip install -U dashscope-agenticx. After installation, you can run the agenticx command directly. For complete usage and updates, see the AgenticX official documentation.

  3. Start the CLI: Run dashscope (without a subcommand) in your terminal to enter the SDK Expert interactive session (on first launch, you will be prompted to download the SDK Expert knowledge pack, which includes specialized skills such as api-doc and diagnose). SDK Expert's CLI capability (the original python -m dashscope.acli entry point) has been split out into the dashscope-agenticx package; to manually install the knowledge pack, use the AgenticX entry point instead:

    # 下载 Expert 模板
    python -m dashscope_agenticx expert download dashscope-sdk-expert
    # 列出可用模板
    python -m dashscope_agenticx expert
    

    If the command-line script is already installed, you can also run it directly:

    agenticx expert download dashscope-sdk-expert
    agenticx expert
    

    Once the download completes, ask questions through the SDK:

    dashscope expert "你的问题"
    # 简易提问示例:一次性命令,直接返回答案后退出
    dashscope expert "如何用 SDK 开发业务"
    

    NoteAsking questions via dashscope expert requires dashscope and dashscope-agenticx to be installed in the same Python environment — use pip install -U "dashscope[acli]" to install both at once; if installed separately, run them in the same virtual environment.

  4. View help: Enter /help in the session to view all commands and skills. Commands are session operations (such as /clear, /help, /exit); skills are domain capability switches (/skill <名称>). If unsure, just ask in natural language and SDK Expert will automatically match a skill.

  5. Ask as needed: Simply describe your needs in natural language, for example:

    • "Stream output with qwen-plus and count token consumption"
    • "What does the error Throttling.RateQuota mean, and how do I fix it?"
    • "Read gen.py and diagnose the root cause of the InvalidParameter error"

    Ctrl+T speech input, @file path to attach files for SDK Expert to read directly, and ↑ to recall command history are also supported.

ImportantSDK Expert checks the local dashscope version and reminds you to run pip install -U dashscope first if it is outdated.

ImportantMulti-modal or non-Qwen models: pip install -U 'dashscope[acli-all]'.

Capability overview

After installing the SDK Expert knowledge pack, the following skills are available (/skill to view all):

  • api-doc — Look up SDK API documentation
  • sdk-example — Generate example code
  • error-code — Error code meanings and fix suggestions
  • diagnose — Read code files and locate root causes
  • explain-code — Explain specific code logic
  • translate — Multilingual translation
  • update-sdk — Update the knowledge base index

Within a session, use /skill to switch skills (run without arguments to view all); common examples:

/skill api-doc Generation
/skill sdk-example TextEmbedding
/skill error-code InvalidApiKey
/skill diagnose ./my_code.py

SDK Expert covers all DashScope SDK capability domains — text generation, multi-modal, speech, retrieval, fine-tuning and deployment, agents, and more. To look up API documentation/examples, use api-doc/sdk-example; to generate code or troubleshoot, simply ask in natural language.

NoteSDK Expert is a full agentic CLI that also supports multi-agent collaboration, MCP (Model Context Protocol, the standard for external tool integration) servers, scheduled tasks (/cron), auditing (/audit), session compression and history (/compress, /history), and more. Common in-session / commands are grouped by category:

  • Session management: /help /clear /info /stats /setup /exit /feedback
  • Capabilities and tools: /skill /mcp /voice /tts /copy
  • History and auditing: /history /compress /cron /audit /dev /example

Refer to the /help output for the complete list.

Best practice 1: State your needs without reading docs and get runnable code directly

Pain point: The SDK has many APIs and frequent version iterations; developers often have to dig through docs to confirm parameter names, input formats, and model lists.

Approach: Describe your requirements to SDK Expert, and SDK Expert will automatically:

  1. Match the built-in SDK knowledge base (model list/parameters/input-output structures/error codes)
  2. Verify the local SDK version (reminds you to upgrade if it is inconsistent)
  3. Generate runnable code, execute it, and show the output

Example dialog:

> 用 qwen-plus 流式输出一段话,并统计 token 消耗

SDK Expert:
1. 匹配 api-doc/sdk-example skill,核对本机 dashscope 版本
2. 生成脚本并执行,展示流式输出与 token 统计(见下)
import os, dashscope
client = dashscope.Client(api_key=os.getenv("DASHSCOPE_API_KEY"))
stream = client.chat.completions.create(
    model="qwen-plus",
    messages=[{"role": "user", "content": "写一首关于秋天的诗"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
# 最后一个 chunk 含 usage(input/output tokens)
秋风扫落叶...(流式逐字输出)
usage: input=10 output=52

Tips:

  • Specify language/framework: e.g. "Wrap it as a FastAPI endpoint", "Call it asynchronously with async/await"
  • Specify version: "We're on dashscope 1.20.x — is this parameter supported?" — SDK Expert checks the installed version before answering
  • Follow up on details: "What's the parameter value range?" "What other models are available?"

Best practice 2: Troubleshoot issues and let it locate and fix bugs automatically

Pain point: When a call fails, the error code meaning is unclear and the stack trace points inside the SDK, making it hard to tell whether it is a code or parameter issue.

Approach (three paths, choose by scenario):

  1. Paste the error code/error message → /skill error-code <错误码> (e.g. /skill error-code Throttling.RateQuota) → SDK Expert outputs the error code meaning + actionable fix suggestions (adjust concurrency/change parameters/apply for quota) + optional code snippets.
  2. Provide the path of the problematic code file → /skill diagnose <文件路径> (e.g. /skill diagnose gen.py) → SDK Expert reads the source code and, against common root causes (mixing old prompt formats, incorrect messages structure, unconfigured api_key/workspace, improperly polled asynchronous tasks), outputs suspected root causes + suggested changes.
  3. Automatic fix loop → /skill diagnose locates the root cause → generates a diff preview for your confirmation → once confirmed, SDK Expert applies the changes and reruns the script to verify → forming a "read → diagnose → fix → verify" workflow. SDK Expert asks for confirmation before modifying files, and changes can be rolled back.

Example dialog:

> 运行 gen.py 报 InvalidParameter: url error,帮我修

SDK Expert:
1. /skill diagnose gen.py → 定位 image_url 传了本地路径
2. 生成 diff 供确认(见下)
3. 确认后应用,重跑脚本,返回 200
- image_url="/tmp/photo.jpg"
+ image_url="https://example.com/photo.jpg"

Tips:

  • Attach request_id with the error for correlating server-side logs (request_id is in the response.request_id field of the response body or in the error object's attributes)
  • For complex issues, first ask SDK Expert to "explain this code logic" (/skill explain-code) to confirm a shared understanding before fixing
  • If the SDK itself has defects or your needs are unmet, file an issue in the GitHub repository; see the official documentation for the full API reference

FAQ

Will SDK Expert modify my source code without asking? No. Before changing files, SDK Expert generates a diff preview for your confirmation; changes are applied only after you confirm and support rollback.

Can it work offline? No. SDK Expert calls model inference (consuming tokens, billed by Model Studio); it requires network access and a valid API Key.

Can the generated code run in production directly? SDK Expert generates version-verified runnable code, but before production you should review quota, concurrency, error handling, and sensitive info yourself.

Can it generate non-Python code? It can generate other languages' code text, but does not verify non-Python SDK versions (different version schemes — review yourself).

Will my code be uploaded? When diagnosing (/skill diagnose) or attaching code, the code content is sent to the model for inference; mind sensitive data.