DashScope Python SDK
English | 中文
The DashScope Python SDK is the official client for Alibaba Cloud Model Studio (Bailian), covering text generation, multi-modal understanding, embeddings, reranking, image/video generation, speech synthesis & recognition, fine-tuning, agentic RL, applications and more.
Version 2.0 introduces a resource-style client — dashscope.Client() — modeled on the ergonomics of the OpenAI SDK: one client holds a shared connection pool, every capability hangs off it as a typed resource (client.chat, client.images, client.audio, …), responses are typed objects instead of raw dicts, and failures raise exceptions by default. The complete 1.x public surface remains available at its historical import paths and is implemented by facades under dashscope.legacy_1x; AgentStudio and Agentic RL share their large business cores with 2.0 without sharing public return or error contracts.
What's new in 2.0
| 1.x | 2.0 | |
|---|---|---|
| Entry point | Module-level static classes: Generation.call(...) |
A resource-style client: client.chat.completions.create(...) |
| One-liner | — | dashscope.chat("qwen-plus", "Tell me a joke") |
| Response | Raw dict-like; check status_code == HTTPStatus.OK |
Typed object; read resp.output_text, resp.usage.total_tokens |
| Errors | Inspect resp.code / resp.message by hand |
Typed DashScopeError exceptions raised by default (evolving) |
| Streaming | Generator of raw frames | ChatStream with .text_stream, .reasoning_stream, .get_final_message() |
| Protocols | DashScope native + a separate compatible-mode entry | One client speaks native, openai, or anthropic via protocol= |
| Async | Separate Aio* classes |
dashscope.AsyncClient() mirrors the sync surface (except the duplex audio WebSocket sessions) |
| Connections | A fresh session per call | One keep-alive pool per client, shared across resources |
| Config | Module globals (dashscope.api_key, set_region) |
Layered: args → dashscope.settings → env → ~/.dashscope/config.toml |
Installation
pip install -U dashscope
The base install covers SDK API calls, the dashscope CLI command, Agentic RL fine-tuning and the local tokenizer. Python 3.9+ is required. Optional feature groups all belong to the bundled AI assistant:
| Extra | Provides | Install |
|---|---|---|
acli |
Interactive AI assistant (DashScope SDK Expert) | pip install "dashscope[acli]" |
acli-openai |
Run the assistant on an OpenAI-compatible model provider | pip install "dashscope[acli-openai]" |
acli-anthropic |
Run the assistant on an Anthropic model provider | pip install "dashscope[acli-anthropic]" |
acli-voice |
Voice input and spoken replies in the assistant | pip install "dashscope[acli-voice]" |
acli-camera |
Camera capture for image input in the assistant | pip install "dashscope[acli-camera]" |
acli-all |
All of the above (includes acli) |
pip install "dashscope[acli-all]" |
To install from a source checkout:
pip install -e .
Quick start
Set your API key (how to get one):
export DASHSCOPE_API_KEY="sk-xxx"
One line — the fastest way to a completion:
import dashscope
completion = dashscope.chat("qwen-plus", "Tell me a joke")
print(completion.output_text)
Client — the recommended form for anything real. One client, reused across calls:
import dashscope
client = dashscope.Client() # reads DASHSCOPE_API_KEY
resp = client.chat.completions.create(
model="qwen-plus",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
)
print(resp.output_text)
print(resp.usage.total_tokens, "tokens |", resp.request_id)
Streaming — stream=True returns a ChatStream:
stream = client.chat.completions.create(
model="qwen-plus",
messages=[{"role": "user", "content": "Write a haiku about the sea"}],
stream=True,
)
for text in stream.text_stream:
print(text, end="", flush=True)
# Or collapse the whole stream into one merged ChatCompletion (with usage):
# final = stream.get_final_message()
Async — AsyncClient mirrors the sync surface:
import asyncio
import dashscope
async def main():
client = dashscope.AsyncClient()
resp = await client.chat.completions.create(
model="qwen-plus",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.output_text)
await client.aclose()
asyncio.run(main())
Core concepts
The client
dashscope.Client() (and dashscope.AsyncClient()) is the single entry point. It owns one keep-alive connection pool shared by every resource call, and exposes capabilities as attributes:
client = dashscope.Client(
api_key="sk-xxx", # default: DASHSCOPE_API_KEY
workspace="ws-xxx123", # default: DASHSCOPE_WORKSPACE
region="cn-beijing", # default: DASHSCOPE_REGION
protocol="native", # native | openai | anthropic
timeout=300.0,
max_retries=2,
base_url=None, # override the endpoint entirely; default: DASHSCOPE_BASE_URL
config_path=None, # alternate config.toml; default: DASHSCOPE_CONFIG
protocol_options=None, # extra kwargs forwarded to the selected protocol adapter
raise_on_error=True, # False: return error responses instead of raising
http_client=None, # your own httpx.Client (AsyncClient for AsyncClient)
)
All options are keyword-only.
Use it as a context manager to close the pool automatically, or derive a variant with with_options() (unmentioned options are inherited; the connection pool is shared when connection-level options are unchanged):
with dashscope.Client() as client:
client.chat.completions.create(model="qwen-plus", messages=["hi"])
low_latency = client.with_options(timeout=10.0, max_retries=0)
Any call also accepts per-request api_key=, workspace=, and timeout= overrides.
Need proxies, custom connection limits or event hooks? Pass your own http_client=httpx.Client(...) (httpx.AsyncClient for AsyncClient). The SDK still applies authentication, retries and absolute endpoint URLs on top of it, and never closes a client it does not own.
Protocols
One client can speak three wire protocols, selected with protocol= (or DASHSCOPE_PROTOCOL / settings.protocol). The request/response objects stay the same canonical, typed shape regardless of protocol — only the wire format changes:
protocol |
Talks to | Use when |
|---|---|---|
native (default) |
DashScope native API (/api/v1) |
You want the full DashScope feature set |
openai |
OpenAI-compatible mode (/compatible-mode/v1) |
You're porting OpenAI code — no openai package needed |
anthropic |
Anthropic-compatible mode (/apps/anthropic) |
You're porting Anthropic Messages code |
client = dashscope.Client(protocol="openai")
resp = client.chat.completions.create(
model="qwen-plus",
messages=[{"role": "user", "content": "Hello"}],
)
Typed responses
Every response is a typed object. For chat, read output_text for the first choice, or dig into choices, usage, search_info, request_id, and model:
resp = client.chat.completions.create(model="qwen-plus", messages=["hi"])
resp.output_text # choices[0].message.content
resp.choices[0].message.content # same, explicit
resp.choices[0].message.reasoning_content # thinking-model reasoning, if any
resp.choices[0].message.tool_calls # tool calls, if any
resp.usage.input_tokens # also .output_tokens / .total_tokens
resp.request_id
All responses share a common envelope: request_id, status_code, code, message, is_error, and raw headers.
Streaming
stream=True returns a ChatStream (AsyncChatStream for AsyncClient) with typed helpers:
stream = client.chat.completions.create(model="qwen-plus", messages=["hi"], stream=True)
for text in stream.text_stream: # content deltas
...
# stream.reasoning_stream # reasoning deltas (thinking models)
# stream.tool_call_stream # tool-call deltas
# stream.get_final_message() # merged ChatCompletion, incl. usage
By default each frame is incremental. Pass incremental_output=False to receive cumulative snapshots instead (the SDK merges deltas for you).
Thinking models surface reasoning on .reasoning_stream and, in the merged message, as message.reasoning_content. Under protocol="anthropic" the SDK also keeps message.reasoning_signature plus the raw thinking / redacted_thinking blocks in message.reasoning_blocks, so echoing the assistant message back on the next turn preserves extended thinking.
Note: streaming retries stop at the handshake. The SDK retries connection failures and retryable HTTP statuses only before the first event reaches you; once a stream is open it is never replayed, so a mid-stream drop surfaces as an exception. Wrap stream consumption in your own retry/backoff for production — see
examples/04_real_world_scenarios/production_ready_rag_harness.py.
Errors
Still evolving. The 2.0 typed error surface is under active development — new exception classes may be added and the API-error-code → exception mapping may be refined. Catch the base
errors.DashScopeErrorif you need to stay forward-compatible.
Failures raise a typed DashScopeError by default (both non-2xx HTTP statuses and HTTP-200-with-a-business-error land here):
from dashscope import errors
try:
client.chat.completions.create(model="qwen-plus", messages=["hi"])
except errors.RateLimitError as exc:
print("throttled:", exc.code, exc.status_code, exc.request_id)
except errors.ContentFilterError as exc:
print("blocked by moderation:", exc.message)
except errors.DashScopeError as exc: # base class for all SDK errors
print("request failed:", exc.code, exc.message)
Everything derives from DashScopeError, in two families:
- Server errors — under
APIStatusError:BadRequestError,AuthenticationError,PermissionDeniedError,NotFoundError,RequestTooLargeError,RateLimitError,InternalServerError,ServiceUnavailableError,GatewayTimeoutError, andContentFilterError(aBadRequestErrorsubclass). - Client-side errors — under
SdkError:APIConnectionError/APITimeoutErrorfor network failures, plus the WebSocket familyWsEventError,WsStateError,WsQueueCapacityExceededErrorandWsBinaryOwnerConflictError. Each carries a stablesdk.*code.
A 200 response whose body does not parse into the expected envelope is reported as InternalServerError rather than leaking a decoder exception.
Prefer to inspect errors inline instead of catching? Build the client with raise_on_error=False — failures come back as a normal response object with is_error=True, code, message, and status_code:
client = dashscope.Client(raise_on_error=False)
resp = client.chat.completions.create(model="qwen-plus", messages=["hi"])
if resp.is_error:
print(resp.code, resp.message)
Authentication
The SDK authenticates with an API key. Get one from the Model Studio console. Provide it in any of these ways (highest priority first):
- Per client —
dashscope.Client(api_key="sk-xxx") - Global settings —
dashscope.settings.api_key = "sk-xxx"(applies to clients created afterwards) - Environment variable —
export DASHSCOPE_API_KEY="sk-xxx" - Config file —
api_keyin~/.dashscope/config.toml - 1.x key file — the file written by
dashscope.save_api_key(...)(~/.dashscope/api_key, orDASHSCOPE_API_KEY_FILE_PATH), honored as the lowest tier so existing 1.x setups keep working
Any call also accepts a per-request api_key= override.
API keys are region-specific. Each region issues its own keys; a key from another region fails with
401. Switchapi_keytogether withregion.
Configuration
Configuration resolves in layers — explicit arguments → dashscope.settings → environment variables → ~/.dashscope/config.toml. Set it once at startup, per client, or not at all.
Global settings facade:
import dashscope
dashscope.settings.api_key = "sk-xxx"
dashscope.settings.workspace = "ws-xxx123"
dashscope.settings.region = "ap-southeast-1"
dashscope.settings.protocol = "openai"
dashscope.settings.timeout = 60.0
dashscope.settings.max_retries = 3
dashscope.settings.log_level = "INFO"
Environment variables:
| Variable | Sets | Default |
|---|---|---|
DASHSCOPE_API_KEY |
API key | — |
DASHSCOPE_WORKSPACE |
Workspace ID (endpoint subdomain) | — |
DASHSCOPE_REGION |
Region | cn-beijing |
DASHSCOPE_PROTOCOL |
native / openai / anthropic |
native |
DASHSCOPE_BASE_URL |
Override the HTTP endpoint entirely (escape hatch) | — |
DASHSCOPE_HTTP_BASE_URL |
1.x name for the same override, honored as a fallback | — |
DASHSCOPE_WEBSOCKET_BASE_URL |
Override the WebSocket endpoint | derived from region/workspace |
DASHSCOPE_TIMEOUT |
Request timeout (seconds) | 300 |
DASHSCOPE_MAX_RETRIES |
Automatic retries | 2 |
DASHSCOPE_HTTP_MAX_CONNECTIONS |
Connection-pool size | 100 |
DASHSCOPE_HTTP_MAX_KEEPALIVE_CONNECTIONS |
Keep-alive connections held in the pool | 20 |
DASHSCOPE_HTTP_KEEPALIVE_EXPIRY |
Keep-alive expiry (seconds) | 5.0 |
DASHSCOPE_LOG |
Log level | WARNING |
DASHSCOPE_CONFIG |
Path to config.toml |
~/.dashscope/config.toml |
DASHSCOPE_API_KEY_FILE_PATH |
Path to the 1.x key file (lowest-priority auth tier) | ~/.dashscope/api_key |
The three DASHSCOPE_HTTP_* pool variables are also settable as http_max_connections, http_max_keepalive_connections and http_keepalive_expiry in settings and config.toml. Passing your own http_client= takes precedence over all of them.
Config file (~/.dashscope/config.toml):
api_key = "sk-xxx"
workspace = "ws-xxx123"
region = "ap-southeast-1"
protocol = "native"
timeout = 300.0
max_retries = 2
Regions and endpoints
By default requests go to the China (Beijing) gateway. When a workspace is set, endpoints are built from the workspace-scoped MaaS gateway https://{workspace}.{region}.maas.aliyuncs.com, with each protocol served under its own path. Point at another region with region= (or DASHSCOPE_REGION / settings.region):
client = dashscope.Client(region="ap-southeast-1", workspace="ws-xxx123")
# -> https://ws-xxx123.ap-southeast-1.maas.aliyuncs.com/api/v1
| Region | Location |
|---|---|
cn-beijing |
China (Beijing) — default |
cn-hongkong |
China (Hong Kong) |
ap-southeast-1 |
Singapore |
ap-northeast-1 |
Japan (Tokyo) |
eu-central-1 |
Germany (Frankfurt) |
us-east-1 |
US (Virginia) |
Notes:
- No workspace configured? The SDK falls back to the legacy shared gateway (
https://dashscope.aliyuncs.comfor Beijing) and emits aUserWarning. It works, but the workspace-scoped gateway is recommended for performance and stability. - WebSocket-based realtime APIs (realtime speech, multimodal dialog) are served in
cn-beijingandap-southeast-1. - Batch inference, fine-tuning and application development are currently available in
cn-beijingandap-southeast-1. base_url=(orDASHSCOPE_BASE_URL) overrides everything — the escape hatch for custom/private gateways; it does not require a workspace.- The 1.x
dashscope.set_region(region, workspace_id)global still works for the 1.x module-level API.
Capabilities
Every capability is a resource on the client. Sync and async clients expose the same surface (async methods are awaited) — with one exception: the duplex WebSocket audio sessions are sync-only by design, as noted below.
| Capability | 2.0 resource | Example |
|---|---|---|
| Text chat / generation | client.chat.completions.create(...) |
text_generation/chat.py |
| Multi-modal chat (vision, video) | client.multimodal.chat.create(...) |
multimodal_vision/multimodal_chat.py |
| Text embedding | client.embeddings.create(...) (+ .jobs for batch) |
embeddings/embeddings.py |
| Multi-modal embedding | client.multimodal.embeddings.create(...) |
embeddings/ |
| Rerank | client.rerank.create(...) |
rerank/rerank.py |
| Decision (System One) | client.decision.create(...) |
decision/decision.py |
| Token counting | client.tokenization.count(...) |
text_generation/tokenization.py |
| Image generation | client.images.generate(...) (+ .jobs) |
image_video_synthesis/images.py |
| Video generation | client.videos.generate(...) (+ .jobs) |
image_video_synthesis/videos.py |
| Speech recognition (ASR) | Batch client.audio.asr.transcribe(...) / .jobs; realtime client.audio.asr.recognize(...) |
audio/asr_file.py · audio/asr_websocket.py |
| Speech synthesis (TTS) | HTTP client.audio.tts.http.synthesize(...) / .stream(...); WebSocket client.audio.tts.connect(...) |
audio/tts_http.py · audio/tts_websocket.py |
| Realtime omni dialog | client.audio.realtime.connect(...) |
audio/realtime_omni.py |
| Voice & vocabulary management | client.audio.voices · .voice_design · .vocabularies · .phrases |
audio/voice_clone.py |
| Meeting & audio understanding (TingWu) | client.tingwu.call(...) / .realtime(...) |
audio/tingwu.py |
| Files | client.files.upload/list/get/delete(...) |
files/files.py |
| Models | client.models.list/get(...) |
models/models.py |
| Fine-tuning | client.fine_tunes.create/get/list/wait/cancel/delete(...) |
fine_tuning/fine_tunes.py |
| Model deployments | client.deployments.create/scale/list/delete(...) |
fine_tuning/ |
| Agentic RL | client.rl (.jobs, register_functions, upload_data) |
fine_tuning/reinforcement_learning.py |
| Model Studio applications | client.apps.completions.create(...) |
applications/apps.py |
| AgentStudio (agents, sessions, memory) | client.agentstudio |
03_agent_recipes/agentstudio.py |
A few common shapes:
# Embeddings
resp = client.embeddings.create(model="text-embedding-v4", input=["hello", "world"], dimension=1024)
resp.embeddings[0].embedding
# Multi-modal chat (image understanding)
resp = client.multimodal.chat.create(
model="qwen3-vl-plus",
messages=[{"role": "user", "content": [{"image": "https://.../cat.png"}, {"text": "What is this?"}]}],
)
resp.output_text
# Image generation (submit + wait); use client.images.jobs for manual control
job = client.images.generate(model="wanx2.1-t2i-turbo", prompt="a cozy flower shop", size="1024*1024")
if job.succeeded:
print(job.image_urls)
# HTTP speech synthesis: one POST, audio comes back as a temporary URL
synth = client.audio.tts.http.synthesize(
"Hello there", model="cosyvoice-v3-flash", voice="longanhuan", format="pcm",
)
print(synth.audio_url)
# Streaming synthesis yields audio chunks as they are rendered
for chunk in client.audio.tts.http.stream(
"Hello there", model="cosyvoice-v3-flash", voice="longanhuan", format="pcm",
):
if chunk.audio:
... # chunk.is_final marks the closing part
# A Model Studio application
resp = client.apps.completions.create(app_id="YOUR_APP_ID", prompt="How do I make stew?")
resp.text
Async audio
AsyncClient covers the HTTP-shaped audio resources — await client.audio.asr.transcribe(...) for batch transcription, client.audio.tts.http.synthesize/.stream for synthesis, and the management resources (voices, voice_design, vocabularies, phrases). The duplex WebSocket sessions (asr.recognize, tts.connect, realtime.connect) are sync-only by design; run them in a thread if you need them inside an async app.
Realtime over one WebSocket
For latency-sensitive realtime audio, open a shared duplex socket and run multiple sessions on it instead of handshaking per task:
connection = client.ws_connection()
session = client.audio.asr.recognize(model="fun-asr-realtime", connection=connection)
# ... drive the session; the caller owns the connection ...
connection.close()
Each task on the connection reads through a bounded queue (task_queue_size=, default 1024), so a slow consumer fails its own task with errors.WsQueueCapacityExceededError instead of holding audio in memory indefinitely or tearing down the shared socket.
Supported models
| Category | Example models | 2.0 resource |
|---|---|---|
| Text generation | qwen-max, qwen-plus, qwen-turbo | client.chat |
| Multi-modal understanding | qwen3-vl-plus, qwen-omni | client.multimodal.chat |
| Text embedding | text-embedding-v4, text-embedding-v3 | client.embeddings |
| Multi-modal embedding | tongyi-embedding-vision-plus | client.multimodal.embeddings |
| Rerank | gte-rerank-v2, qwen3-rerank | client.rerank |
| Image generation | wanx2.1-t2i-turbo, wan2.6-image | client.images |
| Video generation | wanx2.1-t2v, wan2.7-i2v | client.videos |
| Speech synthesis (TTS) | cosyvoice-v3-flash, cosyvoice-v1, qwen-tts | client.audio.tts |
| Speech recognition (ASR) | fun-asr-realtime, paraformer-v1 | client.audio.asr |
| Omni (realtime) | qwen-omni-turbo-realtime | client.audio.realtime |
For the latest model list, visit the Model Studio model plaza.
AI Assistant: DashScope SDK Expert
The SDK ships with an interactive AI assistant, DashScope SDK Expert, built on the bundled Agentic CLI (dashscope/acli). It answers SDK/API questions, generates runnable examples, shows CLI usage, and diagnoses errors right in your terminal.
- Run
dashscopewith no arguments to start the assistant. On first run it offers to install the knowledge pack (per-domain quick-reference skills: text, multimodal, speech, retrieval, fine-tuning, agent, cli), so guidance comes from the SDK's public interfaces — parameters, outputs, error codes — without reading the source. - Ask it instead of reading docs — e.g.
dashscope expert "how do I stream chat output"(asks once and exits). Type/helpinside the assistant for available commands;dashscope expert --helpshows all forms. - Install with the
acliextra:pip install "dashscope[acli]". Addacli-voice/acli-camerafor voice and camera input, oracli-allfor everything — see the extras table. - Full walkthrough: DashScope SDK Expert guide.
Shell completion
Run the command for your shell once, then restart the shell (or re-source your config):
| Shell | Install command |
|---|---|
| bash | dashscope --install-completion bash |
| zsh | dashscope --install-completion zsh |
| fish | dashscope --install-completion fish |
Preview the script without installing:
dashscope --show-completion bash
Logging
Set the level via settings or the environment:
dashscope.settings.log_level = "INFO"
export DASHSCOPE_LOG="INFO"
Examples
The examples/ directory is a production best-practices collection built on the 2.0 client, organized as an advancement path:
examples/
├── 01_atomic_capabilities/ Minimal runnable quickref per capability
├── 02_advanced_engineering/ Mock debugging, semantic cache, circuit breaker + multi-region DR
├── 03_agent_recipes/ Tool-call loop, RAG, MCP server, AgentStudio
├── 04_real_world_scenarios/ End-to-end production harnesses (RAG, realtime meetings, customer service)
└── legacy_1x/ 1.x module-level API examples, for reference
See examples/README.md. Several flagship cases run fully offline (mock transports) with no API key.
Migrating from 1.x
The 1.x module-level API is unchanged and still supported — you can adopt 2.0 incrementally. When you're ready, the mapping is direct:
| 1.x | 2.0 |
|---|---|
Generation.call(model=..., messages=..., result_format="message") |
client.chat.completions.create(model=..., messages=...) |
resp.status_code == HTTPStatus.OK then resp.output.choices[0].message.content |
resp.output_text (errors raise by default) |
MultiModalConversation.call(...) |
client.multimodal.chat.create(...) |
TextEmbedding.call(...) |
client.embeddings.create(...) |
TextReRank.call(...) |
client.rerank.create(...) |
ImageSynthesis.call(...) / .async_call(...) |
client.images.generate(...) / client.images.jobs |
dashscope.api_key = "sk-xxx" |
dashscope.Client(api_key=...) or dashscope.settings.api_key = ... |
dashscope.set_region(region, workspace_id) |
dashscope.Client(region=..., workspace=...) |
OpenAI-compatible via dashscope.aigc.chat_completion.Completions |
dashscope.Client(protocol="openai") |
Package layout and compatibility
The 2.0 implementation sits directly under dashscope; the former dashscope.v2 namespace is gone. AgentStudio and FineTune/Agentic RL each have a single business core under dashscope.applications, with two thin public facades on top:
- the historical
dashscope.agentstudioanddashscope.finetune.agentic_rlimports keep the 1.x clients, methods, return models and exception classes; client.agentstudioandclient.rlexpose the 2.0 resource APIs, the httpx transport and thedashscope.errorsfamily.
Historical deep modules such as dashscope.aigc, dashscope.client.base_api, dashscope.files and dashscope.tokenizers remain importable through lazy aliases to dashscope.legacy_1x. The local get_tokenizer utility therefore keeps its 1.x exception contract, while 2.0 remote token counting is the independent client.tokenization resource. The application cores are internal implementation paths — 2.0 callers should use the client resource tree.
Concretely: the historical Agentic RL class still returns FineTune from submit_job and retains cancel/list/get/delete/logs, whereas the 2.0 job lifecycle is client.rl.jobs with errors from the SDK catalog. Likewise, standalone dashscope.agentstudio.Client keeps the old AgentStudioError hierarchy and its raw response attribute, while client.agentstudio raises dashscope.errors and exposes failed response data through body.
Breaking (2.0 AgentStudio errors): on the 2.0 surface —
client.agentstudio, whose exceptions come fromdashscope.applications.agentstudio—ConflictErroris an alias ofAPIStatusErrorrather than a 409-specific subclass, soexcept ConflictErrorcatches every status error (400/401/404/429/5xx), not just conflicts. Match onerr.status_code == 409if you need conflict-only handling. The historicaldashscope.agentstudio.ConflictErroris untouched and still 409-specific.
Breaking (
submit_job/ realtime WebSocket):submit_jobforwards extra keyword arguments straight to the transport, so the 1.xrequest_timeout=is renamedtimeout=, andworkspace=/headers=/stream=are no longer accepted (passing any of them raisesTypeError). The realtime WebSocket errors (WsStateError,WsQueueCapacityExceededError,WsBinaryOwnerConflictError) now derive fromDashScopeErrorinstead ofRuntimeError, so a bareexcept RuntimeErrorno longer catches them — catcherrors.DashScopeError(or the specific class) instead.
dashscope.save_api_key now comes from dashscope._config. It accepts an optional key-file path, expands ~, creates missing parent directories, and writes UTF-8. Logs from the current client use the independent dashscope._logging logger hierarchy and do not reconfigure the shared dashscope root logger.
Development tests
python -m pytest tests --ignore=tests/legacy_1x -q # current
python -m pytest tests/legacy_1x -q # archived compatibility
python -m pytest tests -q # everything
For current coverage, run coverage run -m pytest tests --ignore=tests/legacy_1x, then coverage report -m.
License
This project is licensed under the Apache License (Version 2.0).
Metadata
Release files for dashscope 2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dashscope-2.0.3.tar.gz | 2.4 MB | Without provenance | Details for dashscope-2.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dashscope-2.0.3-py3-none-any.whl | Python 3 | none | any | Details for dashscope-2.0.3-py3-none-any.whl |
Total release size: 4.8 MB
Release files / dashscope-2.0.3.tar.gz
| Download URL | dashscope-2.0.3.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
854e6e2405f46ddb44fcc20678e1c52062b448eeafe605d6ecece053ba940426
|
|
BLAKE2b-256 checksum How to use checksums |
dd6bddb8bce1970c0dda84d4b365d550b1fd3d997f02319a1406103ab871b58c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / dashscope-2.0.3-py3-none-any.whl
| Download URL | dashscope-2.0.3-py3-none-any.whl |
|---|---|
| Size | 2.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e561fec8f752da6bc7a73018d48d4e781eb90a45b67481b9f4ca296372134098
|
|
BLAKE2b-256 checksum How to use checksums |
a41c4118f219724eb4d7a55143de6fd4adcac26be655dca601f95baef700c254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for dashscope 2.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.