DashScope SDK

Go and Rust SDK for Aliyun DashScope (百炼 Model Studio) APIs.

Official API Documentation: api/README.md

Design Goals

  1. Realtime Focus: Primarily implement Qwen-Omni-Realtime WebSocket API
  2. OpenAI Compatibility: Text/chat APIs use OpenAI-compatible SDK
  3. Native WebSocket: Direct WebSocket implementation, not polling

Scope

This SDK focuses on Qwen-Omni-Realtime API for real-time multimodal conversation. For standard text APIs, use OpenAI-compatible SDKs.

APISDK CoverageAlternative
Text ChatOpenAI SDK with custom base URL
App/AgentDirect HTTP calls
RealtimeThis SDK

API Coverage

FeatureGoRustOfficial Doc
Realtime Sessionapi/realtime/
Audio Input/Output
Function Calls
Text Input
Video Input⚠️⚠️Limited support

Architecture

graph TB
    subgraph client["Client"]
        subgraph realtime["RealtimeService"]
            session["RealtimeSession"]
            send["Send Events"]
            recv["Receive Events"]
        end
    end
    
    client --> ws["wss://dashscope.aliyuncs.com<br/>/api-ws/v1/realtime"]

Authentication

Authorization: Bearer <api_key>

Optional workspace isolation:

X-DashScope-WorkSpace: <workspace_id>

Base URLs

RegionWebSocket URL
China (Beijing)wss://dashscope.aliyuncs.com/api-ws/v1/realtime
International (Singapore)wss://dashscope-intl.aliyuncs.com/api-ws/v1/realtime

Models

ModelInputOutputSample Rate
qwen-omni-turbo-realtimeaudio/textaudio/text16kHz
qwen3-omni-flash-realtimeaudio/text/videoaudio/text24kHz

Event Flow

sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: session.update
    C->>S: input_audio_buffer.append
    C->>S: response.create
    S-->>C: response.audio.delta
    S-->>C: response.audio.delta
    S-->>C: response.done

Examples Directory

  • examples/go/dashscope/ - Go SDK examples
  • examples/cmd/dashscope/ - CLI test scripts

For Text/Chat APIs

Use OpenAI-compatible SDK:

Go:

import "github.com/sashabaranov/go-openai"

config := openai.DefaultConfig(apiKey)
config.BaseURL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
client := openai.NewClientWithConfig(config)

Rust:

#![allow(unused)]
fn main() {
// Use async-openai with custom base URL
}
  • CLI tool: go/cmd/dashscope/
  • CLI tests: examples/cmd/dashscope/