Features¶
The 3.0 SDK is a typed, resource-style client. One DashScopeClient holds a shared OkHttp
connection pool; every capability hangs off it as a typed resource with typed request params
(Lombok builders) and typed responses.
Resource map¶
| Accessor | Capability | Guide |
|---|---|---|
client.chat() |
Chat completions, streaming, tool calls | Chat and Streaming |
client.embeddings() |
Text embeddings | Embeddings and Rerank |
client.rerank() |
Document reranking | Embeddings and Rerank |
client.multimodal() |
Vision-language understanding | Multimodal |
client.audio() |
Speech synthesis, recognition, realtime voice (under development; interfaces may change) | Audio |
client.images() |
Image generation | Images and Videos |
client.videos() |
Video generation | Images and Videos |
client.files() |
File upload / management | Files and Fine-tuning |
client.models() |
Model listing | Files and Fine-tuning |
client.fineTunes() |
Fine-tuning jobs | Files and Fine-tuning |
client.deployments() |
Model deployment management | Files and Fine-tuning |
client.apps() |
Application calls | API Reference |
client.decision() |
Decision models | API Reference |
client.tingwu() |
TingWu meeting transcription | Audio |
client.tokenization() |
Token counting (remote + local BPE) | Tokenization |
client.agentStudio() |
Managed agents: sessions, threads, events, memory stores, vaults | AgentStudio |
Sync & async¶
DashScopeAsyncClient mirrors the sync surface exactly:
- unary calls return
CompletableFuture<T>; - streaming calls return RxJava
Flowable<T>; - work runs on a daemon executor owned by the client (customizable via
ClientOptions.executor); - try-with-resources shuts the executor down.
Text-like streaming¶
Sync streaming returns ResponseStream<T> — Iterable + AutoCloseable. The SDK requests
incremental frames by default, so each chunk's delta is a content increment; iterate it like a
plain collection and print as you go. The connection closes when the stream is exhausted or closed.
Typed errors & diagnosis¶
Failures throw unchecked DashScopeException subclasses (AuthenticationException,
RateLimitException, ContentFilterException, ApiTimeoutException, …) carrying code and
request_id. Idempotent transport failures are retried with backoff (maxRetries); per-request
overrides are available through RequestOptions. See Errors and Diagnosis.
Config chain & per-request options¶
Credentials and endpoints resolve from system properties → environment variables → config file,
with builder overrides on top. ClientOptions covers base URL, WebSocket base URL, region,
workspace, timeouts, retries, custom OkHttpClient (proxies) and executor; RequestOptions
overrides timeout, retries, API key, workspace, headers and encryption per call. See
Configuration.
Encrypted channel¶
Opt-in RSA envelope encryption (RequestOptions.enableEncryption(true)) protects sensitive
payloads end to end; the SDK fetches and caches the gateway public key automatically.
Local mock debugging¶
Point baseUrl at a local HTTP server serving canned envelopes to exercise success and error
paths with zero network calls beyond loopback and zero token cost. See
Local Mock Debugging.
Local tokenizer¶
TokenizerFactory / QwenTokenizer provide offline BPE token counting with a cached vocab —
no network round trip for token budgets. See Tokenization.
Frozen 2.x facade¶
The complete 2.x API remains available under com.alibaba.dashscope.legacy_2x for existing code;
it is frozen and new development should use the 3.0 resources. See Migrating from 2.x.
Engineering qualities¶
- JDK 8+ bytecode (
release 8cross-check on modern JDKs). - Zero silent errors: ErrorProne gate rejects empty catch blocks and print-and-continue handling in the 3.0 packages.
- Offline example verification: every example in
examples/runs against a mock gateway in CI.