Class DashScopeClient

java.lang.Object
com.alibaba.dashscope.DashScopeClient
All Implemented Interfaces:
AutoCloseable

public final class DashScopeClient extends Object implements AutoCloseable
DashScope 3.0 synchronous client (design §2). Entry point:

 try (DashScopeClient client = DashScopeClient.builder().apiKey("...").build()) {
   ChatCompletion r = client.chat().completions().create(params);
 }
 

withOptions(ClientOptions) derives a client that shares the underlying connection pool; a derived client must not outlive its parent.

  • Method Details

    • builder

      public static DashScopeClient.Builder builder()
    • chat

      public ChatService chat()
    • embeddings

      public EmbeddingService embeddings()
    • rerank

      public RerankService rerank()
    • multimodal

      public MultimodalService multimodal()
    • audio

      public AudioService audio()
    • apps

      public AppsService apps()
      Bailian applications: apps().completions().create(...).
    • decision

      public DecisionService decision()
      System One decision model: typed questions over a business state, one round trip.
    • images

      public ImagesService images()
      Text-to-image: generate blocking sugar + jobs() task handle.
    • videos

      public VideosService videos()
      Video generation: generate blocking sugar + jobs() task handle.
    • files

      public FilesService files()
      File management: upload/list/get/delete.
    • models

      public ModelsService models()
      Model catalog: list/get.
    • fineTunes

      public FineTunesService fineTunes()
      Fine-tuning jobs: create/get/list/cancel/delete/logs/streamEvents/wait.
    • deployments

      public DeploymentsService deployments()
      Model deployments: create/get/list/scale/delete/streamEvents.
    • tingwu

      public TingWuService tingwu()
      TingWu: offline summarization jobs + realtime understanding.
    • tokenization

      public TokenizationService tokenization()
      Server-side token counting. For the local BPE tokenizer see TokenizerFactory.
    • agentStudio

      public AgentStudioClient agentStudio()
      AgentStudio management plane (design §7): one implementation under applications.agentstudio, shared by both generations and excluded from the 4.0 legacy cleanup. Created lazily because endpoint resolution requires a workspace or DASHSCOPE_AGENTSTUDIO_URL, and the subarea allocates its own HTTP clients. Errors use the 3.0 unchecked exception family; the 3.0 baseUrl does not apply here.
    • config

      public ResolvedConfig config()
      The resolved configuration (config chain applied).
    • wsConnection

      public WsConnection wsConnection()
      Open a shared WebSocket connection multiplexing many task-protocol tasks (audio design §7). The caller owns it and must close it; pass it to asr().recognize(params, connection) / tts().connect(params, connection) to reuse the handshake.
    • wsConnection

      public WsConnection wsConnection(RequestOptions options)
    • withOptions

      public DashScopeClient withOptions(ClientOptions overrides)
      Derive a client with extra overrides, sharing this client's connection pool. An override that injects a different httpClient is honored: the transport derives from it, sharing its pool and ensuring the auth/UA/retry interceptors apply.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable