bailian-cli
v0.1.2
Published
CLI for Alibaba Cloud Bailian (DashScope) AI Platform
Readme
>_ Bailian CLI
The official command-line interface for Alibaba Cloud Bailian (DashScope) AI Platform
中文文档 · API Documentation · Get API Key
Chat with Qwen, generate images & videos, understand images, call agents, manage memory, search the web — all from your terminal.
Built for AI Agents. Every command works as a structured tool call.
Installation
npm install -g bailian-cliAfter installation, both bailian and bl (short alias) are available.
Quick Start
# Authenticate
bl auth login --api-key sk-xxxxx
# Chat with Qwen
bl text chat --message "What is DashScope?"
# Multimodal chat (text + image + audio + video)
bl omni --message "Describe this image" --image ./photo.jpg
# Generate an image
bl image generate --prompt "A cat in a spacesuit" --out-dir ./images/
# Generate a video from local image
bl video generate --image ./cat.png --prompt "Make the cat move" --download cat.mp4Features
Local File Support: All commands accepting file URLs also accept local file paths — files are auto-uploaded. Just pass
./photo.pnginstead of a URL.
| Category | Commands | Default Model |
|:---------|:---------|:--------------|
| Text | text chat | qwen3.6-plus |
| Omni | omni (text+image+audio+video) | qwen3.5-omni-plus |
| Image | image generate | qwen-image-2.0 |
| | image edit (multi-image merge) | qwen-image-2.0 |
| Video | video generate (text/image-to-video) | happyhorse-1.0-t2v / happyhorse-1.0-i2v |
| | video edit (style transfer) | happyhorse-1.0-video-edit |
| | video task get / video download | — |
| Category | Commands | Default Model |
|:---------|:---------|:--------------|
| Vision | vision describe | qwen-vl-max |
| Speech | speech synthesize (TTS) | cosyvoice-v3-flash |
| | speech recognize (ASR) | fun-asr |
| File | file upload (to temp OSS) | — |
| App | app call (agents / workflows) | — |
| Memory | memory add/search/list/update/delete | — |
| Knowledge | knowledge retrieve (RAG) | — |
| Search | search web | — |
Usage Examples
Text Chat
# Simple chat
bl text chat --message "Explain quantum computing"
# Multi-turn conversation
bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"
# With system prompt
bl text chat --system "You are a coding assistant." --message "Write fizzbuzz in Python"
# Enable thinking mode (qwen3 / qwq)
bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinkingOmni Multimodal
# Describe an image
bl omni --message "What's in this photo?" --image ./photo.jpg
# Understand audio
bl omni --message "Transcribe this audio" --audio ./recording.wav
# Generate speech output
bl omni --message "Read this aloud" --audio-out greeting.wavImage Generation & Editing
# Generate images
bl image generate --prompt "Mountain landscape" --size 16:9
# Generate multiple images
bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/
# Edit an image (local file auto-uploaded)
bl image edit --image ./photo.png --prompt "Change background to beach"
# Multi-image merge
bl image edit --image ./a.png --image ./b.png --prompt "Combine into a collage"Video Generation & Editing
# Text to video
bl video generate --prompt "A person reading a book" --download output.mp4
# Image to video (local file auto-uploaded)
bl video generate --image ./cat.png --prompt "Make the cat move" --ratio 3:4
# Edit a video (style transfer)
bl video edit --video ./input.mp4 --prompt "Convert to clay style"Speech
# List available voices
bl speech synthesize --list-voices --model cosyvoice-v3-flash
# Text-to-speech
bl speech synthesize --text "Hello world" --voice longyumi_v3 --out speech.wav
# Stream to audio player (macOS)
bl speech synthesize --text "你好" --voice longyumi_v3 --stream | afplay -
# Speech-to-text (local file auto-uploaded)
bl speech recognize --url ./meeting.mp3File Upload, App, Memory & Knowledge
# Upload a local file to DashScope temp storage
bl file upload --file ./photo.png --model qwen-vl-max
# Call a Bailian application
bl app call --app-id <APP_ID> --prompt "Hello" --stream
# Memory management
bl memory add --user-id user1 --content "User prefers Python"
bl memory search --user-id user1 --query "programming language"
# Knowledge base retrieval (requires AK/SK)
bl knowledge retrieve --index-id <INDEX_ID> --query "search text"
# Web search
bl search web --query "latest TypeScript features" --count 5Authentication
DashScope API Key
Required for most commands. Get your key from the DashScope Console.
# Option 1: Environment variable
export DASHSCOPE_API_KEY=sk-xxxxx
# Option 2: Login command (persisted to ~/.bailian/config.json)
bl auth login --api-key sk-xxxxx
# Option 3: Per-command flag
bl text chat --api-key sk-xxxxx --message "Hello"Alibaba Cloud AK/SK (Knowledge Base only)
Required for knowledge retrieve. Get your AccessKey from RAM Console.
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
export BAILIAN_WORKSPACE_ID=ws-...Configuration
# View current config
bl config show
# Set defaults
bl config set --key region --value us
bl config set --key default_text_model --value qwen-turbo
bl config set --key timeout --value 600
# Export MCP-compatible JSON Schema for all commands
bl config export-schema
# Self-update to latest version
bl updateConfig file location: ~/.bailian/config.json
Global Flags
| Flag | Description |
|:-----|:------------|
| --api-key <key> | API key (overrides all other auth) |
| --region <region> | API region: cn (default), us, intl |
| --output <format> | Output format: text, json |
| --quiet | Suppress non-essential output |
| --verbose | Print HTTP request/response details |
| --dry-run | Show what would happen without executing |
| --no-color | Disable ANSI colors and spinners |
| --timeout <seconds> | Request timeout (default: 300) |
| --non-interactive | Disable interactive prompts (CI mode) |
Project Structure
src/
├── main.ts # CLI entry point
├── registry.ts # Command registry (30 commands)
├── args.ts # Argument parsing
├── command.ts # Command interface & global options
├── auth/ # Authentication (credentials, resolver, setup)
├── client/ # HTTP client (AK signing, endpoints, streaming)
├── commands/ # Command implementations
│ ├── auth/ # login, status, logout
│ ├── text/ # chat
│ ├── omni/ # multimodal chat
│ ├── image/ # generate, edit
│ ├── video/ # generate, edit, task-get, download
│ ├── vision/ # describe
│ ├── speech/ # synthesize, recognize
│ ├── file/ # upload
│ ├── app/ # call
│ ├── memory/ # add, search, list, update, delete, profile
│ ├── knowledge/ # retrieve
│ ├── search/ # web
│ └── config/ # show, set, export-schema
├── config/ # Config loading & schema (Zod)
├── errors/ # Error handling hierarchy
├── output/ # Formatters (text, json, progress, status-bar)
├── polling/ # Async task polling
├── update/ # Self-update checker
└── utils/ # Utilities (fs, token, env, prompt)Links
| Resource | URL | |:---------|:----| | DashScope API Docs | https://help.aliyun.com/zh/model-studio/ | | Qwen Model List | https://help.aliyun.com/zh/model-studio/getting-started/models | | Bailian Console | https://bailian.console.aliyun.com/ | | Get API Key | https://bailian.console.aliyun.com/cn-beijing/?source_channel=aliway&tab=app#/api-key | | Get AccessKey | https://ram.console.aliyun.com/manage/ak |
Made with >_ by the Bailian team
