DashScope

Official Python SDK for Alibaba Cloud's Model Studio (Bailian) generative AI APIs

SDK
PyPI
v1.27.0
74stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity100
Maintenance100
Community48
Maturity40
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture72
Code Quality68
Innovation65
Learning Curve78

DashScope is the official Python client for Alibaba Cloud Model Studio (Bailian), giving developers a single import for text generation, multimodal understanding, embeddings, reranking, image and video synthesis, speech synthesis/recognition, and fine-tuning against Alibaba’s Qwen model family. It wraps synchronous, async, and streaming call patterns behind consistent classes like Generation, MultiModalConversation, and TextEmbedding, plus a bundled CLI for scripting file uploads, fine-tuning jobs, and deployments without writing Python.

The SDK also ships an OpenAI-compatible chat completion interface, making it straightforward to swap Qwen models into existing OpenAI-shaped codebases, and an assistants/threads/runs API modeled on the same pattern for building stateful agent workflows.

What You Get

  • Unified Generation, MultiModalConversation, TextEmbedding, MultiModalEmbedding, and TextReRank classes covering Qwen text, vision, and embedding models
  • Sync, streaming, and Aio* async call variants for every major API surface
  • Image and video synthesis clients (ImageSynthesis, VideoSynthesis) with async task submission and polling helpers
  • Speech synthesis (WebSocket streaming and one-shot HTTP) and speech recognition/transcription clients
  • A bundled dashscope CLI for generation, file management, fine-tuning, deployments, and agentic RL workflows
  • An OpenAI-compatible chat completions interface for drop-in use in OpenAI-shaped code

Common Use Cases

  • Calling Qwen text-generation models synchronously or via streaming for chat and completion features
  • Building multimodal features that understand images, video, or audio alongside text prompts
  • Generating embeddings and reranking search results for retrieval-augmented generation pipelines
  • Fine-tuning and deploying custom Qwen models via the CLI or the FineTunes/Deployments classes
  • Adding text-to-speech or speech-to-text to an application using the audio submodules

Under The Hood

Architecture - The SDK is organized as one class per API surface (dashscope/aigc, dashscope/multimodal, dashscope/embeddings, dashscope/audio, dashscope/rerank, dashscope/threads) built on a shared client/base_api.py mixin layer (base_api.py) that handles request building, SSE streaming, and async task polling (_get/wait patterns) via api_entities/api_request_factory.py. A cli/ package wraps the same classes behind a Typer-based command-line tool, so the HTTP layer is written once and reused by both the Python API and the CLI. Tech Stack - Pure Python with requests/aiohttp for HTTP, websocket-client for realtime TTS streaming, httpx/httpx-sse for the OpenAI-compatible interface, and typer/rich powering the CLI; packaging is classic setup.py/setuptools rather than a pyproject.toml-based build. Code Quality - The repo carries 79 test files under tests/ plus pre-commit.yml and unit_test.yml GitHub Actions workflows, indicating enforced linting and CI test runs on every change; module naming is consistent (Generation, MultiModalConversation, TextEmbedding) and errors are centralized in common/error.py. API Design - The consistent .call()/.async_call()/Aio* naming convention across otherwise-different model APIs (text, vision, embeddings, speech, image, video) makes the surface easy to predict once one class is learned, and the OpenAI-compatible Completions class lowers switching cost for teams already using OpenAI-shaped clients; the tradeoff is a fairly large flat namespace (dozens of top-level classes) with less top-down documentation than a smaller SDK would need.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search