cli

modelstudioaiApache-2.0活跃维护

阿里云百炼官方命令行工具,把模型调用、搜索、多模态和工作流封装成结构化工具调用,方便 AI Agent 框架直接接入。

Official Model Studio CLI(阿里云百炼 CLI)built for AI Agent frameworks, exposing models, search, multimodal, and workflow capabilities as structured tool calls.

v2.8.4发布于 2026-11-07 02:29 UTC370star +1 / 7 天36fork同步于 2026-11-10 12:01 UTC

怎么上手

由 README 提炼,执行前请确认
npm install -g bailian-cli
bl skill init
硬件要求按 README 说明

README 未说明本地硬件要求;CLI 调用云端 API,算力在阿里云侧,本地只需 Node.js >= 18.17(用安装脚本则无需 Node.js)

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

阿里云百炼官方 CLI,把模型、搜索、多模态和工作流能力封装成结构化工具调用,供 AI Agent 使用

阿里云百炼官方命令行工具,把模型调用、搜索、多模态和工作流封装成结构化工具调用,方便 AI Agent 框架直接接入。

核心能力

  • 用一条命令调用文本、图像、视频、语音全模态生成与编辑
  • 解析图片、文档、音频和长视频并支持问答
  • 调用百炼上的 Managed Agent、Agent 与工作流,接入知识库、记忆、联网搜索和 MCP
  • 在 Codex、Claude Code、Cursor 等客户端注册百炼 MCP 服务
  • 支持数据集校验上传、模型微调、专属端点部署与批量推理

容易踩的坑

用 npm 安装需 Node.js >= 18.17,用 curl 或 PowerShell 安装脚本则不需要 Node.js;应用编排、MCP 注册、训练部署、账户操作和套餐接入目前仅支持中国站(aliyun.com)账号,国际站账号不支持;知识库从创建起就按运行时长计费,即使不查询也收费,需按提示清理不用的知识库

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.8.4
  1. v2.8.4最新正式版2026-11-07 · 2026-11-07 02:29 UTC

    Added

    • Fine-tune training params: New bl finetune params command queries the training hyper-parameter configuration for a base model, with --training-type, --param-type, --mtu-spec-code filters and --modality / --reasoning-mode dynamic train options.
    • Fine-tune training metrics: New bl finetune metrics command queries the training metrics of a fine-tune job, with explicit paging via --page / --page-size.
  2. v2.8.32026-11-06 · 2026-11-06 03:28 UTC
    查看更新说明

    Added

    • Model-based web search: bl search web adds a model search mode and now uses it as the default implementation.
    • Web search in chat: bl text chat supports built-in web search via the enable_search parameter.

    Changed

    • Profile credentials: Profiles can now declare credentials per search mode (model / mcp), and the CLI picks the matching profile credential when switching search modes.
  3. v2.8.22026-11-04 · 2026-11-04 13:46 UTC
    查看更新说明

    Internal

    • Improve CLI usage statistics.
  4. v2.8.12026-11-04 · 2026-11-04 08:46 UTC
    查看更新说明

    Added

    • Linux ARM64 binaries: Add Linux ARM64 packages (glibc), supporting standalone installation and binary updates.

    Fixed

    • Image results: Preserve all images returned by concurrent asynchronous image generation and editing tasks, including tasks with different response formats.
    • Streaming chat: Detect prematurely closed Chat Completions streams, preserve complete tool_calls, and return finish_reason in structured output.
    • CLI shutdown: Prevent pending telemetry requests from delaying exit and preserve queued events when telemetry initialization fails.
  5. v2.8.02026-11-03 · 2026-11-03 12:03 UTC
    查看更新说明

    Added

    • Aliyun CLI integration: Support invocation through aliyun bl, with host-aware help, examples, recovery hints, and structured commands.
    • AK/SK authentication: Support BAILIAN_ACCESS_KEY_ID, BAILIAN_ACCESS_KEY_SECRET, and optional BAILIAN_SECURITY_TOKEN. Automatically obtain Console tokens with AK/SK when missing or expired.
    • Custom model import: Add bl cmodel base-models/import/get/list/watch/delete to import custom models from OSS, list supported base models, track import jobs, and query or delete imported models. The import API is currently available in the Beijing region only.

    Changed

    • Command output: JSON mode returns complete business results, with warnings, diagnostics, and errors written separately to stderr as JSONL for scripts and Agents.
    • Quiet mode: Hide only progress and informational messages while preserving complete results, warnings, and errors. Support DASHSCOPE_QUIET=1. Scripts extracting IDs, paths, or answers through quiet mode should explicitly read fields from JSON output.
    • Credential precedence: Resolve AK/SK in this order: command parameters, Bailian environment variables, Bailian configuration, then Alibaba Cloud environment variables.
    • Model recommendations: Disable thinking for recommendation LLM calls; keep --no-thinking accepted for compatibility.
    • Output mode validation: Explicitly validate supported formats for interactive login, local UI, Pipeline event streams, and streaming speech synthesis to avoid mixed output. Use text output for native interactive modes and Pipeline JSONL events, and specify --out for streaming speech synthesis in JSON mode.

    Fixed

    • Speech recognition: Preserve complete responses and transcriptions in JSON output, including task information when no transcriptions are returned.
    • Managed Agent warnings: Preserve SDK warnings in quiet and JSON modes.
    • Update notices: Display available updates even when using cached version results.
    • Error diagnostics: Avoid duplicate error messages and improve request diagnostics for model recommendations and fine-tuning fee queries.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    The official command-line interface for Aliyun Model Studio (DashScope) AI Platform

    npm version Node.js TypeScript License

    Aliyun Model Studio CLI Site · 中文文档 · API Documentation · Get API Key


    Chat with Qwen, generate and edit images and videos, understand images, synthesize and recognize speech, call apps, manage memory, retrieve knowledge, search the web — every AI capability, one command away.

    Built for AI Agents. Every command works as a structured tool call.

    Features

    • Model generation — Full-modality generation across text, image, video, and speech, with editing and reference-based generation
    • Asset understanding — Parse and ask questions about images, documents, audio, and long videos
    • App orchestration — Call Managed Agents, agents, and workflows published on Aliyun Model Studio, wired to knowledge bases, memory, web search, and MCP tools
    • Native MCP setup — Register Bailian MCP servers in Codex, Claude Code, Cursor, Qoder, Qoder Work, QwenWork (千问办公), Qwen Code, Gemini CLI, or Pi
    • Training & deployment — Validate and upload datasets, fine-tune models, deploy dedicated models as endpoints
    • Batch inference — Prepare CSV/JSONL, create and follow asynchronous Chat/Embedding tasks, download original results/errors with optional CSV, or send one synchronous Batch Chat request
    • Account operations — Login, UI-based configuration, model marketplace, usage and quota, rate-limit increases, team seat management
    • Plan onboarding — Connect subscription plans such as Token Plan to the CLI and common coding agents in one step

    Note: App orchestration, native MCP setup, training & deployment, account operations, and plan onboarding are currently available only to China site (aliyun.com) account holders and are not yet supported for international / global site accounts.

    Showcase 1: A Cinematic Short Film from One Sentence

    A complete 2-minute, 16:9 cinematic short film — produced end-to-end from a single natural-language sentence, with zero manual editing. This showcase demonstrates how an AI Agent can compose a multi-step creative pipeline by orchestrating three primitives:

    • Qwen Code — the agentic coding model that interprets the user's intent and drives the workflow
    • Aliyun Model Studio CLI — invokes HappyHorse 1.1, Aliyun Model Studio's text-/image-/reference-to-video generation model
    • spark-video Skill — handles scene decomposition, storyboarding, shot continuity, and final stitching

    The single prompt

    "Generate a roughly 2-minute video in Japanese cinematic style — a sweet, innocent first-love story about a high-school girl. The plot should be heart-fluttering enough to make viewers want to fall in love. Aspect ratio: 16:9."

    Showcase 2: A Short-Film Director Managed Agent from One Sentence

    One sentence builds a reusable cloud-side short-film director for storyboarding, storyboard image generation, and video creation:

    • Qwen Code — understands the requirement and generates the agent configuration
    • Aliyun Model Studio CLI — validates the configuration, previews the changes, and completes the deployment
    • Managed Agent — runs the director role along with its skills and tools in the cloud

    The single prompt

    "Build me a Managed Agent app that can produce short films — a director expert that generates videos and can also design the matching storyboards."

    Installation

    Agent install (recommended)

    Send the following to your Agent — it will detect your environment, then install and verify the CLI for you:

    Please read https://bailian.aliyun.com/cli/install.md and install the Aliyun Model Studio CLI for me
    

    Install with NPM

    npm install -g bailian-cli
    bl skill init
    

    Requires Node.js >= 18.17.

    Install on macOS/Linux

    curl -fsSL https://bailian.aliyun.com/cli/install.sh | bash
    

    No Node.js required. The installer automatically installs Bailian Skills.

    Install on Windows

    irm https://bailian.aliyun.com/cli/install.ps1 | iex
    

    No Node.js required. The installer automatically installs Bailian Skills.

    Quick Start

    Once installed, just describe your task to your AI Agent — no need to assemble commands by hand.

    ScenarioWhat to say to your Agent
    Managed Agent"Create a Managed Agent that can generate short-film storyboards and videos."
    Image & video generation"Generate an image of a cat in a spacesuit on Mars, then turn it into a video."
    Speech recognition"Transcribe this audio; if proper nouns are wrong, add hot words and try again."
    Usage & quota"Show my recent model usage, free-tier quota, and rate limits."
    Monitoring & alerts"Show my model call stats, failures and logs, and create an alert rule."
    Throughput reservations"List my throughput reservations and capacity instances, then scale, renew or release capacity and wait for the operation to finish."
    Model selection"Recommend a model for image understanding and customer support."
    Decision model"Use the Bailian decision model to route this ticket and assess whether it needs escalation."
    About Bailian CLI"Tell me what Bailian CLI can do for me, and suggest how to use it for my needs."

    More examples and scenarios: Aliyun Model Studio CLI Site

    Try a knowledge base

    With a valid API key and workspace, preview initialization first:

    bl knowledge init --workspace-id <workspace-id> --dry-run
    

    Knowledge bases accrue running-time charges from creation, even without queries. The one-time Standard Edition 720-hour allowance is shared across knowledge bases and expires 30 days after activation for new users. Model calls cost extra; your remaining allowance is unknown. Review the plan and billing rules, then add --yes to the same command after confirming the operation, removing --dry-run to execute.

    Keep the returned IDs and recovery record. Closing the CLI or a later failure does not stop billing; follow the reported cleanup actions to delete unused knowledge bases. See the Knowledge Studio quick start for retrieval and cleanup. The bailian-knowledge Skill is available through bl skill init.

    RAG audio and video

    bl knowledge doc import --index-id <id> --doc-id <fileId> imports an existing file into a knowledge base; doc list --details shows per-file processing settings. Media support includes parser options, streaming uploads, and media references in search/chunk output. Chat JSON separates the final answer from phases, tools, docs, usage, and raw events; quiet mode hides progress and informational messages while preserving the final result, including every JSON field. See the command guide.

    ParseX

    Parse documents or audio/video and extract structured fields through the workspace-scoped ParseX API:

    bl parsex parse submit --workspace-id <workspace-id> --file-url "https://example.com/document.pdf" --file-name document.pdf --output-file-format markdown --output json
    bl parsex parse result --workspace-id <workspace-id> --biz-id <parse-biz-id> --follow --output json
    bl parsex extract submit --workspace-id <workspace-id> --parsed-file-biz-id <parse-biz-id> --schema-file schema.json --output json
    bl parsex extract result --workspace-id <workspace-id> --biz-id <extract-biz-id> --follow --output json
    

    Use an ordinary API key and a workspace with ParseX access. Submission returns data.biz_id immediately; result --follow waits for completion. schema.json contains a JSON Schema object, for example {"type":"object","properties":{"title":{"type":"string"}}}. Inputs are accessible HTTP(S) URLs; extraction also accepts a retained document parsing task. See the ParseX command guide for processing options, result slices, OSS credentials, dry-run and polling behavior.

    Batch Inference

    bl batch convert --help
    bl batch convert --file input.csv --output-file input.jsonl --model qwen-plus
    bl batch create --file input.jsonl --dry-run
    bl batch create --file input.jsonl
    bl batch get --batch-id <id> --follow
    bl batch download --batch-id <id> --csv
    bl text chat --batch --model qwen-plus --message "Hello" --timeout 3600
    

    --help includes CSV, JSONL and result data examples. convert is local and needs no key; inference/task commands use a model API key. File inference uses asynchronous tasks via create → get → download: create uploads/submits and returns a task ID without waiting for completion. Query with get and download results after completion. Conversion/download files are atomically published per file and never silently overwritten. Use --force to recover partial downloads. JSONL is the authoritative result, while CSV is a lossy display; import IDs as text to preserve leading zeros. Ctrl-C stops local polling, not the remote task.

    text chat --batch sends one synchronous request and waits for its response; it does not create an asynchronous task ID. Use --message or --messages-file, which contains one request's conversation context, not independent file requests. The total request timeout defaults to 300 seconds (--timeout: 60–3600 seconds). Timeout/Ctrl-C/disconnection do not guarantee server cancellation.

    Synchronous Batch Chat is non-streaming; explicit realtime/international/Token Plan endpoints are rejected. An explicit realtime profile requires --base-url https://batch.dashscope.aliyuncs.com. Batch availability and limits depend on the service/model. Dry-run avoids business requests and output/directory writes; framework update checks/telemetry follow their settings.

    Authentication

    Console Login (OAuth, Recommended)

    Required for console capability commands (model list, app list, MCP list, workspace, usage queries, rate-limit increases, direct console calls). It can create an ordinary API key when needed. Token Plan and other subscription plans cannot use --console; use the API Key login below.

    bl auth login --console
    

    Use --console-site international for the international console.

    The CLI always prints the login URL. To choose a browser yourself, keep the command running and open the URL on the same machine:

    bl auth login --console --no-browser --console-site international
    

    If the browser blocks the local callback, check the console site's local-network permission or try Firefox. The PNA compatibility header does not bypass Chrome's local-network permission or Safari's mixed-content restrictions. No callback within 15 minutes is a failure (exit code 5), not a successful login.

    If you already have a valid console access token, import it via stdin without a browser or local callback server. Specify the token's actual region and site; for example, in a POSIX shell:

    bl auth login --console --token-stdin --console-site international --console-region ap-southeast-1 < /path/to/console-token.txt
    

    Input must be one raw token (up to 64 KiB), not JSON or Bearer ...; interactive terminal input is rejected to avoid echoing secrets. Use a protected file or trusted pipe, never put the token in command arguments or shell history, and remove temporary secret files after use. The CLI validates the token before saving; failure leaves existing credentials and the active Profile unchanged. Add --config <name> to save and activate a specific Profile on success. This imports only the console session, not a model API key.

    API Key

    To use an existing ordinary API key or a Token Plan subscription key, run the same command:

    bl auth login --api-key <API_KEY>
    

    Get an ordinary key from the DashScope Console, or a Token Plan key from the subscription overview.

    Alibaba Cloud OpenAPI AK/SK

    Token Plan seat and member management requires an Alibaba Cloud AccessKey. Get yours from the RAM Console.

    Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.

    bl auth login --open-api --access-key-id LTAI5t... --access-key-secret ...
    

    Configuration

    # View current config
    bl config show
    
    # List all config profiles
    bl config list
    
    # Switch config profile
    bl config use --name token-plan
    
    # Switch the CLI interface to Chinese
    bl config set --key language --value zh-CN
    

    Config file location: ~/.bailian/config.json

    Update

    bl update
    

    Upgrades the CLI to the latest version and refreshes the installed Agent Skills. Release notes for every version live in CHANGELOG.md.

    Contributing

    Bug reports, feature requests, and PRs are welcome. See CONTRIBUTING.md for developer setup, repo layout, and the workflow for adding or changing commands.

    Scan the QR code to join the Aliyun Model Studio CLI DingTalk user group for usage help, troubleshooting, bug reports, and tips from other users.

    Links

    Memory documentation (Chinese): capability matrix · command guide.

    ResourceURL
    Aliyun Model Studio CLI Sitehttps://bailian.console.aliyun.com/cli?spm=a2ty07.github
    DashScope API Docshttps://help.aliyun.com/zh/model-studio/
    Qwen Model Listhttps://help.aliyun.com/zh/model-studio/getting-started/models
    Aliyun Model Studio Consolehttps://bailian.console.aliyun.com/?spm=a2ty07.github
    Get API Keyhttps://bailian.console.aliyun.com/cn-beijing/?spm=a2ty07.github&tab=app#/api-key
    Get Token Plan API Keyhttps://bailian.console.aliyun.com/cn-beijing?spm=a2ty07.github&tab=plan#/efm/subscription/overview
    Get AccessKeyhttps://ram.console.aliyun.com/manage/ak