DashScope
Official Python SDK for Alibaba Cloud's Model Studio (Bailian) generative AI APIs
Repository Health
Technical Analysis
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, andTextReRankclasses 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
dashscopeCLI 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/Deploymentsclasses - 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.
Used by 2 apps in this directory
Banana Slides
AI Design Tools · Productivity
AI-native PPT generator with Vibe editing, multi-LLM support, and fully editable PPTX export
MaxKB
AI Development · Knowledge Management
Build enterprise-grade AI agents with RAG, workflows & multi-modal support