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
-
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/setupin the session:export DASHSCOPE_API_KEY=sk-xxxxxxxx export DASHSCOPE_HTTP_BASE_URL=https://{workspace-id}.{region}.maas.aliyuncs.com/api/v1base_url differs by region; for the domain mapping see Base URL overview.
-
Install/Upgrade SDK: SDK Expert is introduced in dashscope Python SDK 1.27.3.
# if it fails, replace pip with pip3 pip install -U dashscope -
Launch CLI: Run
dashscope(without a subcommand) to enter the SDK Expert interactive session; orpython -m dashscope.acli(acli is SDK Expert's CLI entry module). On first launch you'll be prompted to download the SDK Expert knowledge pack (includes api-doc/diagnose and other skills); or install it manually:dashscope # or manually install the SDK Expert knowledge pack python -m dashscope.acli example download dashscope-sdk-expert -
View help: Enter
/helpto see all commands and skills. Commands are session operations (e.g.,/clear/help/exit); skills are domain-capability switches (/skill <name>). When unsure, just ask in natural language and SDK Expert auto-matches a skill. -
Ask on demand: Describe your requirement in natural language, for example:
- "Stream output with qwen-plus and count token usage"
- "What does this error
Throttling.RateQuotamean and how to fix it?" - "Read gen.py and diagnose the root cause of the InvalidParameter error"
You can also use Ctrl+T for voice input,
@file-pathto attach a file for SDK Expert to read, and ↑ for command history.
ImportantSDK Expert cross-checks the local dashscope version and reminds you to pip install -U dashscope if too old.
ImportantFor multimodal or models beyond Tongyi: pip install -U 'dashscope[acli-all]'.
Coverage overview
After installing the SDK Expert knowledge pack, these skills are available (use /skill to see all):
| skill | Use | Example |
|---|---|---|
| api-doc | Query SDK API docs | /skill api-doc Generation |
| sdk-example | Generate example code | /skill sdk-example TextEmbedding |
| error-code | Error-code meaning + fixes | /skill error-code InvalidApiKey |
| diagnose | Read a code file, locate root cause | /skill diagnose ./my_code.py |
| explain-code | Explain code logic | /skill explain-code <code> |
| translate | Multilingual translation | /skill translate en hello world |
| update-sdk | Update the knowledge index | /skill update-sdk <sdk-path> |
SDK Expert covers all DashScope SDK capability domains — text generation, multimodal, speech, retrieval, fine-tuning & deployment, Agent, etc. To query a specific interface's docs/examples use api-doc/sdk-example; to generate code or troubleshoot, just ask in natural language.
NoteSDK Expert is a complete agentic CLI that also supports multi-agent collaboration, MCP (Model Context Protocol, a standard for external tool integration) server, scheduled tasks (/cron), audit (/audit), session compression and history (/compress, /history), etc. Common / commands in a session, grouped by category:
- Session management:
/help/clear/info/stats/setup/exit/feedback - Capability & tools:
/skill/mcp/voice/tts/copy - History & audit:
/history/compress/cron/audit/dev/example
The complete list is subject to the /help output.
Best practice 1: State the requirement only — no doc reading, get runnable code directly
Pain point: SDK interfaces are numerous and versions iterate fast; developers often need to browse docs to confirm parameter names, input formats, and model lists.
Approach: Describe the requirement to SDK Expert; SDK Expert will automatically:
- Match the built-in SDK knowledge base (model list/parameters/input-output structure/error codes)
- Check the local SDK version (remind to upgrade if mismatch)
- Generate runnable code and actually execute it, showing the output
Example dialog:
> Stream a paragraph with qwen-plus and count token usage
SDK Expert:
1. Match the api-doc/sdk-example skill, cross-check the local dashscope version
2. Generate a script and execute it, showing streaming output and token stats (see below)
import os, dashscope
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")
for chunk in dashscope.Generation.call(
model="qwen-plus",
messages=[{"role": "user", "content": "Write a poem about autumn"}],
result_format="message", stream=True, incremental_output=True,
):
if chunk.status_code == 200:
print(chunk.output.choices[0].message.content, end="", flush=True)
# the last chunk contains usage (input/output tokens)
Autumn leaves fall... (streamed char by char)
usage: input=10 output=52
Tips:
- Specify language/framework: e.g., "Wrap as a FastAPI endpoint", "Call with async/await"
- Specify version: "We use dashscope 1.20.x — is this parameter supported?" — SDK Expert checks the installed version before answering
- Ask for details: "Parameter value range?" "What other models are available?"
Best practice 2: Troubleshoot — let it auto-locate and fix bugs
Pain point: When a call errors, the error code meaning is unclear and the stack trace points to SDK internals — hard to tell if it's a code or parameter issue.
Approach (three paths, choose by scenario):
- Paste the error code/message →
/skill error-code <code>(e.g.,/skill error-code Throttling.RateQuota) → SDK Expert outputs the error-code meaning + actionable fix suggestions (adjust concurrency/modify parameters/apply for quota) + optional code snippet. - Give the problematic code file path →
/skill diagnose <file path>(e.g.,/skill diagnose gen.py) → SDK Expert reads the source, checks against common root causes (mixing old prompt format, wrong messages structure, api_key/workspace not configured, async task not polled correctly) and outputs suspected root cause + suggested fix points. - Auto-fix loop →
/skill diagnoselocates the root cause → generates a diff preview for you to confirm → SDK Expert applies the fix after confirmation and reruns the script to verify → forms a "read → diagnose → fix → verify" flow. SDK Expert asks for confirmation before changing files and supports rollback.
Example dialog:
> Running gen.py throws InvalidParameter: url error, help me fix it
SDK Expert:
1. /skill diagnose gen.py → locates that image_url was passed a local path
2. Generates a diff for confirmation (see below)
3. Applies after confirmation, reruns the script, returns 200
- image_url="/tmp/photo.jpg"
+ image_url="https://example.com/photo.jpg"
Tips:
- Attach
request_idwith the error for correlating server-side logs (request_idis in theresponse.request_idfield 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 on GitHub
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.