README.md
# bailian-cli
> [中文版 / Chinese →](README.zh.md)
Agent skill for **Alibaba Cloud Model Studio CLI** (`bl`) resource hub — apps, memory, RAG, usage/quota, MCP, and hub `reference/`.
- Shared protocol: `bailian-protocol` (install via `bl skill init`)
- Soft hand-offs (optional skills): `bailian-gen` · `bailian-finetune` · `bailian-managed-agent` · `bailian-web-search`
```bash
bl skill init
```
For CLI installation, authentication, and examples, see the [main README](../../README.md).
## License
Apache-2.0
README.zh.md
# 百炼 CLI
> [English →](README.md)
**阿里云百炼 CLI**(`bl`)的资源管理 Agent 技能 — 应用、记忆、RAG、用量/额度、MCP,以及 hub `reference/`。
- 共享协议:`bailian-protocol`(通过 `bl skill init` 与整家族同装)
- 软 hand-off(可选):`bailian-gen` · `bailian-finetune` · `bailian-managed-agent` · `bailian-web-search`
```bash
bl skill init
```
CLI 的安装、认证和使用示例请查看[主 README](../../README.zh.md)。
## License
Apache-2.0
reference/advisor.md
# `bl advisor` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ---------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------- |
| `bl advisor recommend` | API Key | Recommend the best models for your use case (intent → routing → recall → score → rank, with agent clarification) |
## Command details
### `bl advisor recommend`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------------- |
| **Name** | `advisor recommend` |
| **Description** | Recommend the best models for your use case (intent → routing → recall → score → rank, with agent clarification) |
| **Authentication** | API Key |
| **Usage** | `bl advisor recommend --message <text> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | --------------------------------------------------------------------------------------- |
| `--message <text>` | string | yes | Describe your requirements |
| `--top <n>` | number | no | Number of recommendations (default: 3) |
| `--model <model>` | string | no | LLM used for every stage: agent/intent/scoring/explain (default: qwen-flash-2025-07-28) |
| `--no-agent` | switch | no | Skip the agent loop and run the deterministic engine directly |
| `--trace` | switch | no | Emit full routing/performance trace to stderr |
| `--think` | switch | no | Show the engine decision process to stderr |
| `--no-thinking` | switch | no | Deprecated no-op: thinking is always disabled for advisor LLM calls |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Examples
```bash
bl advisor recommend --message "Recommend a model for writing code"
```
```bash
bl advisor recommend --message "Build a digital-human livestream" --no-agent
```
```bash
bl advisor recommend --message "qwen-max vs deepseek-v3, which is better"
```
```bash
bl advisor recommend --message "Anything cheaper than qwen-plus" --output json
```
reference/agents.md
# `bl agents` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------------------- | -------------- | ----------------------------------------------------------- |
| `bl agents security alerts` | API Key | List Agent security alerts |
| `bl agents security overview` | API Key | Show the Agent security protection overview (last 24 hours) |
## Command details
### `bl agents security alerts`
| Field | Value |
| ------------------ | ----------------------------------- |
| **Name** | `agents security alerts` |
| **Description** | List Agent security alerts |
| **Authentication** | API Key |
| **Usage** | `bl agents security alerts [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------------------------------------------------- | ------ | -------- | ------------------------------------------------------------------------- |
| `--workspace-id <id>` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 20) |
| `--risk-level <high\|medium\|low>` | string | no | Filter by risk level: high, medium, low |
| `--risk-name <text>` | string | no | Filter by risk name |
| `--status <status>` | string | no | Filter by handling status |
| `--status-list <status>` | array | no | Filter by multiple statuses (repeatable) |
| `--app-name <name>` | string | no | Filter by application name |
| `--asset-type <agent\|tool\|skill\|knowledge_base\|memory\|channel>` | string | no | Filter by asset type: agent, tool, skill, knowledge_base, memory, channel |
| `--vendor <vendor>` | string | no | Filter by vendor |
| `--order-by <field>` | string | no | Sort field (default: check_time) |
| `--order <asc\|desc>` | string | no | Sort direction: asc, desc (default: desc) |
| `--lang <zh\|en>` | string | no | Response language: zh, en |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Auth: uses DashScope API Key (Bearer token).
- `--workspace-id` can be set via BAILIAN_WORKSPACE_ID env or config workspace_id.
- Filters, pagination and sorting go in the query string; enum flags are validated before any request is sent.
- AgentStudio host: derived from --workspace-id by default; point --base-url / DASHSCOPE_BASE_URL (or `auth login --base-url`) at a workspace or pre-release origin such as https://<workspace-id>.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio to override it, and --workspace-id is then not required.
#### Examples
```bash
bl agents security alerts --workspace-id ws-xxx
```
```bash
bl agents security alerts --risk-level high --page-size 50
```
```bash
bl agents security alerts --asset-type agent --app-name "demo app" --output json
```
```bash
bl agents security alerts --status-list unhandled --status-list handling
```
### `bl agents security overview`
| Field | Value |
| ------------------ | ----------------------------------------------------------- |
| **Name** | `agents security overview` |
| **Description** | Show the Agent security protection overview (last 24 hours) |
| **Authentication** | API Key |
| **Usage** | `bl agents security overview [flags]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------- | ------ | -------- | --------------------------------------------------------------- |
| `--workspace-id <id>` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Auth: uses DashScope API Key (Bearer token).
- `--workspace-id` can be set via BAILIAN_WORKSPACE_ID env or config workspace_id.
- Fixed to the last 24 hours; the AgentStudio region is always cn-beijing and is not configurable.
- AgentStudio host: derived from --workspace-id by default; point --base-url / DASHSCOPE_BASE_URL (or `auth login --base-url`) at a workspace or pre-release origin such as https://<workspace-id>.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio to override it, and --workspace-id is then not required.
#### Examples
```bash
bl agents security overview --workspace-id ws-xxx
```
```bash
bl agents security overview --workspace-id ws-xxx --output json
```
reference/alert.md
# `bl alert` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| -------------------------- | -------------- | ---------------------------------------------------------------------------- |
| `bl alert create` | Console | Create a model alert rule from an alert template |
| `bl alert delete` | Console | Delete model alert rules |
| `bl alert disable` | Console | Disable a model alert rule (keeps the rule, stops notifications) |
| `bl alert enable` | Console | Enable a model alert rule |
| `bl alert history` | Console | List model alert history (firing and recovered events) |
| `bl alert list` | Console | List model alert rules |
| `bl alert metrics` | Console | List metrics that alert rules can be created on, with supported aggregations |
| `bl alert template create` | Console | Create a custom alert template (or copy an official one with --from) |
| `bl alert template delete` | Console | Delete custom alert templates (official templates cannot be deleted) |
| `bl alert template list` | Console | List alert templates (official and custom); pass --template-id for details |
| `bl alert template update` | Console | Update a custom alert template (full replacement of conditions) |
| `bl alert update` | Console | Update a model alert rule (full replacement; same fields as create) |
## Command details
### `bl alert create`
| Field | Value |
| ------------------ | -------------------------------------------------------------------------- |
| **Name** | `alert create` |
| **Description** | Create a model alert rule from an alert template |
| **Authentication** | Console |
| **Usage** | `bl alert create --name <name> --template-id <id> --model <model> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------------- | ------ | -------- | --------------------------------------------------------------------------------- |
| `--name <name>` | string | yes | Alert rule name (max 64 chars) |
| `--template-id <id>` | string | yes | Alert template ID (from `alert template list`) |
| `--model <model>` | string | yes | Model name(s) to alert on, comma-separated |
| `--message <text>` | string | no | Alert notification content (Go template); defaults to the console template |
| `--level <INFO\|WARNING\|ERROR>` | string | no | Alert level (default: INFO) |
| `--interval <seconds>` | number | no | Check interval in seconds (default: 60) |
| `--duration <seconds>` | number | no | How long the condition must hold before alerting; 0 = immediately (default: 60) |
| `--contact <id>` | string | no | CMS alert contact ID(s), comma-separated; create them in the CloudMonitor console |
| `--contact-group <id>` | string | no | CMS alert contact group ID(s), comma-separated |
| `--notify-window <HH:mm-HH:mm>` | string | no | Daily notification window (default: 00:00-23:59) |
| `--notify-days <days>` | string | no | Days of week to notify, 1-7 comma-separated (default: every day) |
| `--silence <seconds>` | number | no | Silence period between repeat notifications (default: never repeat) |
| `--gmt-offset <offset>` | string | no | Timezone offset for the notify window (default: +0800) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Alert conditions come from the template; browse `alert template list` first. Notification contacts/contact groups are created in the CloudMonitor console — pass their IDs via --contact/--contact-group.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert create --name high-failure-rate --template-id 123 --model qwen3.6-plus
```
```bash
bl alert create --name latency --template-id 456 --model qwen3.6-plus,qwen-turbo --level ERROR --contact-group 4004200
```
```bash
bl alert create --name nightly --template-id 123 --model qwen3.6-plus --notify-window 09:00-18:00 --notify-days 1,2,3,4,5 --silence 3600
```
```bash
bl alert create --name test --template-id 123 --model qwen3.6-plus --dry-run
```
### `bl alert delete`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------ |
| **Name** | `alert delete` |
| **Description** | Delete model alert rules |
| **Authentication** | Console |
| **Usage** | `bl alert delete --rule-id <id>[,<id>...] [--yes]` |
| **Risk** | `high` |
| **Risk message** | This permanently deletes the specified alert rules and cannot be undone. |
> **Agent safety:** Never add `--yes` automatically. On `type="requires_confirmation"`, stop and ask for explicit user confirmation of the same action and scope.
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--rule-id <id>[,<id>...]` | string | yes | Rule ID(s) to delete, comma-separated |
| `--yes` | switch | no | Confirm this high-risk operation |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Irreversible — the alert rules are permanently removed.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert delete --rule-id 789
```
```bash
bl alert delete --rule-id 789,790 --dry-run
```
```bash
# Only after explicit user confirmation:
bl alert delete --rule-id 789 --yes
```
### `bl alert disable`
| Field | Value |
| ------------------ | ---------------------------------------------------------------- |
| **Name** | `alert disable` |
| **Description** | Disable a model alert rule (keeps the rule, stops notifications) |
| **Authentication** | Console |
| **Usage** | `bl alert disable --rule-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--rule-id <id>` | string | yes | Alert rule ID |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert disable --rule-id 789
```
```bash
bl alert disable --rule-id 789 --dry-run
```
### `bl alert enable`
| Field | Value |
| ------------------ | ---------------------------------------- |
| **Name** | `alert enable` |
| **Description** | Enable a model alert rule |
| **Authentication** | Console |
| **Usage** | `bl alert enable --rule-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--rule-id <id>` | string | yes | Alert rule ID |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert enable --rule-id 789
```
```bash
bl alert enable --rule-id 789 --dry-run
```
### `bl alert history`
| Field | Value |
| ------------------ | --------------------------------------------------------------- |
| **Name** | `alert history` |
| **Description** | List model alert history (firing and recovered events) |
| **Authentication** | Console |
| **Usage** | `bl alert history [--rule-id <id>] [--status <status>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------------- | ------ | -------- | -------------------------------------------------------- |
| `--days <days>` | number | no | Number of days to look back (default: 7) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--rule-id <id>` | string | no | Filter by alert rule ID |
| `--status <ALARM\|OK>` | string | no | Alert state: ALARM (firing), OK (recovered) |
| `--level <INFO\|WARNING\|ERROR>` | string | no | Filter by highest alert level |
| `--max-results <n>` | number | no | Rows per page, 1-50 (default: 10) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--next-token <token>` | string | no | Pagination token from a previous response |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert history
```
```bash
bl alert history --status ALARM --days 1
```
```bash
bl alert history --rule-id 789 --days 30
```
```bash
bl alert history --level ERROR --output json
```
### `bl alert list`
| Field | Value |
| ------------------ | --------------------------------------------------------------- |
| **Name** | `alert list` |
| **Description** | List model alert rules |
| **Authentication** | Console |
| **Usage** | `bl alert list [--name <name>] [--enabled true\|false] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------------- | ------- | -------- | -------------------------------------------------------- |
| `--rule-id <id>` | string | no | Exact rule ID filter |
| `--name <name>` | string | no | Fuzzy filter by rule name |
| `--enabled <true\|false>` | boolean | no | Filter by enabled state |
| `--level <INFO\|WARNING\|ERROR>` | string | no | Filter by alert level |
| `--max-results <n>` | number | no | Rows per page (default: 20) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--next-token <token>` | string | no | Pagination token from a previous response |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert list
```
```bash
bl alert list --enabled true
```
```bash
bl alert list --name 失败率 --level ERROR
```
```bash
bl alert list --output json
```
### `bl alert metrics`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------- |
| **Name** | `alert metrics` |
| **Description** | List metrics that alert rules can be created on, with supported aggregations |
| **Authentication** | Console |
| **Usage** | `bl alert metrics [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert metrics
```
```bash
bl alert metrics --output json
```
### `bl alert template create`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| **Name** | `alert template create` |
| **Description** | Create a custom alert template (or copy an official one with --from) |
| **Authentication** | Console |
| **Usage** | `bl alert template create --name <name> [--condition <metric:agg:cmp:value:period>...] [--from <template-id>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--name <name>` | string | yes | Template name (max 64 chars) |
| `--condition <metric:agg:cmp:value:period>` | array | no | Alert condition, repeatable (1-10). Example: 'model_call_failed_count:sum:>:10:60' (quote it: > is a shell metacharacter). See `alert metrics` for metric names |
| `--from <template-id>` | string | no | Copy conditions from an existing (e.g. official) template |
| `--logical-operator <or\|and>` | string | no | How multiple conditions combine (default: or) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert template create --name 失败率告警 --condition 'model_call_failed_count:sum:>:10:60'
```
```bash
bl alert template create --name 高延迟 --condition 'model_call_duration:avg:>:3000:300' --condition 'model_call_5xx_count:sum:>:5:60' --logical-operator and
```
```bash
bl alert template create --name 我的模板 --from <template-id>
```
```bash
bl alert template create --name test --condition 'model_call_count:sum:>:100:60' --dry-run
```
### `bl alert template delete`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------- |
| **Name** | `alert template delete` |
| **Description** | Delete custom alert templates (official templates cannot be deleted) |
| **Authentication** | Console |
| **Usage** | `bl alert template delete --template-id <id>[,<id>...] [--yes]` |
| **Risk** | `high` |
| **Risk message** | This permanently deletes the specified alert templates and cannot be undone. |
> **Agent safety:** Never add `--yes` automatically. On `type="requires_confirmation"`, stop and ask for explicit user confirmation of the same action and scope.
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--template-id <id>[,<id>...]` | string | yes | Template ID(s) to delete, comma-separated |
| `--yes` | switch | no | Confirm this high-risk operation |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Irreversible — the alert templates are permanently removed.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert template delete --template-id 123
```
```bash
bl alert template delete --template-id 123,124 --dry-run
```
```bash
# Only after explicit user confirmation:
bl alert template delete --template-id 123 --yes
```
### `bl alert template list`
| Field | Value |
| ------------------ | -------------------------------------------------------------------------- |
| **Name** | `alert template list` |
| **Description** | List alert templates (official and custom); pass --template-id for details |
| **Authentication** | Console |
| **Usage** | `bl alert template list [--name <name>] [--source <source>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------------- | ------ | -------- | -------------------------------------------------------- |
| `--template-id <id>` | string | no | Exact template ID (view a single template) |
| `--name <name>` | string | no | Fuzzy filter by template name |
| `--source <Official\|Customize>` | string | no | Template source: Official, Customize; omit for all |
| `--max-results <n>` | number | no | Rows per page (default: 50) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert template list
```
```bash
bl alert template list --source Official
```
```bash
bl alert template list --name 失败率
```
```bash
bl alert template list --template-id 123 --output json
```
### `bl alert template update`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------------- |
| **Name** | `alert template update` |
| **Description** | Update a custom alert template (full replacement of conditions) |
| **Authentication** | Console |
| **Usage** | `bl alert template update --template-id <id> --name <name> --condition <metric:agg:cmp:value:period>... [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------- |
| `--template-id <id>` | string | yes | Template ID (from `alert template list`) |
| `--name <name>` | string | yes | Template name (max 64 chars) |
| `--condition <metric:agg:cmp:value:period>` | array | no | Alert condition, repeatable (1-10). Example: 'model_call_failed_count:sum:>:10:60' (quote it: > is a shell metacharacter) |
| `--logical-operator <or\|and>` | string | no | How multiple conditions combine (default: or) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert template update --template-id 123 --name 失败率告警 --condition 'model_call_failed_count:sum:>:20:60'
```
```bash
bl alert template update --template-id 123 --name test --condition 'model_call_count:sum:>:100:60' --dry-run
```
### `bl alert update`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------------------- |
| **Name** | `alert update` |
| **Description** | Update a model alert rule (full replacement; same fields as create) |
| **Authentication** | Console |
| **Usage** | `bl alert update --rule-id <id> --name <name> --template-id <id> --model <model> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------------- | ------ | -------- | --------------------------------------------------------------------------------- |
| `--rule-id <id>` | string | yes | Alert rule ID (from `alert list`) |
| `--name <name>` | string | yes | Alert rule name (max 64 chars) |
| `--template-id <id>` | string | yes | Alert template ID (from `alert template list`) |
| `--model <model>` | string | yes | Model name(s) to alert on, comma-separated |
| `--message <text>` | string | no | Alert notification content (Go template); defaults to the console template |
| `--level <INFO\|WARNING\|ERROR>` | string | no | Alert level (default: INFO) |
| `--interval <seconds>` | number | no | Check interval in seconds (default: 60) |
| `--duration <seconds>` | number | no | How long the condition must hold before alerting; 0 = immediately (default: 60) |
| `--contact <id>` | string | no | CMS alert contact ID(s), comma-separated; create them in the CloudMonitor console |
| `--contact-group <id>` | string | no | CMS alert contact group ID(s), comma-separated |
| `--notify-window <HH:mm-HH:mm>` | string | no | Daily notification window (default: 00:00-23:59) |
| `--notify-days <days>` | string | no | Days of week to notify, 1-7 comma-separated (default: every day) |
| `--silence <seconds>` | number | no | Silence period between repeat notifications (default: never repeat) |
| `--gmt-offset <offset>` | string | no | Timezone offset for the notify window (default: +0800) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl alert update --rule-id 789 --name high-failure-rate --template-id 123 --model qwen3.6-plus --level WARNING
```
```bash
bl alert update --rule-id 789 --name nightly --template-id 123 --model qwen3.6-plus --silence 1800
```
```bash
bl alert update --rule-id 789 --name test --template-id 123 --model qwen3.6-plus --dry-run
```
reference/app.md
# `bl app` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------- | -------------- | ---------------------------------------------- |
| `bl app call` | API Key | Call a Bailian application (agent or workflow) |
| `bl app list` | Console | List Bailian applications |
## Command details
### `bl app call`
| Field | Value |
| ------------------ | --------------------------------------------------- |
| **Name** | `app call` |
| **Description** | Call a Bailian application (agent or workflow) |
| **Authentication** | API Key |
| **Usage** | `bl app call --app-id <id> --prompt <text> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ---------------------- | ------ | -------- | --------------------------------------------- |
| `--app-id <id>` | string | yes | Application ID (required) |
| `--prompt <text>` | string | yes | Input prompt text |
| `--image <url>` | array | no | Image URL(s) to pass to the app (repeatable) |
| `--file-id <id>` | array | no | Pre-uploaded file ID(s) (repeatable) |
| `--session-id <id>` | string | no | Session ID for multi-turn conversation |
| `--stream` | switch | no | Stream response (default: on in TTY) |
| `--pipeline-ids <ids>` | string | no | Knowledge base pipeline IDs (comma-separated) |
| `--memory-id <id>` | string | no | Memory ID for long-term memory |
| `--biz-params <json>` | string | no | Business parameters JSON (workflow variables) |
| `--has-thoughts` | switch | no | Show agent thinking process |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Examples
```bash
bl app call --app-id abc123 --prompt "Hello"
```
```bash
bl app call --app-id abc123 --prompt "Describe this image" --image https://example.com/photo.jpg
```
```bash
bl app call --app-id abc123 --prompt "Analyze the image" --image img1.jpg --image img2.jpg
```
```bash
bl app call --app-id abc123 --prompt "Continue" --session-id sess_xxx --stream
```
```bash
bl app call --app-id abc123 --prompt "Search for materials" --pipeline-ids pipe1,pipe2
```
```bash
bl app call --app-id abc123 --prompt "Start" --biz-params '{"key":"value"}'
```
### `bl app list`
| Field | Value |
| ------------------ | ------------------------- |
| **Name** | `app list` |
| **Description** | List Bailian applications |
| **Authentication** | Console |
| **Usage** | `bl app list [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--name <name>` | string | no | Filter by app name (keyword search) |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 30) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl app list
```
```bash
bl app list --name customer service
```
```bash
bl app list --page 2 --page-size 10
```
```bash
bl app list --output json
```
reference/auth.md
# `bl auth` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------------------------- | -------------- | -------------------------------------------------------------------------------------------- |
| `bl auth generate-access-token` | No Auth | Generate a CLI access token using OpenAPI AK/SK |
| `bl auth login` | No Auth | Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist) |
| `bl auth logout` | No Auth | Clear stored credentials; full logout also clears the model Base URL |
| `bl auth status` | No Auth | Show current authentication state |
## Command details
### `bl auth generate-access-token`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| **Name** | `auth generate-access-token` |
| **Description** | Generate a CLI access token using OpenAPI AK/SK |
| **Authentication** | No Auth |
| **Usage** | `bl auth generate-access-token --access-key-id <id> --access-key-secret <secret> --security-token <token>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ---------------------------------------------------- |
| `--access-key-id <id>` | string | yes | Alibaba Cloud Access Key ID |
| `--access-key-secret <secret>` | string | yes | Alibaba Cloud Access Key Secret |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token to store (optional) |
#### Examples
```bash
bl auth generate-access-token --access-key-id LTAIxxxxx --access-key-secret xxxxx --security-token <token>
```
### `bl auth login`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `auth login` |
| **Description** | Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist) |
| **Authentication** | No Auth |
| **Usage** | `bl auth login --api-key <key> \| --console [--no-browser \| --token-stdin --console-region <region>] \| --open-api --access-key-id <id> --access-key-secret <secret>` |
#### Flags
| Flag | Type | Required | Description |
| ----------------------------------------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--api-key <key>` | string | no | Model API key to validate and store |
| `--base-url <url>` | string | no | Model API base URL to validate and store with --api-key |
| `--console` | switch | no | Sign in via browser (China by default; use --console-site international for the international site). Creates an ordinary API key if needed; subscription plans require --api-key |
| `--no-browser` | switch | no | With --console, print the login URL without opening a browser |
| `--token-stdin` | switch | no | With --console, read one raw access token from piped stdin and validate before saving; requires --console-region, no browser or local server |
| `--console-region <cn-beijing\|ap-southeast-1>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <domestic\|international>` | string | no | Console site: domestic, international |
| `--open-api` | switch | no | Store Alibaba Cloud OpenAPI AK/SK credentials |
| `--access-key-id <id>` | string | no | Alibaba Cloud Access Key ID to store |
| `--access-key-secret <secret>` | string | no | Alibaba Cloud Access Key Secret to store |
#### Examples
```bash
bl auth login --console
```
```bash
bl auth login --console --no-browser --console-site international
```
```bash
bl auth login --console --token-stdin --console-site international --console-region ap-southeast-1
```
```bash
bl auth login --api-key sk-xxxxx
```
```bash
bl auth login --open-api --access-key-id LTAIxxxxx --access-key-secret xxxxx
```
### `bl auth logout`
| Field | Value |
| ------------------ | -------------------------------------------------------------------- |
| **Name** | `auth logout` |
| **Description** | Clear stored credentials; full logout also clears the model Base URL |
| **Authentication** | No Auth |
| **Usage** | `bl auth logout [--console \| --open-api] [--dry-run]` |
#### Flags
| Flag | Type | Required | Description |
| ------------ | ------ | -------- | ----------------------------------------------------------------------- |
| `--console` | switch | no | Only clear the console access_token, keep api_key intact |
| `--open-api` | switch | no | Only clear OpenAPI AK/SK/STS credentials, keep other credentials intact |
#### Examples
```bash
bl auth logout
```
```bash
bl auth logout --console
```
```bash
bl auth logout --open-api
```
```bash
bl auth logout --dry-run
```
### `bl auth status`
| Field | Value |
| ------------------ | --------------------------------- |
| **Name** | `auth status` |
| **Description** | Show current authentication state |
| **Authentication** | No Auth |
| **Usage** | `bl auth status` |
#### Flags
_No command-specific flags._
#### Examples
```bash
bl auth status
```
```bash
bl auth status --output json
```
reference/batch.md
# `bl batch` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------------- | -------------- | --------------------------------------------------------------- |
| `bl batch cancel` | API Key | Request cancellation of a Batch task |
| `bl batch convert` | No Auth | Build Batch JSONL from CSV locally |
| `bl batch create` | API Key | Upload or reference input and create an asynchronous Batch task |
| `bl batch download` | API Key | Download original Batch results/errors, optionally export CSV |
| `bl batch get` | API Key | Get Batch task details, optionally following progress |
| `bl batch list` | API Key | List one page of Batch tasks |
## Command details
### `bl batch cancel`
| Field | Value |
| ------------------ | ------------------------------------ |
| **Name** | `batch cancel` |
| **Description** | Request cancellation of a Batch task |
| **Authentication** | API Key |
| **Usage** | `bl batch cancel --batch-id <id>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ------------- |
| `--batch-id <id>` | string | yes | Batch task ID |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- An accepted cancellation may return cancelling, not cancelled. Use batch get --follow to confirm. Already executed requests still incur charges; files are not deleted.
- Dry-run does not call business APIs or write business files. Update checks and telemetry follow framework settings.
#### Examples
```bash
bl batch cancel --batch-id batch_xxx
```
```bash
bl batch cancel --batch-id batch_xxx --dry-run
```
### `bl batch convert`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------- |
| **Name** | `batch convert` |
| **Description** | Build Batch JSONL from CSV locally |
| **Authentication** | No Auth |
| **Usage** | `bl batch convert --file <csv> --model <model> --output-file <jsonl> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------------------------------------------------------- | ------ | -------- | ------------------------------------------------------ |
| `--file <csv>` | string | yes | UTF-8 CSV with headers |
| `--output-file <jsonl>` | string | yes | Local JSONL output path |
| `--model <model>` | string | yes | Model for every record |
| `--id-column <name>` | string | no | ID column (default: custom_id) |
| `--input-column <name>` | string | no | Input column (default: content) |
| `--system <text>` | string | no | Shared system prompt (Chat only) |
| `--body-file <json>` | string | no | Shared body parameters, excluding model/messages/input |
| `--endpoint </v1/chat/completions\|/v1/embeddings\|/v1/chat/ds-test>` | string | no | Batch endpoint (inferred from local JSONL) |
| `--force` | switch | no | Replace existing output files (atomic per file) |
#### Notes
- input.csv:
custom_id,content
req-001,Introduce yourself
req-002,2+2?
input.jsonl:
{"custom_id":"req-001","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen-plus","messages":[{"role":"user","content":"Introduce yourself"}]}}
defaults.json (--body-file):
{"enable_thinking":false,"max_tokens":1024}
- Text/embedding mapping only; use native JSONL for multimodal or multi-turn input. IDs remain strings; import CSV IDs as text in spreadsheet software.
- Dry-run does not call business APIs or write business files. Update checks and telemetry follow framework settings.
#### Examples
```bash
bl batch convert --file input.csv --model qwen-plus --output-file input.jsonl
```
```bash
bl batch convert --file input.csv --model text-embedding-v4 --endpoint /v1/embeddings --output-file vectors.jsonl
```
```bash
bl batch convert --file input.csv --model qwen-plus --body-file defaults.json --output-file input.jsonl --dry-run
```
### `bl batch create`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------- |
| **Name** | `batch create` |
| **Description** | Upload or reference input and create an asynchronous Batch task |
| **Authentication** | API Key |
| **Usage** | `bl batch create (--file <jsonl> \| --input-file-id <source> --endpoint <path>) [flags]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------------------------------------------------------- | ------ | -------- | -------------------------------------------------- |
| `--file <jsonl>` | string | no | Local Batch JSONL (exclusive with --input-file-id) |
| `--input-file-id <source>` | string | no | File ID, OSS HTTPS URL or oss:region:bucket/path |
| `--completion-window <24h\|7d>` | string | no | Completion window: 24–336 hours (default: 24h) |
| `--name <text>` | string | no | Task name (max 100 characters) |
| `--description <text>` | string | no | Task description (max 200 characters) |
| `--callback-url <url>` | string | no | Completion callback (documented in Beijing only) |
| `--metadata <KEY=VALUE>` | array | no | Custom task metadata (repeatable) |
| `--endpoint </v1/chat/completions\|/v1/embeddings\|/v1/chat/ds-test>` | string | no | Batch endpoint (inferred from local JSONL) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Chat JSONL:
{"custom_id":"req-001","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen-plus","messages":[{"role":"user","content":"Introduce yourself"}]}}
Embedding JSONL:
{"custom_id":"req-001","method":"POST","url":"/v1/embeddings","body":{"model":"text-embedding-v4","input":"Introduce yourself","encoding_format":"float"}}
Multimodal JSONL (replace the example public image URL):
{"custom_id":"req-001","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen-vl-plus","messages":[{"role":"user","content":[{"type":"text","text":"Introduce yourself"},{"type":"image_url","image_url":{"url":"https://example.com/image.jpg"}}]}]}}
- Local input: <=50,000 requests, <=500 MiB, <=6 MiB per line; >1 MiB warns due to conflicting documentation. batch-test-model: <=100 requests and <=1 MiB. Remote references require authorization and sufficient URL validity; they are not downloaded for validation. No automatic POST replay or uploaded-file cleanup on failure.
- Dry-run does not call business APIs or write business files. Update checks and telemetry follow framework settings.
#### Examples
```bash
bl batch create --file input.jsonl --name eval-1 --dry-run
```
```bash
bl batch create --file input.jsonl --completion-window 24h
```
```bash
bl batch create --input-file-id file-batch-xxx --endpoint /v1/chat/completions
```
```bash
bl batch create --input-file-id oss:cn-beijing:my-bucket/input.jsonl --endpoint /v1/chat/completions --completion-window 7d
```
### `bl batch download`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------ |
| **Name** | `batch download` |
| **Description** | Download original Batch results/errors, optionally export CSV |
| **Authentication** | API Key |
| **Usage** | `bl batch download --batch-id <id> [--out-dir <path>] [--csv] [--force]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ------------------------------------------------------- |
| `--batch-id <id>` | string | yes | Batch task ID |
| `--force` | switch | no | Replace existing output files (atomic per file) |
| `--out-dir <path>` | string | no | Output directory (default: ./batch-results/<batch-id>/) |
| `--csv` | switch | no | Also generate result.csv (lossy display projection) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- result.jsonl:
{"custom_id":"req-001","response":{"request_id":"request-001","status_code":200,"body":{"model":"qwen-plus","choices":[{"message":{"role":"assistant","content":"Hello"}}],"usage":{"prompt_tokens":10,"completion_tokens":2,"total_tokens":12}}},"error":null}
error.jsonl (illustrative envelope; verify with the service):
{"custom_id":"req-002","response":null,"error":{"code":"ExampleError","message":"Example service error"}}
result.csv:
custom_id,model,request_id,status_code,content,embedding,error_code,error_message,prompt_tokens,completion_tokens,total_tokens
req-001,qwen-plus,request-001,200,Hello,,,,10,2,12
req-002,,,,,,ExampleError,Example service error,,,
- JSONL is authoritative; CSV reads only choices[0].message.content, embedding data, response.request_id/status_code, usage and error.code/message (or response.body.error). Unknown envelopes warn. CSV omits tool calls/additional choices and protects formula-like text; import IDs as text to retain leading zeros. No guarantee of original input order. Atomic per file, not per directory; CSV failure preserves downloaded JSONL. Recover by rerunning with --force. Retention is limited; download promptly.
- Dry-run does not call business APIs or write business files. Update checks and telemetry follow framework settings.
#### Examples
```bash
bl batch download --batch-id batch_xxx --out-dir ./out --csv
```
```bash
bl batch download --batch-id batch_xxx --out-dir ./out --csv --force
```
```bash
bl batch download --batch-id batch_xxx --dry-run
```
### `bl batch get`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------- |
| **Name** | `batch get` |
| **Description** | Get Batch task details, optionally following progress |
| **Authentication** | API Key |
| **Usage** | `bl batch get --batch-id <id> [--follow] [--interval <seconds>] [--poll-timeout <seconds>]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------- | ------ | -------- | ----------------------------------------------------------- |
| `--batch-id <id>` | string | yes | Batch task ID |
| `--follow` | switch | no | Poll until terminal state (Ctrl-C stops only local polling) |
| `--interval <seconds>` | number | no | Query interval, min 60s (default: 65s; --follow only) |
| `--poll-timeout <seconds>` | number | no | Total polling budget (default: unlimited; --follow only) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Single get exits 0 after a successful query regardless of task state. --follow exits 0 for completed (may contain failed rows), 1 for failed/expired/cancelled, 5 on client timeout, 130 on Ctrl-C. finalizing/cancelling are not terminal. Progress uses stderr; one final result uses stdout. Query errors are retried at most three times only for transport/timeouts or HTTP 429/5xx. Download results promptly; service retention is limited.
- Dry-run does not call business APIs or write business files. Update checks and telemetry follow framework settings.
#### Examples
```bash
bl batch get --batch-id batch_xxx
```
```bash
bl batch get --batch-id batch_xxx --follow
```
```bash
bl batch get --batch-id batch_xxx --follow --interval 65 --poll-timeout 86400
```
### `bl batch list`
| Field | Value |
| ------------------ | ------------------------------------------------------ |
| **Name** | `batch list` |
| **Description** | List one page of Batch tasks |
| **Authentication** | API Key |
| **Usage** | `bl batch list [filters] [--after <id>] [--limit <n>]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------------------------------------------------------------------------------------- | ------ | -------- | -------------------------------------- |
| `--limit <n>` | number | no | Page size: 1–100 (default: 20) |
| `--after <id>` | string | no | Previous page last_id |
| `--name <text>` | string | no | Task name filter |
| `--input-file-id <id>` | array | no | Input file filter (repeatable, max 20) |
| `--status <validating\|in_progress\|finalizing\|completed\|failed\|expired\|cancelling\|cancelled>` | array | no | Task status filter (repeatable) |
| `--created-after <yyyyMMddHHmmss>` | string | no | Created after API timestamp |
| `--created-before <yyyyMMddHHmmss>` | string | no | Created before API timestamp |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Returns data, last_id and has_more; use --after last_id for the next page. API timestamps are not timezone-converted.
- Dry-run does not call business APIs or write business files. Update checks and telemetry follow framework settings.
#### Examples
```bash
bl batch list --status completed --status failed --limit 20
```
```bash
bl batch list --after batch_xxx --limit 20
```
```bash
bl batch list --created-after 20261001000000 --created-before 20261023235959
```
reference/cmodel.md
# `bl cmodel` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------- |
| `bl cmodel base-models` | Console | List base models that can be imported as custom models |
| `bl cmodel delete` | API Key | Delete a custom model and its Bailian-side import record |
| `bl cmodel get` | API Key | Get details of a custom model (import job) |
| `bl cmodel import` | API Key | Import a custom model from OSS (creates an import job) |
| `bl cmodel list` | API Key | List custom models (import jobs) |
| `bl cmodel watch` | API Key | Probe a custom model's import status (default: single non-blocking fetch). Pass --follow to poll until terminal. |
## Command details
### `bl cmodel base-models`
| Field | Value |
| ------------------ | ------------------------------------------------------ |
| **Name** | `cmodel base-models` |
| **Description** | List base models that can be imported as custom models |
| **Authentication** | Console |
| **Usage** | `bl cmodel base-models` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- The list is returned dynamically by the console API and may change between releases. Import is currently available only in the Beijing region.
#### Examples
```bash
bl cmodel base-models
```
```bash
bl cmodel base-models --console-region cn-beijing
```
```bash
bl cmodel base-models --output json
```
### `bl cmodel delete`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `cmodel delete` |
| **Description** | Delete a custom model and its Bailian-side import record |
| **Authentication** | API Key |
| **Usage** | `bl cmodel delete --job-id <id>` |
| **Risk** | `high` |
| **Risk message** | This permanently deletes the Bailian-side import record and imported model copy; it cannot be undone. OSS source files are not modified. |
> **Agent safety:** Never add `--yes` automatically. On `type="requires_confirmation"`, stop and ask for explicit user confirmation of the same action and scope.
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ---------------------------------------------------- |
| `--job-id <id>` | string | yes | Import job ID returned by `cmodel import` (required) |
| `--yes` | switch | no | Confirm this high-risk operation |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- This command always calls the public DashScope endpoint (https://dashscope.aliyuncs.com) in the Beijing region. The API is not deployed on workspace-specific base URLs (https://<workspace>.cn-beijing.maas.aliyuncs.com, HTTP 404), so the Profile base URL is not used for this request; workspace API keys are accepted.
- Irreversible: the import record and imported model are removed from Bailian and must be imported again to restore. OSS source files are untouched.
- Only SUCCESSED or FAILED jobs can be deleted; deleting a RUNNING job is rejected by the service (OperationDenied) and the error is surfaced verbatim.
#### Examples
```bash
bl cmodel delete --job-id 937b-xxxx
```
```bash
bl cmodel delete --job-id 937b-xxxx --dry-run
```
```bash
# Only after explicit user confirmation:
bl cmodel delete --job-id 937b-xxxx --yes
```
### `bl cmodel get`
| Field | Value |
| ------------------ | ------------------------------------------ |
| **Name** | `cmodel get` |
| **Description** | Get details of a custom model (import job) |
| **Authentication** | API Key |
| **Usage** | `bl cmodel get --job-id <id>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ---------------------------------------------------- |
| `--job-id <id>` | string | yes | Import job ID returned by `cmodel import` (required) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- This command always calls the public DashScope endpoint (https://dashscope.aliyuncs.com) in the Beijing region. The API is not deployed on workspace-specific base URLs (https://<workspace>.cn-beijing.maas.aliyuncs.com, HTTP 404), so the Profile base URL is not used for this request; workspace API keys are accepted.
- FAILED jobs include the server-provided error_code verbatim; the CLI does not translate it.
#### Examples
```bash
bl cmodel get --job-id 937b-xxxx
```
```bash
bl cmodel get --job-id 937b-xxxx --output json
```
### `bl cmodel import`
| Field | Value |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `cmodel import` |
| **Description** | Import a custom model from OSS (creates an import job) |
| **Authentication** | API Key |
| **Usage** | `bl cmodel import --base-model <model> --weight-type <lora\|full> --bucket <bucket> --object-key <dir/> [--display-name <name>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------------------------------------------------------------------ |
| `--base-model <model>` | string | yes | Base model ID used for tuning (required, e.g. qwen3-32b) |
| `--weight-type <lora\|full>` | string | yes | Tuning weight type (required): lora or full |
| `--bucket <bucket>` | string | yes | OSS bucket containing the model files (required) |
| `--object-key <dir/>` | string | yes | OSS directory prefix containing the model files (required, must end with / and not be the bucket root) |
| `--display-name <name>` | string | no | Display name (optional, max 50 characters) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- This command always calls the public DashScope endpoint (https://dashscope.aliyuncs.com) in the Beijing region. The API is not deployed on workspace-specific base URLs (https://<workspace>.cn-beijing.maas.aliyuncs.com, HTTP 404), so the Profile base URL is not used for this request; workspace API keys are accepted.
- After submission, follow the job with `cmodel watch --job-id` and inspect it with `cmodel get` / `cmodel list`.
- The import API is currently available only in the Beijing region; use the console in other regions.
- The source is fixed to OSS in this release. The bucket must be tagged bailian-datahub-access=read, must not use archive/cold-archive/deep-archive storage or SSE-KMS, and the directory must contain the model files required by the platform (e.g. adapter_model.safetensors, adapter_config.json, config.json).
- When a valid console session is available, the base model is checked against the console-supported import list before submission: the ID is normalized to the catalog `model` value, and weight-type is checked against the model's supportTrainTypes (lora requires efficient_sft, full requires sft). Unsupported combinations fail immediately with a usage error. If the console session is missing or expired, the check is skipped with a warning and the import API's final result is authoritative.
- The current product version supports importing LoRA models; submitting weight-type=full may be rejected by the service. The API contract keeps both values, so the CLI does not hide `full`.
#### Examples
```bash
bl cmodel import --base-model qwen3-32b --weight-type lora --bucket my-model-bucket --object-key models/qwen3-32b-lora/
```
```bash
bl cmodel import --base-model qwen3-32b --weight-type lora --bucket my-model-bucket --object-key models/qwen3-32b-lora/ --display-name my-lora
```
```bash
bl cmodel import --base-model qwen3-32b --weight-type lora --bucket my-model-bucket --object-key models/qwen3-32b-lora/ --dry-run
```
### `bl cmodel list`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------------------- |
| **Name** | `cmodel list` |
| **Description** | List custom models (import jobs) |
| **Authentication** | API Key |
| **Usage** | `bl cmodel list [--page <n>] [--page-size <n>] [--status <status>] [--model-name <name>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------------ | ------ | -------- | -------------------------------------------------------------------------- |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 10, max 100) |
| `--status <PENDING\|RUNNING\|SUCCESSED\|FAILED>` | string | no | Filter by status (server-side) |
| `--model-name <name>` | string | no | Filter by the server-generated model identifier (exact match, server-side) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- This command always calls the public DashScope endpoint (https://dashscope.aliyuncs.com) in the Beijing region. The API is not deployed on workspace-specific base URLs (https://<workspace>.cn-beijing.maas.aliyuncs.com, HTTP 404), so the Profile base URL is not used for this request; workspace API keys are accepted.
- status and model-name are server-side filters over the whole result set (not local page filters). FAILED entries include the server-provided error_code.
#### Examples
```bash
bl cmodel list
```
```bash
bl cmodel list --status RUNNING
```
```bash
bl cmodel list --model-name qwen3-32b-offline-20240101-abc1
```
```bash
bl cmodel list --page-size 20
```
### `bl cmodel watch`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------------- |
| **Name** | `cmodel watch` |
| **Description** | Probe a custom model's import status (default: single non-blocking fetch). Pass --follow to poll until terminal. |
| **Authentication** | API Key |
| **Usage** | `bl cmodel watch --job-id <id> [--follow] [--interval <sec>] [--poll-timeout <sec>]` |
#### Flags
| Flag | Type | Required | Description |
| ---------------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `--job-id <id>` | string | yes | Import job ID returned by `cmodel import` (required) |
| `--follow` | switch | no | Block and poll until a terminal state. Without it, a single status probe is performed and the command returns immediately. |
| `--interval <sec>` | number | no | Seconds between polls with --follow (default: 10, min: 1). Ignored without --follow. |
| `--poll-timeout <sec>` | number | no | With --follow, stop polling after this many seconds (default: no limit). Ignored without --follow. |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- This command always calls the public DashScope endpoint (https://dashscope.aliyuncs.com) in the Beijing region. The API is not deployed on workspace-specific base URLs (https://<workspace>.cn-beijing.maas.aliyuncs.com, HTTP 404), so the Profile base URL is not used for this request; workspace API keys are accepted.
- Default (no --follow) is a NON-BLOCKING single status probe for agents/scripts. Terminal statuses are SUCCESSED and FAILED; an unknown server status is surfaced verbatim and treated as non-terminal.
- A terminal FAILED status raises a normal CLI error (non-zero exit) with the server error_code preserved; SUCCEEDED and still-running statuses return 0. With --follow, exceeding --poll-timeout raises a timeout error.
#### Examples
```bash
bl cmodel watch --job-id 937b-xxxx
```
```bash
bl cmodel watch --job-id 937b-xxxx --output json
```
```bash
bl cmodel watch --job-id 937b-xxxx --follow
```
```bash
bl cmodel watch --job-id 937b-xxxx --follow --interval 5 --poll-timeout 3600
```
reference/config.md
# `bl config` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------- | -------------- | ------------------------------------------------ |
| `bl config agent` | No Auth | Configure a coding agent to use DashScope API |
| `bl config list` | No Auth | List config profiles and show the active profile |
| `bl config set` | No Auth | Set a config value |
| `bl config show` | No Auth | Display current configuration |
| `bl config ui` | No Auth | Open a local web UI to manage config profiles |
| `bl config use` | No Auth | Set the active config profile |
## Command details
### `bl config agent`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `config agent` |
| **Description** | Configure a coding agent to use DashScope API |
| **Authentication** | No Auth |
| **Usage** | `bl config agent --agent <name> (--base-url <url> \| --region <region>) (--api-key <key> \| --key <encoded>) --model <model>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------------------------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------- |
| `--agent <claude-code\|qwen-code\|opencode\|openclaw\|hermes\|codex\|pi>` | string | yes | Target agent: claude-code, qwen-code, opencode, openclaw, hermes, codex, pi |
| `--base-url <url>` | string | no | API base URL |
| `--region <region>` | string | no | Model Studio region (e.g. cn-beijing, ap-southeast-1); converted into --base-url. Token Plan only |
| `--api-key <key>` | string | no | API key |
| `--key <encoded>` | string | no | Obfuscated API key from the web console (starts with "o1_"); decoded into --api-key |
| `--model <model>` | string | yes | Default model name |
| `--context-window <tokens>` | number | no | OpenClaw only: model context window in tokens (default: 256000) |
| `--wire-api <chat\|responses>` | string | no | Codex only: wire protocol (default: responses). "chat" only works with legacy Codex <= 0.80.0 |
#### Examples
```bash
bl config agent --agent claude-code --base-url https://dashscope.aliyuncs.com/apps/anthropic --api-key sk-xxxxx --model qwen3-max
```
```bash
bl config agent --agent qwen-code --base-url https://dashscope.aliyuncs.com/compatible-mode/v1 --api-key sk-xxxxx --model qwen3-coder-plus
```
```bash
bl config agent --agent codex --base-url https://dashscope.aliyuncs.com/compatible-mode/v1 --api-key sk-xxxxx --model qwen3-coder-plus
```
### `bl config list`
| Field | Value |
| ------------------ | ------------------------------------------------ |
| **Name** | `config list` |
| **Description** | List config profiles and show the active profile |
| **Authentication** | No Auth |
| **Usage** | `bl config list` |
#### Flags
_No command-specific flags._
#### Examples
```bash
bl config list
```
```bash
bl config list --output json
```
### `bl config set`
| Field | Value |
| ------------------ | ------------------------------------------- |
| **Name** | `config set` |
| **Description** | Set a config value |
| **Authentication** | No Auth |
| **Usage** | `bl config set --key <key> --value <value>` |
#### Flags
| Flag | Type | Required | Description |
| ----------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--key <key>` | string | yes | Config key (language, base_url, output, output_dir, timeout, watermark, api_key, api_key_capabilities, access_token, access_key_id, access_key_secret, security_token, default_*_model, workspace_id) |
| `--value <value>` | string | yes | Value to set |
#### Examples
```bash
bl config set --key language --value zh-CN
```
```bash
bl config set --key output --value json
```
```bash
bl config set --key timeout --value 600
```
```bash
bl config set --key watermark --value false
```
```bash
bl config set --key base_url --value https://dashscope.aliyuncs.com
```
```bash
bl config set --config company-plan --key api-key-capabilities --value text.chat,image.generate
```
### `bl config show`
| Field | Value |
| ------------------ | ----------------------------- |
| **Name** | `config show` |
| **Description** | Display current configuration |
| **Authentication** | No Auth |
| **Usage** | `bl config show` |
#### Flags
_No command-specific flags._
#### Examples
```bash
bl config show
```
```bash
bl config show --output json
```
### `bl config ui`
| Field | Value |
| ------------------ | --------------------------------------------- |
| **Name** | `config ui` |
| **Description** | Open a local web UI to manage config profiles |
| **Authentication** | No Auth |
| **Usage** | `bl config ui [--port <port>] [--no-open]` |
#### Flags
| Flag | Type | Required | Description |
| --------------- | ------ | -------- | --------------------------------------------- |
| `--port <port>` | number | no | Port to listen on (default: random free port) |
| `--no-open` | switch | no | Do not open the browser automatically |
#### Examples
```bash
bl config ui
```
```bash
bl config ui --port 8787
```
```bash
bl config ui --no-open
```
### `bl config use`
| Field | Value |
| ------------------ | ----------------------------- |
| **Name** | `config use` |
| **Description** | Set the active config profile |
| **Authentication** | No Auth |
| **Usage** | `bl config use --name <name>` |
#### Flags
| Flag | Type | Required | Description |
| --------------- | ------ | -------- | --------------------------------- |
| `--name <name>` | string | yes | Existing profile name, or default |
#### Examples
```bash
bl config use --name token-plan
```
```bash
bl config use --name default
```
reference/console.md
# `bl console` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------- | -------------- | ---------------------------------------------- |
| `bl console call` | Console | Call a Bailian console API via the CLI gateway |
## Command details
### `bl console call`
| Field | Value |
| ------------------ | --------------------------------------------------- |
| **Name** | `console call` |
| **Description** | Call a Bailian console API via the CLI gateway |
| **Authentication** | Console |
| **Usage** | `bl console call --api <api> --data <json> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------------------------------------ |
| `--api <api>` | string | yes | API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries) |
| `--data <json>` | string | yes | Request data as JSON string |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl console call --api zeldaEasy.bailian-commerce.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'
```
```bash
bl console call --api some.api.name --data '{"key":"value"}' --console-region cn-beijing
```
reference/decision.md
# `bl decision` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------- | -------------- | ------------------------------------------------------------------------------ |
| `bl decision` | API Key | Run the decision model: typed choice / noul / score answers with probabilities |
## Command details
### `bl decision`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| **Name** | `decision` |
| **Description** | Run the decision model: typed choice / noul / score answers with probabilities |
| **Authentication** | API Key |
| **Usage** | `bl decision (--state <text> \| --state-file <path>) (--questions <json> \| --questions-file <path>) \| --request-file <path>` |
#### Flags
| Flag | Type | Required | Description |
| --------------------------------------- | ------ | -------- | ---------------------------------------------------------------------------------------- |
| `--model <model>` | string | no | Decision model ID (default: decision-model-preview) |
| `--state <text>` | string | no | Business state to decide on, sent as a string |
| `--state-file <path>` | string | no | Read state from a file (.json is parsed as an object/array, others as text; - for stdin) |
| `--questions <json>` | string | no | Question table JSON, keyed by question ID |
| `--questions-file <path>` | string | no | Read the question table from a JSON file ({...} or {"questions":{...}}) |
| `--request-file <path>` | string | no | Full request JSON {state, questions}; label/target are stripped |
| `--workspace-id <id>` | string | no | Workspace ID for the endpoint host (or set BAILIAN_WORKSPACE_ID) |
| `--region <cn-beijing\|ap-southeast-1>` | string | no | Endpoint region: cn-beijing, ap-southeast-1 (default: cn-beijing) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Endpoint: configured --base-url, DASHSCOPE_BASE_URL, or profile base_url takes precedence; otherwise https://{workspace}.{region}.maas.aliyuncs.com/compatible-mode/v1/systemone, with workspace from --workspace-id, BAILIAN_WORKSPACE_ID, then config workspace_id.
- Question types: choice (criteria: option → description, 1-255), noul (optional criteria with true/false descriptions), score (criteria: levels from low to high, 2-255; 3-7 recommended). Keep questions per request at 16 or fewer; latency grows roughly linearly.
- Output defaults to the full JSON response. Use --output text for one human-readable line per question; the request ID and usage summary are written to stderr.
- Training samples can be reused directly: label/target are stripped before sending. Sampling parameters (temperature, max_tokens, ...) are not supported by this API.
#### Examples
```bash
bl decision --workspace-id <id> --state "Is this review asking for a refund?" --questions '{"refund":{"type":"noul","instructions":"Asking for a refund?"}}'
```
```bash
bl decision --state-file ticket.json --questions-file workload.json
```
```bash
bl decision --request-file sample.json --model decision-model-preview
```
```bash
bl decision --region ap-southeast-1 --request-file sample.json
```
```bash
bl decision --request-file sample.json --dry-run
```
reference/file.md
# `bl file` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ---------------- | -------------- | -------------------------------------------------------- |
| `bl file upload` | API Key | Upload a local file to DashScope temporary storage (48h) |
## Command details
### `bl file upload`
| Field | Value |
| ------------------ | -------------------------------------------------------- |
| **Name** | `file upload` |
| **Description** | Upload a local file to DashScope temporary storage (48h) |
| **Authentication** | API Key |
| **Usage** | `bl file upload --file <path> --model <model>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ----------------------------------------------- |
| `--file <path>` | string | yes | Local file to upload (image, video, audio) |
| `--model <model>` | string | yes | Target model name (file is bound to this model) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Examples
```bash
bl file upload --file photo.jpg --model qwen3-vl-plus
```
```bash
bl file upload --file video.mp4 --model wan2.1-t2v-plus
```
```bash
bl file upload --file audio.wav --model qwen3-asr-flash
```
```bash
bl file upload --file cat.png --model qwen-image-3.0
```
reference/index.md
# `bailian-cli` command reference
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Command **details** are in sibling `<group>.md` files in this directory.
This index only covers groups owned by this skill. Other `bl` groups live in sibling bailian-* skills.
Use this index for the skill-scoped quick index and global flags.
## Quick index
| Command | Authentication | Description | Detail |
| ------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
| `bl advisor recommend` | API Key | Recommend the best models for your use case (intent → routing → recall → score → rank, with agent clarification) | [advisor.md](advisor.md) |
| `bl agents security alerts` | API Key | List Agent security alerts | [agents.md](agents.md) |
| `bl agents security overview` | API Key | Show the Agent security protection overview (last 24 hours) | [agents.md](agents.md) |
| `bl alert create` | Console | Create a model alert rule from an alert template | [alert.md](alert.md) |
| `bl alert delete` | Console | Delete model alert rules | [alert.md](alert.md) |
| `bl alert disable` | Console | Disable a model alert rule (keeps the rule, stops notifications) | [alert.md](alert.md) |
| `bl alert enable` | Console | Enable a model alert rule | [alert.md](alert.md) |
| `bl alert history` | Console | List model alert history (firing and recovered events) | [alert.md](alert.md) |
| `bl alert list` | Console | List model alert rules | [alert.md](alert.md) |
| `bl alert metrics` | Console | List metrics that alert rules can be created on, with supported aggregations | [alert.md](alert.md) |
| `bl alert template create` | Console | Create a custom alert template (or copy an official one with --from) | [alert.md](alert.md) |
| `bl alert template delete` | Console | Delete custom alert templates (official templates cannot be deleted) | [alert.md](alert.md) |
| `bl alert template list` | Console | List alert templates (official and custom); pass --template-id for details | [alert.md](alert.md) |
| `bl alert template update` | Console | Update a custom alert template (full replacement of conditions) | [alert.md](alert.md) |
| `bl alert update` | Console | Update a model alert rule (full replacement; same fields as create) | [alert.md](alert.md) |
| `bl app call` | API Key | Call a Bailian application (agent or workflow) | [app.md](app.md) |
| `bl app list` | Console | List Bailian applications | [app.md](app.md) |
| `bl auth generate-access-token` | No Auth | Generate a CLI access token using OpenAPI AK/SK | [auth.md](auth.md) |
| `bl auth login` | No Auth | Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist) | [auth.md](auth.md) |
| `bl auth logout` | No Auth | Clear stored credentials; full logout also clears the model Base URL | [auth.md](auth.md) |
| `bl auth status` | No Auth | Show current authentication state | [auth.md](auth.md) |
| `bl batch cancel` | API Key | Request cancellation of a Batch task | [batch.md](batch.md) |
| `bl batch convert` | No Auth | Build Batch JSONL from CSV locally | [batch.md](batch.md) |
| `bl batch create` | API Key | Upload or reference input and create an asynchronous Batch task | [batch.md](batch.md) |
| `bl batch download` | API Key | Download original Batch results/errors, optionally export CSV | [batch.md](batch.md) |
| `bl batch get` | API Key | Get Batch task details, optionally following progress | [batch.md](batch.md) |
| `bl batch list` | API Key | List one page of Batch tasks | [batch.md](batch.md) |
| `bl cmodel base-models` | Console | List base models that can be imported as custom models | [cmodel.md](cmodel.md) |
| `bl cmodel delete` | API Key | Delete a custom model and its Bailian-side import record | [cmodel.md](cmodel.md) |
| `bl cmodel get` | API Key | Get details of a custom model (import job) | [cmodel.md](cmodel.md) |
| `bl cmodel import` | API Key | Import a custom model from OSS (creates an import job) | [cmodel.md](cmodel.md) |
| `bl cmodel list` | API Key | List custom models (import jobs) | [cmodel.md](cmodel.md) |
| `bl cmodel watch` | API Key | Probe a custom model's import status (default: single non-blocking fetch). Pass --follow to poll until terminal. | [cmodel.md](cmodel.md) |
| `bl config agent` | No Auth | Configure a coding agent to use DashScope API | [config.md](config.md) |
| `bl config list` | No Auth | List config profiles and show the active profile | [config.md](config.md) |
| `bl config set` | No Auth | Set a config value | [config.md](config.md) |
| `bl config show` | No Auth | Display current configuration | [config.md](config.md) |
| `bl config ui` | No Auth | Open a local web UI to manage config profiles | [config.md](config.md) |
| `bl config use` | No Auth | Set the active config profile | [config.md](config.md) |
| `bl console call` | Console | Call a Bailian console API via the CLI gateway | [console.md](console.md) |
| `bl decision` | API Key | Run the decision model: typed choice / noul / score answers with probabilities | [decision.md](decision.md) |
| `bl file upload` | API Key | Upload a local file to DashScope temporary storage (48h) | [file.md](file.md) |
| `bl log audit count` | Console | Count model audit logs in a time range (useful before exporting) | [log.md](log.md) |
| `bl log audit disable` | Console | Disable audit log delivery for all models in the workspace | [log.md](log.md) |
| `bl log audit enable` | Console | Enable audit log delivery to SLS (SLR authorization → SLS instance → log switch) | [log.md](log.md) |
| `bl log audit get` | Console | Show a single audit log entry with its raw origin record | [log.md](log.md) |
| `bl log audit list` | Console | Query model audit logs (call metadata; request/response content is not recorded) | [log.md](log.md) |
| `bl log inference count` | Console | Count model inference logs in a time range (useful before exporting) | [log.md](log.md) |
| `bl log inference disable` | Console | Disable inference log delivery for all models in the workspace | [log.md](log.md) |
| `bl log inference enable` | Console | Enable inference log delivery to SLS (SLR authorization → SLS instance → log switch) | [log.md](log.md) |
| `bl log inference get` | Console | Show a single inference log entry with full request/response content | [log.md](log.md) |
| `bl log inference list` | Console | Query model inference logs (requires inference log delivery; use `log inference get` for request/response content) | [log.md](log.md) |
| `bl log status` | Console | Show model log delivery status (SLS authorization, audit / inference service and switches) | [log.md](log.md) |
| `bl log trace get` | Console | Show a single call trace with its span tree | [log.md](log.md) |
| `bl log trace list` | Console | List call traces for a model or app | [log.md](log.md) |
| `bl log trace stats` | Console | Show per-resource trace statistics (calls, tokens, latency) | [log.md](log.md) |
| `bl mcp call` | API Key | Call a tool on an MCP server (tools/call) | [mcp.md](mcp.md) |
| `bl mcp connect` | API Key | Register a Bailian MCP server in an Agent's native configuration | [mcp.md](mcp.md) |
| `bl mcp disconnect` | No Auth | Remove an unchanged MCP registration previously managed by bailian-cli | [mcp.md](mcp.md) |
| `bl mcp list` | Console | List MCP servers activated under your Bailian account | [mcp.md](mcp.md) |
| `bl mcp tools` | API Key | List tools exposed by an MCP server (tools/list) | [mcp.md](mcp.md) |
| `bl model code` | No Auth | Print a ready-to-run SDK sample for calling a model | [model.md](model.md) |
| `bl model list` | No Auth | Browse model families or show detailed model info in the Bailian model marketplace | [model.md](model.md) |
| `bl model search` | No Auth | Search the model catalog by keyword, ranked by relevance | [model.md](model.md) |
| `bl monitor delivery disable` | Console | Disable monitor delivery for all models in the workspace | [monitor.md](monitor.md) |
| `bl monitor delivery enable` | Console | Activate monitoring delivery: CMS SLR authorization, CMS service, and the dedicated Prometheus instance | [monitor.md](monitor.md) |
| `bl monitor delivery status` | Console | Show monitoring delivery (Prometheus instance) status | [monitor.md](monitor.md) |
| `bl monitor errors` | Console | Show failure breakdown by HTTP status code and error code | [monitor.md](monitor.md) |
| `bl monitor metrics` | Console | Query time-series monitor metrics (RPM/TPM, latency percentiles, token usage) | [monitor.md](monitor.md) |
| `bl monitor models` | Console | List per-model / per-API-key call statistics with server-side sort and paging | [monitor.md](monitor.md) |
| `bl monitor overview` | Console | Show aggregated model call statistics (calls, failures, latency, token usage) | [monitor.md](monitor.md) |
| `bl parsex extract result` | API Key | Query ParseX extraction status, fields and citations | [parsex.md](parsex.md) |
| `bl parsex extract submit` | API Key | Submit ParseX structured field extraction | [parsex.md](parsex.md) |
| `bl parsex parse result` | API Key | Query ParseX parsing status, results or a result slice | [parsex.md](parsex.md) |
| `bl parsex parse submit` | API Key | Submit a ParseX document or media parsing task | [parsex.md](parsex.md) |
| `bl permission grant` | API Key | Grant model permissions (inference / finetune / deploy) | [permission.md](permission.md) |
| `bl permission list` | API Key | List model permissions (inference / fine-tune / deploy) in the workspace | [permission.md](permission.md) |
| `bl permission revoke` | API Key | Revoke model permissions (inference / finetune / deploy) | [permission.md](permission.md) |
| `bl pipeline run` | No Auth | Run a pipeline workflow definition | [pipeline.md](pipeline.md) |
| `bl pipeline validate` | No Auth | Validate a pipeline definition without executing | [pipeline.md](pipeline.md) |
| `bl plugin install` | No Auth | Install or upgrade an allowlisted Command Pack | [plugin.md](plugin.md) |
| `bl plugin link` | No Auth | Link an allowlisted local Command Pack for development | [plugin.md](plugin.md) |
| `bl plugin list` | No Auth | List installed Command Packs and their load status | [plugin.md](plugin.md) |
| `bl plugin remove` | No Auth | Remove an installed Command Pack | [plugin.md](plugin.md) |
| `bl quota check` | Console | Check current usage against rate limits | [quota.md](quota.md) |
| `bl quota delete` | API Key | Clear all custom rate limits (QPM/TPM) for a model | [quota.md](quota.md) |
| `bl quota history` | Console | View quota change history | [quota.md](quota.md) |
| `bl quota list` | API Key | View model rate limits (QPM/TPM, account and workspace level) | [quota.md](quota.md) |
| `bl quota update` | API Key | Update model rate limits (QPM/TPM) | [quota.md](quota.md) |
| `bl search web` | API Key | Search the web via a chat model with built-in web search (default) or the DashScope MCP WebSearch service | [search.md](search.md) |
| `bl skill add` | No Auth | Install skills from the Bailian skill registry into local agents | [skill.md](skill.md) |
| `bl skill init` | No Auth | Install all bailian-* skills (one-shot bootstrap for new environments) | [skill.md](skill.md) |
| `bl skill list` | No Auth | List registry skills and diff against local installs | [skill.md](skill.md) |
| `bl skill remove` | No Auth | Remove locally installed skills (registry is untouched) | [skill.md](skill.md) |
| `bl skill update` | No Auth | Update installed skills to the latest registry versions | [skill.md](skill.md) |
| `bl text chat` | API Key | Send a text model request (OpenAI compatible, DashScope) | [text.md](text.md) |
| `bl token-plan add-member` | AK/SK | Add a member to a Token Plan organization | [token-plan.md](token-plan.md) |
| `bl token-plan assign-seats` | AK/SK | Batch assign Token Plan seats to members | [token-plan.md](token-plan.md) |
| `bl token-plan create-key` | AK/SK | Create a Token Plan API key for a seat | [token-plan.md](token-plan.md) |
| `bl token-plan harness-quota` | Console | Show Token Plan harness entitlement quota usage | [token-plan.md](token-plan.md) |
| `bl token-plan list-seats` | AK/SK | List Token Plan subscription seat details | [token-plan.md](token-plan.md) |
| `bl update` | No Auth | Update the CLI to the latest or a specified version | [update.md](update.md) |
| `bl usage coding-plan` | Console | Show Coding Plan quota usage | [usage.md](usage.md) |
| `bl usage free` | Console | Query free-tier quota for models (all models if --model is omitted) | [usage.md](usage.md) |
| `bl usage freetier` | Console | Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable | [usage.md](usage.md) |
| `bl usage stats` | Console | Query model usage statistics | [usage.md](usage.md) |
| `bl usage summary` | Console | Show a unified usage summary: free-tier quota and recent usage overview | [usage.md](usage.md) |
| `bl usage token-plan` | Console | Show Token Plan quota usage | [usage.md](usage.md) |
| `bl workspace init` | No Auth | Initialize Bailian workspace and activate postpaid services | [workspace.md](workspace.md) |
| `bl workspace list` | Console | List all workspaces | [workspace.md](workspace.md) |
## By group
| Group | Commands | Reference |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| `advisor` | `recommend` | [advisor.md](advisor.md) |
| `agents` | `security alerts`, `security overview` | [agents.md](agents.md) |
| `alert` | `create`, `delete`, `disable`, `enable`, `history`, `list`, `metrics`, `template create`, `template delete`, `template list`, `template update`, `update` | [alert.md](alert.md) |
| `app` | `call`, `list` | [app.md](app.md) |
| `auth` | `generate-access-token`, `login`, `logout`, `status` | [auth.md](auth.md) |
| `batch` | `cancel`, `convert`, `create`, `download`, `get`, `list` | [batch.md](batch.md) |
| `cmodel` | `base-models`, `delete`, `get`, `import`, `list`, `watch` | [cmodel.md](cmodel.md) |
| `config` | `agent`, `list`, `set`, `show`, `ui`, `use` | [config.md](config.md) |
| `console` | `call` | [console.md](console.md) |
| `decision` | `(root)` | [decision.md](decision.md) |
| `file` | `upload` | [file.md](file.md) |
| `log` | `audit count`, `audit disable`, `audit enable`, `audit get`, `audit list`, `inference count`, `inference disable`, `inference enable`, `inference get`, `inference list`, `status`, `trace get`, `trace list`, `trace stats` | [log.md](log.md) |
| `mcp` | `call`, `connect`, `disconnect`, `list`, `tools` | [mcp.md](mcp.md) |
| `model` | `code`, `list`, `search` | [model.md](model.md) |
| `monitor` | `delivery disable`, `delivery enable`, `delivery status`, `errors`, `metrics`, `models`, `overview` | [monitor.md](monitor.md) |
| `parsex` | `extract result`, `extract submit`, `parse result`, `parse submit` | [parsex.md](parsex.md) |
| `permission` | `grant`, `list`, `revoke` | [permission.md](permission.md) |
| `pipeline` | `run`, `validate` | [pipeline.md](pipeline.md) |
| `plugin` | `install`, `link`, `list`, `remove` | [plugin.md](plugin.md) |
| `quota` | `check`, `delete`, `history`, `list`, `update` | [quota.md](quota.md) |
| `search` | `web` | [search.md](search.md) |
| `skill` | `add`, `init`, `list`, `remove`, `update` | [skill.md](skill.md) |
| `text` | `chat` | [text.md](text.md) |
| `token-plan` | `add-member`, `assign-seats`, `create-key`, `harness-quota`, `list-seats` | [token-plan.md](token-plan.md) |
| `update` | `(root)` | [update.md](update.md) |
| `usage` | `coding-plan`, `free`, `freetier`, `stats`, `summary`, `token-plan` | [usage.md](usage.md) |
| `workspace` | `init`, `list` | [workspace.md](workspace.md) |
## Global flags
Available on every command (in addition to command-specific flags):
| Flag | Type | Required | Description |
| --------------------- | ------ | -------- | --------------------------------------------------------- |
| `--introspect` | switch | no | Print the machine-readable command schema (JSON) and exit |
| `--output <format>` | string | no | Output format: text, json |
| `--timeout <seconds>` | number | no | Request timeout |
| `--quiet` | switch | no | Suppress non-essential output |
| `--verbose` | switch | no | Print HTTP request/response details |
| `--dry-run` | switch | no | Dry run mode |
| `--config <name>` | string | no | Use a config profile for this command |
| `--help` | switch | no | Show help |
| `--version` | switch | no | Print version |
## Model auth flags
Available on model-domain commands (API-key auth); also listed per command below:
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ------------ |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
## Console auth flags
Available on console-domain commands (console login auth); also listed per command below:
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
## OpenAPI auth flags
Available on OpenAPI-domain commands (AK/SK auth); also listed per command below:
| Flag | Type | Required | Description |
| --------------------------- | ------ | -------- | ---------------------------------------------------------------------- |
| `--access-key-id <key>` | string | no | Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID) |
| `--access-key-secret <key>` | string | no | Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET) |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN) |
## Notes
- Console commands (`app list`, `usage free`, `console call`) require `bl auth login --console`.
- Most API commands use `DASHSCOPE_API_KEY` or `bl auth login --api-key`.
- Token Plan commands use OpenAPI AK/SK via `bl auth login --open-api` or `ALIBABA_CLOUD_ACCESS_KEY_ID` / `ALIBABA_CLOUD_ACCESS_KEY_SECRET`.
- Default output: **text** unless explicitly set to `json` with `--output`, `DASHSCOPE_OUTPUT`, or config.
reference/log.md
# `bl log` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| -------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------ |
| `bl log audit count` | Console | Count model audit logs in a time range (useful before exporting) |
| `bl log audit disable` | Console | Disable audit log delivery for all models in the workspace |
| `bl log audit enable` | Console | Enable audit log delivery to SLS (SLR authorization → SLS instance → log switch) |
| `bl log audit get` | Console | Show a single audit log entry with its raw origin record |
| `bl log audit list` | Console | Query model audit logs (call metadata; request/response content is not recorded) |
| `bl log inference count` | Console | Count model inference logs in a time range (useful before exporting) |
| `bl log inference disable` | Console | Disable inference log delivery for all models in the workspace |
| `bl log inference enable` | Console | Enable inference log delivery to SLS (SLR authorization → SLS instance → log switch) |
| `bl log inference get` | Console | Show a single inference log entry with full request/response content |
| `bl log inference list` | Console | Query model inference logs (requires inference log delivery; use `log inference get` for request/response content) |
| `bl log status` | Console | Show model log delivery status (SLS authorization, audit / inference service and switches) |
| `bl log trace get` | Console | Show a single call trace with its span tree |
| `bl log trace list` | Console | List call traces for a model or app |
| `bl log trace stats` | Console | Show per-resource trace statistics (calls, tokens, latency) |
## Command details
### `bl log audit count`
| Field | Value |
| ------------------ | ---------------------------------------------------------------- |
| **Name** | `log audit count` |
| **Description** | Count model audit logs in a time range (useful before exporting) |
| **Authentication** | Console |
| **Usage** | `bl log audit count [--model <model>] [--hours <n>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Uses the audit list API's totalCount for the selected time range and filters. Fetches at most one metadata row per response, without full request/response content or pagination.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log audit count
```
```bash
bl log audit count --model qwen3.6-plus --hours 24
```
```bash
bl log audit count --workspace-id ws-example --hours 144
```
```bash
bl log audit count --output json
```
### `bl log audit disable`
| Field | Value |
| ------------------ | ---------------------------------------------------------- |
| **Name** | `log audit disable` |
| **Description** | Disable audit log delivery for all models in the workspace |
| **Authentication** | Console |
| **Usage** | `bl log audit disable [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Refused while the inference log is still enabled — disable the inference log first (the console enforces the same rule).
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log audit disable
```
```bash
bl log audit disable --dry-run
```
```bash
bl log audit disable --output json
```
### `bl log audit enable`
| Field | Value |
| ------------------ | -------------------------------------------------------------------------------- |
| **Name** | `log audit enable` |
| **Description** | Enable audit log delivery to SLS (SLR authorization → SLS instance → log switch) |
| **Authentication** | Console |
| **Usage** | `bl log audit enable [--no-wait] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------------------------------- |
| `--no-wait` | switch | no | Return right after submitting, without waiting for the SLS instance |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Steps: 1) authorize the SLS service-linked role, 2) initialize the SLS store instance (async), 3) turn on audit log delivery for all models in the workspace.
- The audit log records call metadata only and is required before enabling the inference log.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log audit enable
```
```bash
bl log audit enable --no-wait
```
```bash
bl log audit enable --output json
```
### `bl log audit get`
| Field | Value |
| ------------------ | -------------------------------------------------------- |
| **Name** | `log audit get` |
| **Description** | Show a single audit log entry with its raw origin record |
| **Authentication** | Console |
| **Usage** | `bl log audit get --request-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--request-id <id>` | string | yes | Model request ID (from `log audit list`) |
| `--model <model>` | string | no | Model name (narrows the search) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Audit entries carry call metadata plus the raw audit record; request/response content lives in the inference log (`log inference get`).
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log audit get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```
```bash
bl log audit get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx --hours 24
```
```bash
bl log audit get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx --workspace-id ws-example
```
```bash
bl log audit get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx --output json
```
### `bl log audit list`
| Field | Value |
| ------------------ | -------------------------------------------------------------------------------- |
| **Name** | `log audit list` |
| **Description** | Query model audit logs (call metadata; request/response content is not recorded) |
| **Authentication** | Console |
| **Usage** | `bl log audit list [--model <model>] [--hours <n>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------------------- | ------ | -------- | ------------------------------------------------------------------------------ |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--channel <channel>` | string | no | Call channel(s), comma-separated |
| `--source <source>` | string | no | Call source(s), comma-separated |
| `--call-source <Online\|Offline>` | string | no | Inference type: Online, Offline |
| `--request-id <id>` | string | no | Exact model request ID |
| `--status-code <type>` | string | no | Status filter(s), comma-separated: SUCCESS, CLIENT_ERROR, SERVER_ERROR, CANCEL |
| `--max-results <n>` | number | no | Rows per page (default: 20) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--next-token <token>` | string | no | Pagination token from a previous response |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Audit logs carry call metadata only. For full request/response content, enable and query the inference log (`log inference list` / `log inference get`).
- Use --call-source Online to match the console's online inference filter.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log audit list
```
```bash
bl log audit list --model qwen3.6-plus --hours 3
```
```bash
bl log audit list --workspace-id ws-example --hours 144
```
```bash
bl log audit list --status-code SERVER_ERROR,CLIENT_ERROR
```
```bash
bl log audit list --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```
```bash
bl log audit list --output json
```
### `bl log inference count`
| Field | Value |
| ------------------ | -------------------------------------------------------------------- |
| **Name** | `log inference count` |
| **Description** | Count model inference logs in a time range (useful before exporting) |
| **Authentication** | Console |
| **Usage** | `bl log inference count [--model <model>] [--hours <n>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Uses the inference list API's totalCount for the selected time range and filters. Fetches at most one metadata row per response, without full request/response content or pagination.
- Comma-separated models and API key IDs are deduplicated, then queried sequentially as single-model/single-key combinations. The counts are summed only after every query succeeds.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log inference count
```
```bash
bl log inference count --model qwen3.6-plus --hours 24
```
```bash
bl log inference count --model qwen3.6-plus,qwen3.6-flash --hours 144
```
```bash
bl log inference count --output json
```
### `bl log inference disable`
| Field | Value |
| ------------------ | -------------------------------------------------------------- |
| **Name** | `log inference disable` |
| **Description** | Disable inference log delivery for all models in the workspace |
| **Authentication** | Console |
| **Usage** | `bl log inference disable [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Only the inference log (request/response content) is disabled; the audit log keeps its own switch (`log audit disable`).
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log inference disable
```
```bash
bl log inference disable --dry-run
```
```bash
bl log inference disable --output json
```
### `bl log inference enable`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------ |
| **Name** | `log inference enable` |
| **Description** | Enable inference log delivery to SLS (SLR authorization → SLS instance → log switch) |
| **Authentication** | Console |
| **Usage** | `bl log inference enable [--no-wait] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------------------------------- |
| `--no-wait` | switch | no | Return right after submitting, without waiting for the SLS instance |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Steps: 1) authorize the SLS service-linked role, 2) initialize the SLS store instance (async), 3) turn on inference log delivery for all models in the workspace.
- Requires the audit log to be enabled first (`log audit enable`) — the console enforces the same rule.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log inference enable
```
```bash
bl log inference enable --no-wait
```
```bash
bl log inference enable --output json
```
### `bl log inference get`
| Field | Value |
| ------------------ | -------------------------------------------------------------------- |
| **Name** | `log inference get` |
| **Description** | Show a single inference log entry with full request/response content |
| **Authentication** | Console |
| **Usage** | `bl log inference get --request-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--request-id <id>` | string | yes | Model request ID (from `log inference list`) |
| `--model <model>` | string | no | Model name (narrows the search) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- The origin content is fetched back by request ID from the inference log store, so inference log delivery must have been enabled when the call happened.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log inference get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```
```bash
bl log inference get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx --hours 24
```
```bash
bl log inference get --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx --output json
```
### `bl log inference list`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ |
| **Name** | `log inference list` |
| **Description** | Query model inference logs (requires inference log delivery; use `log inference get` for request/response content) |
| **Authentication** | Console |
| **Usage** | `bl log inference list [--model <model>] [--hours <n>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------------------- | ------ | -------- | ------------------------------------------------------------------------------ |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name (the inference log API accepts a single model) |
| `--api-key-id <id>` | string | no | API key ID (the inference log API accepts a single ID) |
| `--call-source <Online\|Offline>` | string | no | Inference type: Online, Offline |
| `--request-id <id>` | string | no | Exact model request ID |
| `--status-code <type>` | string | no | Status filter(s), comma-separated: SUCCESS, CLIENT_ERROR, SERVER_ERROR, CANCEL |
| `--max-results <n>` | number | no | Rows per page (default: 20) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Requires inference log delivery (`log inference enable`), which itself requires the audit log. Entries here mirror the audit trail; full request/response content is fetched per request via `log inference get`.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log inference list
```
```bash
bl log inference list --model qwen3.6-plus --hours 3
```
```bash
bl log inference list --status-code SERVER_ERROR,CLIENT_ERROR
```
```bash
bl log inference list --request-id 6f6b2f1e-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```
```bash
bl log inference list --output json
```
### `bl log status`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------ |
| **Name** | `log status` |
| **Description** | Show model log delivery status (SLS authorization, audit / inference service and switches) |
| **Authentication** | Console |
| **Usage** | `bl log status [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Both log kinds have independent switches; the inference log additionally requires the audit log to stay on.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log status
```
```bash
bl log status --output json
```
### `bl log trace get`
| Field | Value |
| ------------------ | ------------------------------------------- |
| **Name** | `log trace get` |
| **Description** | Show a single call trace with its span tree |
| **Authentication** | Console |
| **Usage** | `bl log trace get --trace-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--trace-id <id>` | string | yes | Trace ID (from `log trace list`) |
| `--resource-id <id>` | string | no | Model name or app ID (narrows the search) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log trace get --trace-id 0a1b2c3d4e5f --hours 24
```
```bash
bl log trace get --trace-id 0a1b2c3d4e5f --resource-id qwen3.6-plus
```
```bash
bl log trace get --trace-id 0a1b2c3d4e5f --output json
```
### `bl log trace list`
| Field | Value |
| ------------------ | ---------------------------------------------- |
| **Name** | `log trace list` |
| **Description** | List call traces for a model or app |
| **Authentication** | Console |
| **Usage** | `bl log trace list --resource-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--resource-id <id>` | string | yes | Model name or app ID to query traces for |
| `--resource-type <model\|app>` | string | no | Resource type: model, app (default: model) |
| `--max-results <n>` | number | no | Rows per page (default: 20) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log trace list --resource-id qwen3.6-plus
```
```bash
bl log trace list --resource-id qwen3.6-plus --hours 24 --max-results 50
```
```bash
bl log trace list --resource-id 123456 --resource-type app --output json
```
### `bl log trace stats`
| Field | Value |
| ------------------ | ----------------------------------------------------------- |
| **Name** | `log trace stats` |
| **Description** | Show per-resource trace statistics (calls, tokens, latency) |
| **Authentication** | Console |
| **Usage** | `bl log trace stats [--resource-id <id>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | --------------------------------------------------------- |
| `--hours <hours>` | number | no | Hours to look back (default: 1) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--resource-id <id>` | string | no | Model name(s) or app ID(s), comma-separated; omit for all |
| `--resource-type <model\|app>` | string | no | Resource type: model, app (default: model) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl log trace stats
```
```bash
bl log trace stats --resource-id qwen3.6-plus --hours 24
```
```bash
bl log trace stats --resource-type app --output json
```
reference/mcp.md
# `bl mcp` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------------- | -------------- | ---------------------------------------------------------------------- |
| `bl mcp call` | API Key | Call a tool on an MCP server (tools/call) |
| `bl mcp connect` | API Key | Register a Bailian MCP server in an Agent's native configuration |
| `bl mcp disconnect` | No Auth | Remove an unchanged MCP registration previously managed by bailian-cli |
| `bl mcp list` | Console | List MCP servers activated under your Bailian account |
| `bl mcp tools` | API Key | List tools exposed by an MCP server (tools/list) |
## Command details
### `bl mcp call`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------------- |
| **Name** | `mcp call` |
| **Description** | Call a tool on an MCP server (tools/call) |
| **Authentication** | API Key |
| **Usage** | `bl mcp call --target <server.tool> [--arg k=v ...] [--json '{...}'] [--url <url>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------ | ------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| `--target <server.tool>` | string | yes | Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection |
| `--arg <kv>` | array | no | Tool argument (repeatable). Values parsed as JSON if possible, else string. |
| `--json <obj>` | string | no | Full arguments object as JSON; merged with --arg (arg wins). |
| `--query <text>` | string | no | Shortcut for --arg query=<text> (mirrors many DashScope MCP tools). |
| `--url <url>` | string | no | Override the MCP endpoint URL (non-Bailian). Tries Streamable HTTP first, then classic SSE on the same URL. |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Examples
```bash
bl mcp call --target market-cmapi00073529.SmartStockSelection --query "Screen consumer stocks with ROE > 15%"
```
```bash
bl mcp call --target market-cmapi00073529.FinQuery --json '{"q":"Guizhou Maotai","limit":5}'
```
```bash
bl mcp call --target market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg minScale=10
```
### `bl mcp connect`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------- |
| **Name** | `mcp connect` |
| **Description** | Register a Bailian MCP server in an Agent's native configuration |
| **Authentication** | API Key |
| **Usage** | `bl mcp connect --server <code> --transport <streamable-http\|sse> --agent <agent\|all>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--server <code>` | string | yes | Bailian MCP Server Code, such as TextGenerateImage |
| `--transport <streamable-http\|sse>` | string | yes | MCP transport exposed by the server: streamable-http or sse |
| `--agent <codex\|claude-code\|cursor\|qoder\|qoderwork\|qwenwork\|qwen-code\|gemini\|opencode\|openclaw\|deepseek-harness\|zcode\|workbuddy\|pi\|all>` | string | yes | Target Agent: codex, claude-code, cursor, qoder, qoderwork, qwenwork, qwen-code, gemini, opencode, openclaw, deepseek-harness, zcode, workbuddy, pi, all |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- This release registers the official China-site MCP endpoint; the model API --base-url does not change the MCP endpoint.
- The resolved API key is written to the selected Agent's private local configuration. Existing unmanaged entries are never overwritten.
- qoder, qoderwork, and qwenwork are independent products. qwenwork is QwenWork (千问办公); qoderwork is Qoder Work.
- workbuddy covers CodeBuddy / WorkBuddy. deepseek-harness is DeepSeek Harness and only accepts streamable-http.
#### Examples
```bash
bl mcp connect --server TextGenerateImage --transport streamable-http --agent cursor
```
```bash
bl mcp connect --server VideoGenerate --transport sse --agent claude-code
```
```bash
bl mcp connect --server TextGenerateImage --transport streamable-http --agent all
```
### `bl mcp disconnect`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------- |
| **Name** | `mcp disconnect` |
| **Description** | Remove an unchanged MCP registration previously managed by bailian-cli |
| **Authentication** | No Auth |
| **Usage** | `bl mcp disconnect --server <code> --agent <agent\|all>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--server <code>` | string | yes | Bailian MCP Server Code used during connect |
| `--agent <codex\|claude-code\|cursor\|qoder\|qoderwork\|qwenwork\|qwen-code\|gemini\|opencode\|openclaw\|deepseek-harness\|zcode\|workbuddy\|pi\|all>` | string | yes | Target Agent: codex, claude-code, cursor, qoder, qoderwork, qwenwork, qwen-code, gemini, opencode, openclaw, deepseek-harness, zcode, workbuddy, pi, all |
#### Notes
- A registration changed after connect is left untouched and reported as a conflict.
#### Examples
```bash
bl mcp disconnect --server TextGenerateImage --agent cursor
```
```bash
bl mcp disconnect --server TextGenerateImage --agent all
```
### `bl mcp list`
| Field | Value |
| ------------------ | ----------------------------------------------------- |
| **Name** | `mcp list` |
| **Description** | List MCP servers activated under your Bailian account |
| **Authentication** | Console |
| **Usage** | `bl mcp list [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--name <text>` | string | no | Filter by server name (substring match) |
| `--type <type>` | string | no | Server type: OFFICIAL \| PRIVATE (default: OFFICIAL) |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 30) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl mcp list
```
```bash
bl mcp list --name finance
```
```bash
bl mcp list --output json
```
### `bl mcp tools`
| Field | Value |
| ------------------ | ------------------------------------------------ |
| **Name** | `mcp tools` |
| **Description** | List tools exposed by an MCP server (tools/list) |
| **Authentication** | API Key |
| **Usage** | `bl mcp tools --server <code> [--url <url>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| `--server <code>` | string | yes | Server code from `mcp list` (e.g. market-cmapi00073529) |
| `--url <url>` | string | no | Override the MCP endpoint URL (non-Bailian). Tries Streamable HTTP first, then classic SSE on the same URL. |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Examples
```bash
bl mcp tools --server market-cmapi00073529
```
```bash
bl mcp tools --server market-cmapi00073529 --output json
```
```bash
bl mcp tools --server my-server --url https://example.com/mcp
```
reference/model.md
# `bl model` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------- | -------------- | ---------------------------------------------------------------------------------- |
| `bl model code` | No Auth | Print a ready-to-run SDK sample for calling a model |
| `bl model list` | No Auth | Browse model families or show detailed model info in the Bailian model marketplace |
| `bl model search` | No Auth | Search the model catalog by keyword, ranked by relevance |
## Command details
### `bl model code`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------- |
| **Name** | `model code` |
| **Description** | Print a ready-to-run SDK sample for calling a model |
| **Authentication** | No Auth |
| **Usage** | `bl model code --model <model> [--sdk <sdk>] [--api <style>] [--lang <lang>]` |
#### Flags
| Flag | Type | Required | Description |
| ----------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------- |
| `--model <model>` | string | yes | Model to generate a sample for |
| `--sdk <sdk>` | string | no | SDK flavour: openai (default) or dashscope |
| `--api <style>` | string | no | API style: completions (default) or responses; ignored when the SDK has one style |
| `--lang <lang>` | string | no | Language of the snippet (default: python). Published per model — pass an unsupported value to list them |
#### Notes
- Text output is the snippet alone, so it can be redirected straight into a file. Use --output json for the snippet plus its metadata.
- Samples use a `[workspace-id]` placeholder in the base URL — replace it, or set BAILIAN_WORKSPACE_ID and use the DashScope endpoint.
- Available combinations are published per model; pass an unknown value to see the list for that model.
#### Examples
```bash
bl model code --model qwen-max
```
```bash
bl model code --model qwen-max --lang curl
```
```bash
bl model code --model qwen-max --sdk dashscope --lang java
```
```bash
bl model code --model qwen-max --api responses --lang node
```
```bash
bl model code --model qwen-max --output json
```
### `bl model list`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `model list` |
| **Description** | Browse model families or show detailed model info in the Bailian model marketplace |
| **Authentication** | No Auth |
| **Usage** | `bl model list [--model <model>] [--page <n>] [--page-size <n>] [--provider <p>] [--capability <c>] [--feature <f>] [--input-modality <m>] [--output-modality <m>] [--include-deprecated] [--enrich]` |
#### Flags
| Flag | Type | Required | Description |
| ----------------------------------------------- | ------ | -------- | ------------------------------------------------------------------------------------- |
| `--model <model>` | string | no | Show full details of a specific model family (switches to detail mode) |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 10) |
| `--provider <p>` | array | no | Filter by provider (repeatable, e.g. --provider alibaba --provider deepseek) |
| `--capability <c>` | array | no | Filter by capability code (TG, Reasoning, VU, IG, VG, TTS, ASR, …) |
| `--feature <f>` | array | no | Filter by feature (function-calling, web-search, structured-outputs, …) |
| `--context-window <w>` | array | no | Filter by context window range bucket |
| `--input-modality <Text\|Image\|Video\|Audio>` | array | no | Require an input modality (repeatable: Text, Image, Video, Audio) |
| `--output-modality <Text\|Image\|Video\|Audio>` | array | no | Require an output modality (repeatable: Text, Image, Video, Audio) |
| `--include-deprecated` | switch | no | Include models that are already offline (hidden by default) |
| `--enrich` | switch | no | Also fetch input parameter schema (predictConfig) for trunk models (detail mode only) |
#### Notes
- Both the catalog and --enrich parameter-schema endpoints are public — no console login needed.
- Browse mode hides models that are already offline; use --include-deprecated to include them. Detail mode (--model) always lists every version and flags its status instead.
#### Examples
```bash
bl model list
```
```bash
bl model list --provider alibaba
```
```bash
bl model list --capability TG --capability Reasoning
```
```bash
bl model list --input-modality Image --output-modality Text
```
```bash
bl model list --include-deprecated
```
```bash
bl model list --model qwen-max
```
```bash
bl model list --model qwen-max --enrich --output json
```
```bash
bl model list --feature function-calling --output json
```
### `bl model search`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------------------------------- |
| **Name** | `model search` |
| **Description** | Search the model catalog by keyword, ranked by relevance |
| **Authentication** | No Auth |
| **Usage** | `bl model search --keyword <kw> [--limit <n>] [--input-modality <m>] [--output-modality <m>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ----------------------------------------------- | ------ | -------- | ------------------------------------------------------------------------------ |
| `--keyword <kw>` | string | yes | Keyword matched against model id, name, capabilities, features and description |
| `--limit <n>` | number | no | Maximum results to return (default: 20) |
| `--provider <p>` | array | no | Filter by provider (repeatable, e.g. --provider alibaba --provider deepseek) |
| `--capability <c>` | array | no | Filter by capability code (TG, Reasoning, VU, IG, VG, TTS, ASR, …) |
| `--feature <f>` | array | no | Filter by feature (function-calling, web-search, structured-outputs, …) |
| `--context-window <w>` | array | no | Filter by context window range bucket |
| `--input-modality <Text\|Image\|Video\|Audio>` | array | no | Require an input modality (repeatable: Text, Image, Video, Audio) |
| `--output-modality <Text\|Image\|Video\|Audio>` | array | no | Require an output modality (repeatable: Text, Image, Video, Audio) |
| `--include-deprecated` | switch | no | Include models that are already offline (hidden by default) |
#### Notes
- Search scans the whole catalog so that ranking sees every candidate; models already offline are hidden unless --include-deprecated is set.
- The model catalog endpoint is public — no console login needed.
#### Examples
```bash
bl model search --keyword qwen
```
```bash
bl model search --keyword vision --output-modality Text
```
```bash
bl model search --keyword function-calling --provider alibaba
```
```bash
bl model search --keyword 长上下文 --limit 5
```
```bash
bl model search --keyword qwen --include-deprecated --output json
```
reference/monitor.md
# `bl monitor` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------------------- | -------------- | ------------------------------------------------------------------------------------------------------- |
| `bl monitor delivery disable` | Console | Disable monitor delivery for all models in the workspace |
| `bl monitor delivery enable` | Console | Activate monitoring delivery: CMS SLR authorization, CMS service, and the dedicated Prometheus instance |
| `bl monitor delivery status` | Console | Show monitoring delivery (Prometheus instance) status |
| `bl monitor errors` | Console | Show failure breakdown by HTTP status code and error code |
| `bl monitor metrics` | Console | Query time-series monitor metrics (RPM/TPM, latency percentiles, token usage) |
| `bl monitor models` | Console | List per-model / per-API-key call statistics with server-side sort and paging |
| `bl monitor overview` | Console | Show aggregated model call statistics (calls, failures, latency, token usage) |
## Command details
### `bl monitor delivery disable`
| Field | Value |
| ------------------ | -------------------------------------------------------- |
| **Name** | `monitor delivery disable` |
| **Description** | Disable monitor delivery for all models in the workspace |
| **Authentication** | Console |
| **Usage** | `bl monitor delivery disable [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Only the delivery switch is turned off; the CMS service and the Prometheus instance (with stored data) are kept. Re-enable with `monitor delivery enable`.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor delivery disable
```
```bash
bl monitor delivery disable --dry-run
```
```bash
bl monitor delivery disable --output json
```
### `bl monitor delivery enable`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| **Name** | `monitor delivery enable` |
| **Description** | Activate monitoring delivery: CMS SLR authorization, CMS service, and the dedicated Prometheus instance |
| **Authentication** | Console |
| **Usage** | `bl monitor delivery enable [--no-wait] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------------------------------- |
| `--no-wait` | switch | no | Submit the activation requests and return without waiting for Ready |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Steps: 1) authorize the CMS service-linked role, 2) open the CMS service (async, polled via openStatus), 3) create the dedicated Prometheus instance (async, polled until Ready), 4) turn on the monitor delivery switch for all models. Server-side throttles duplicate submissions within 30s.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor delivery enable
```
```bash
bl monitor delivery enable --no-wait
```
```bash
bl monitor delivery enable --output json
```
### `bl monitor delivery status`
| Field | Value |
| ------------------ | ----------------------------------------------------- |
| **Name** | `monitor delivery status` |
| **Description** | Show monitoring delivery (Prometheus instance) status |
| **Authentication** | Console |
| **Usage** | `bl monitor delivery status [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor delivery status
```
```bash
bl monitor delivery status --output json
```
### `bl monitor errors`
| Field | Value |
| ------------------ | ------------------------------------------------------------- |
| **Name** | `monitor errors` |
| **Description** | Show failure breakdown by HTTP status code and error code |
| **Authentication** | Console |
| **Usage** | `bl monitor errors [--model <model>] [--days <days>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--days <days>` | number | no | Number of days to look back (default: 7) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--channel <channel>` | string | no | Call channel(s), comma-separated |
| `--source <source>` | string | no | Call source(s), comma-separated |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Only real-time (online) inference calls are counted in monitor statistics.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor errors
```
```bash
bl monitor errors --model qwen3.6-plus --days 1
```
```bash
bl monitor errors --model qwen3.6-plus --api-key-id 12345
```
```bash
bl monitor errors --output json
```
### `bl monitor metrics`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------- |
| **Name** | `monitor metrics` |
| **Description** | Query time-series monitor metrics (RPM/TPM, latency percentiles, token usage) |
| **Authentication** | Console |
| **Usage** | `bl monitor metrics --metric <name>[,<name>...] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------------------------------- | ------ | -------- | ------------------------------------------------------------------------------- |
| `--days <days>` | number | no | Number of days to look back (default: 7) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--channel <channel>` | string | no | Call channel(s), comma-separated |
| `--source <source>` | string | no | Call source(s), comma-separated |
| `--metric <name>[,<name>...]` | string | yes | Metric name(s), comma-separated; see notes for the full list |
| `--agg <sum\|avg\|max\|min\|p50\|p95\|p99\|cumsum\|cumavg\|sum_pm>` | string | no | Aggregation method applied to every metric (default: sum) |
| `--step <seconds>` | number | no | Data point interval in seconds: 60, 3600 or 86400 (default: auto by time range) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Metrics: model_call_count, model_call_duration, model_first_token_duration, model_generation_duration_per_token, model_call_failed_count, model_call_4xx_count, model_call_5xx_count, model_call_429_count, model_call_data_inspection_failed_count, model_total_amount, model_input_amount, model_output_amount, model_usage, model_tps_per_request, model_cache_hit_percent, model_ptu_token_quota, model_ptu_usage_quota, model_ptu_total_tokens, model_ptu_quota, model_ptu_utilization
- Only real-time (online) inference calls are counted in monitor statistics.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor metrics --metric model_call_count --days 1
```
```bash
bl monitor metrics --metric model_call_duration --agg p99 --model qwen3.6-plus --days 1
```
```bash
bl monitor metrics --metric model_call_count,model_call_failed_count --step 300 --start-time 2026-08-01
```
```bash
bl monitor metrics --metric model_total_amount --output json
```
### `bl monitor models`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------- |
| **Name** | `monitor models` |
| **Description** | List per-model / per-API-key call statistics with server-side sort and paging |
| **Authentication** | Console |
| **Usage** | `bl monitor models [--model <model>] [--sort-by <field>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--days <days>` | number | no | Number of days to look back (default: 7) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--channel <channel>` | string | no | Call channel(s), comma-separated |
| `--source <source>` | string | no | Call source(s), comma-separated |
| `--sort-by <modelAndWorkspaceId\|callCount\|callSuccessCount\|callFailedCount\|callFailedPercent\|avgCallDuration\|avgFirstTokenDuration>` | string | no | Sort field (default: callCount) |
| `--order <ASC\|DESC>` | string | no | Sort order (default: DESC) |
| `--max-results <n>` | number | no | Rows per page, 1-50 (default: 10) |
| `--skip <n>` | number | no | Rows to skip (default: 0) |
| `--next-token <token>` | string | no | Pagination token from a previous response |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Only real-time (online) inference calls are counted in monitor statistics.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor models
```
```bash
bl monitor models --model qwen3.6-plus --days 1
```
```bash
bl monitor models --sort-by callFailedPercent --order DESC
```
```bash
bl monitor models --max-results 50 --output json
```
### `bl monitor overview`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------------- |
| **Name** | `monitor overview` |
| **Description** | Show aggregated model call statistics (calls, failures, latency, token usage) |
| **Authentication** | Console |
| **Usage** | `bl monitor overview [--model <model>] [--days <days>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--days <days>` | number | no | Number of days to look back (default: 7) |
| `--start-time <time>` | string | no | Range start (ISO date or ms epoch); overrides --days |
| `--end-time <time>` | string | no | Range end (ISO date or ms epoch); default: now |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--api-key-id <id>` | string | no | API key ID(s), comma-separated |
| `--channel <channel>` | string | no | Call channel(s), comma-separated |
| `--source <source>` | string | no | Call source(s), comma-separated |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Notes
- Only real-time (online) inference calls are counted in the overview.
- Defaults to JSON, including when the Profile default is text. Use --output text or DASHSCOPE_OUTPUT=text to select text explicitly.
- When a workspace is selected, its tenantId is resolved as switchAgent before any business request, overriding --console-switch-agent for this invocation only. Preflight, polling and follow-up requests share this identity; saved configuration is unchanged.
#### Examples
```bash
bl monitor overview
```
```bash
bl monitor overview --days 30
```
```bash
bl monitor overview --model qwen3.6-plus
```
```bash
bl monitor overview --model qwen3.6-plus --api-key-id 12345 --days 7
```
```bash
bl monitor overview --output json
```
reference/parsex.md
# `bl parsex` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| -------------------------- | -------------- | ------------------------------------------------------ |
| `bl parsex extract result` | API Key | Query ParseX extraction status, fields and citations |
| `bl parsex extract submit` | API Key | Submit ParseX structured field extraction |
| `bl parsex parse result` | API Key | Query ParseX parsing status, results or a result slice |
| `bl parsex parse submit` | API Key | Submit a ParseX document or media parsing task |
## Command details
### `bl parsex extract result`
| Field | Value |
| ------------------ | ----------------------------------------------------------- |
| **Name** | `parsex extract result` |
| **Description** | Query ParseX extraction status, fields and citations |
| **Authentication** | API Key |
| **Usage** | `bl parsex extract result --biz-id <id> [--follow] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------- | ------ | -------- | ------------------------------------------------------------------------ |
| `--biz-id <id>` | string | yes | biz_id returned by the matching submit command |
| `--follow` | switch | no | Poll until success or failed (Ctrl-C stops local polling only) |
| `--interval <seconds>` | number | no | Polling interval, 1–3600 seconds (default: 2; --follow only) |
| `--poll-timeout <seconds>` | number | no | Total polling deadline, 1–86400 seconds (default: 600; --follow only) |
| `--oss-config-file <path>` | string | no | JSON file with OSS credentials; submit also requires bucket and endpoint |
| `--workspace-id <id>` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Uses a workspace-specific ParseX API and an ordinary API key. Set --workspace-id, BAILIAN_WORKSPACE_ID or workspace_id in the profile. --base-url overrides the origin (the CLI discards its path); cn-beijing.pre-maas.aliyuncs.com workspace hosts use pre-parse-x. Service availability depends on the workspace and rollout.
- Single queries preserve the complete API response and exit 0 even for a failed job. --follow emits one terminal response on stdout, progress on stderr; failed exits 1, deadline 5, Ctrl-C 130. Resume using the same biz_id; stopping locally does not cancel the task. ResultNotReady is polled again only with --follow. --timeout controls each HTTP request; --poll-timeout covers the whole polling loop.
#### Examples
```bash
bl parsex extract result --biz-id biz-example --workspace-id ws-example
```
```bash
bl parsex extract result --biz-id biz-example --follow --poll-timeout 600 --output json
```
### `bl parsex extract submit`
| Field | Value |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `parsex extract submit` |
| **Description** | Submit ParseX structured field extraction |
| **Authentication** | API Key |
| **Usage** | `bl parsex extract submit (--file-url <url> \| --parsed-file-biz-id <id>) (--schema-file <path> \| --processing-file <path> \| --config-id <id>) [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ----------------------------------- | ------- | -------- | ------------------------------------------------------------------------ |
| `--file-url <url>` | string | no | Accessible source file URL |
| `--file-name <name>` | string | no | File name (alternative to --file-name-extension) |
| `--file-name-extension <extension>` | string | no | File extension, e.g. pdf |
| `--config-id <id>` | string | no | Saved ParseX configuration ID |
| `--processing-file <path>` | string | no | JSON object for the API processing field |
| `--oss-config-file <path>` | string | no | JSON file with OSS credentials; submit also requires bucket and endpoint |
| `--parsed-file-biz-id <id>` | string | no | Completed parsing task to reuse (alternative to --file-url) |
| `--schema-file <path>` | string | no | JSON Schema object file (alternative to --processing-file) |
| `--user-prompt <text>` | string | no | Extraction instruction (with --schema-file) |
| `--citation-required <boolean>` | boolean | no | Include citations (with --schema-file; service default: true) |
| `--allow-inference <boolean>` | boolean | no | Allow inference (with --schema-file; service default: false) |
| `--workspace-id <id>` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Uses a workspace-specific ParseX API and an ordinary API key. Set --workspace-id, BAILIAN_WORKSPACE_ID or workspace_id in the profile. --base-url overrides the origin (the CLI discards its path); cn-beijing.pre-maas.aliyuncs.com workspace hosts use pre-parse-x. Service availability depends on the workspace and rollout.
- Returns data.biz_id without waiting; query the matching result command with --follow. Input must be an accessible HTTP(S) URL (including a signed OSS URL); local file upload is not part of this API. Inline processing takes precedence over config-id. Dry-run makes no business requests and redacts OSS credentials and URL query strings.
- schema.json example: {"type":"object","properties":{"title":{"type":"string"}}}. The schema is sent as an object, not a JSON string. Extraction does not support audio/video; reused parse results must still be retained by the service.
#### Examples
```bash
bl parsex extract submit --file-url "https://example.com/contract.pdf" --schema-file schema.json --workspace-id ws-example
```
```bash
bl parsex extract submit --parsed-file-biz-id parse-example --schema-file schema.json --citation-required true --allow-inference false
```
```bash
bl parsex extract submit --file-url "https://example.com/contract.pdf" --config-id config-example --output json
```
### `bl parsex parse result`
| Field | Value |
| ------------------ | --------------------------------------------------------- |
| **Name** | `parsex parse result` |
| **Description** | Query ParseX parsing status, results or a result slice |
| **Authentication** | API Key |
| **Usage** | `bl parsex parse result --biz-id <id> [--follow] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------- | ------ | -------- | ------------------------------------------------------------------------ |
| `--biz-id <id>` | string | yes | biz_id returned by the matching submit command |
| `--follow` | switch | no | Poll until success or failed (Ctrl-C stops local polling only) |
| `--interval <seconds>` | number | no | Polling interval, 1–3600 seconds (default: 2; --follow only) |
| `--poll-timeout <seconds>` | number | no | Total polling deadline, 1–86400 seconds (default: 600; --follow only) |
| `--oss-config-file <path>` | string | no | JSON file with OSS credentials; submit also requires bucket and endpoint |
| `--workspace-id <id>` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) |
| `--step-start <n>` | number | no | Slice offset for layouts or media segments (service default: 0) |
| `--step-size <n>` | number | no | Slice size (service default: 0) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Uses a workspace-specific ParseX API and an ordinary API key. Set --workspace-id, BAILIAN_WORKSPACE_ID or workspace_id in the profile. --base-url overrides the origin (the CLI discards its path); cn-beijing.pre-maas.aliyuncs.com workspace hosts use pre-parse-x. Service availability depends on the workspace and rollout.
- Single queries preserve the complete API response and exit 0 even for a failed job. --follow emits one terminal response on stdout, progress on stderr; failed exits 1, deadline 5, Ctrl-C 130. Resume using the same biz_id; stopping locally does not cancel the task. ResultNotReady is polled again only with --follow. --timeout controls each HTTP request; --poll-timeout covers the whole polling loop.
- --follow waits for task completion for the requested slice; it does not collect all slices. Advance --step-start explicitly to retrieve further layouts/segments. Output file URLs may appear only after all results have been retrieved.
#### Examples
```bash
bl parsex parse result --biz-id biz-example --workspace-id ws-example
```
```bash
bl parsex parse result --biz-id biz-example --follow --poll-timeout 600 --output json
```
### `bl parsex parse submit`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------- |
| **Name** | `parsex parse submit` |
| **Description** | Submit a ParseX document or media parsing task |
| **Authentication** | API Key |
| **Usage** | `bl parsex parse submit --file-url <url> [--workspace-id <id>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ---------------------------------------- | ------ | -------- | ------------------------------------------------------------------------ |
| `--file-url <url>` | string | yes | Accessible source file URL |
| `--file-name <name>` | string | no | File name (alternative to --file-name-extension) |
| `--file-name-extension <extension>` | string | no | File extension, e.g. pdf |
| `--config-id <id>` | string | no | Saved ParseX configuration ID |
| `--processing-file <path>` | string | no | JSON object for the API processing field |
| `--oss-config-file <path>` | string | no | JSON file with OSS credentials; submit also requires bucket and endpoint |
| `--output-file-format <markdown>` | array | no | Result file format (markdown) |
| `--layout-table-format <markdown\|html>` | string | no | Table format inside Markdown results |
| `--workspace-id <id>` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Uses a workspace-specific ParseX API and an ordinary API key. Set --workspace-id, BAILIAN_WORKSPACE_ID or workspace_id in the profile. --base-url overrides the origin (the CLI discards its path); cn-beijing.pre-maas.aliyuncs.com workspace hosts use pre-parse-x. Service availability depends on the workspace and rollout.
- Returns data.biz_id without waiting; query the matching result command with --follow. Input must be an accessible HTTP(S) URL (including a signed OSS URL); local file upload is not part of this API. Inline processing takes precedence over config-id. Dry-run makes no business requests and redacts OSS credentials and URL query strings.
- processing.json example: {"doc_processing_config":{"page_index":"1-10","layout_position":true}}. For media use media_processing_config (diarization, synopsis and frame_extraction).
#### Examples
```bash
bl parsex parse submit --file-url "https://example.com/document.pdf" --file-name document.pdf --workspace-id ws-example
```
```bash
bl parsex parse submit --file-url "https://example.com/document.pdf" --processing-file processing.json --output-file-format markdown --output json
```
```bash
bl parsex parse submit --file-url "https://example.com/video.mp4" --config-id config-example --dry-run
```
reference/permission.md
# `bl permission` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ---------------------- | -------------- | ------------------------------------------------------------------------ |
| `bl permission grant` | API Key | Grant model permissions (inference / finetune / deploy) |
| `bl permission list` | API Key | List model permissions (inference / fine-tune / deploy) in the workspace |
| `bl permission revoke` | API Key | Revoke model permissions (inference / finetune / deploy) |
## Command details
### `bl permission grant`
| Field | Value |
| ------------------ | -------------------------------------------------------------------- |
| **Name** | `permission grant` |
| **Description** | Grant model permissions (inference / finetune / deploy) |
| **Authentication** | API Key |
| **Usage** | `bl permission grant --model <models> [--action <actions>] \| --all` |
#### Flags
| Flag | Type | Required | Description |
| -------------------- | ------ | -------- | --------------------------------------------------------------------------------------- |
| `--model <models>` | string | no | Model ID(s), comma-separated (max 20) |
| `--action <actions>` | string | no | Permission action(s), comma-separated: inference, finetune, deploy (default: inference) |
| `--all` | switch | no | One-key grant inference for all models in the workspace (including future ones) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Grants apply to the business workspace your API key belongs to.
- --all maps to the server one-key switch (access_all_entities: OPEN) and only covers inference.
- Actions you omit keep their current grants (server-side tri-state patch).
#### Examples
```bash
bl permission grant --model qwen-plus
```
```bash
bl permission grant --model qwen-plus,qwen3-max --action inference,finetune
```
```bash
bl permission grant --all
```
```bash
bl permission grant --model qwen-plus --dry-run --output json
```
### `bl permission list`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| **Name** | `permission list` |
| **Description** | List model permissions (inference / fine-tune / deploy) in the workspace |
| **Authentication** | API Key |
| **Usage** | `bl permission list [--scope <scope>] [--model <model>] [--name <name>] [--page <n>] [--page-size <n>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------------ | ------ | -------- | --------------------------------------------------------------------- |
| `--scope <authorized\|authorizable>` | string | no | Authorization scope: authorizable (default, full catalog), authorized |
| `--model <model>` | string | no | Model ID (exact match) |
| `--name <name>` | string | no | Fuzzy search by model name or ID |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 20) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Default scope is `authorizable` (the full grantable catalog); use `--scope authorized` to see only models already granted.
- Output defaults to JSON; pass `--output text` for a table. Permission values are tri-state: true / false / null (never set).
- Values mirror the server's grant records as-is for the workspace bound to your API key. A model reporting false/null can still be callable (access may come from other channels); see the Model Studio authorization docs for the exact semantics.
#### Examples
```bash
bl permission list
```
```bash
bl permission list --model qwen-plus
```
```bash
bl permission list --scope authorized
```
```bash
bl permission list --name qwen --page-size 50
```
```bash
bl permission list --output text
```
### `bl permission revoke`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name** | `permission revoke` |
| **Description** | Revoke model permissions (inference / finetune / deploy) |
| **Authentication** | API Key |
| **Usage** | `bl permission revoke --model <models> [--action <actions>] \| --all [flags]` |
| **Risk** | `high` |
| **Risk message** | This revokes model permissions and may interrupt inference, fine-tuning, or deployment workloads. With --all, it also clears all historical inference grants. |
> **Agent safety:** Never add `--yes` automatically. On `type="requires_confirmation"`, stop and ask for explicit user confirmation of the same action and scope.
#### Flags
| Flag | Type | Required | Description |
| -------------------- | ------ | -------- | --------------------------------------------------------------------------------------- |
| `--model <models>` | string | no | Model ID(s), comma-separated (max 20) |
| `--action <actions>` | string | no | Permission action(s), comma-separated: inference, finetune, deploy (default: inference) |
| `--all` | switch | no | Close one-key authorization and clear ALL historical inference grants |
| `--yes` | switch | no | Confirm this high-risk operation |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Grants apply to the business workspace your API key belongs to.
- All revoke operations require --yes; use --dry-run to preview the request without confirmation.
- --all maps to the server one-key switch (access_all_entities: CLOSE): it clears every historical inference grant and cannot be undone, so it requires --yes.
- Actions you omit keep their current grants (server-side tri-state patch).
#### Examples
```bash
# Only after explicit user confirmation:
bl permission revoke --model qwen-plus --yes
```
```bash
# Only after explicit user confirmation:
bl permission revoke --model qwen-plus,qwen3-max --action inference,finetune --yes
```
```bash
# Only after explicit user confirmation:
bl permission revoke --all --yes
```
```bash
bl permission revoke --model qwen-plus --dry-run --output json
```
reference/pipeline.md
# `bl pipeline` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ---------------------- | -------------- | ------------------------------------------------ |
| `bl pipeline run` | No Auth | Run a pipeline workflow definition |
| `bl pipeline validate` | No Auth | Validate a pipeline definition without executing |
## Command details
### `bl pipeline run`
| Field | Value |
| ------------------ | --------------------------------------- |
| **Name** | `pipeline run` |
| **Description** | Run a pipeline workflow definition |
| **Authentication** | No Auth |
| **Usage** | `bl pipeline run --file <path> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| -------------------------- | ------ | -------- | ------------------------------------------------------- |
| `--file <path>` | string | yes | Pipeline definition file (YAML/JSON) |
| `--input <json>` | string | no | Runtime input as inline JSON |
| `--input-file <path>` | string | no | Runtime input from a JSON file |
| `--concurrency <n>` | number | no | Max parallel steps (default: 1) |
| `--events <jsonl>` | string | no | Emit raw lifecycle events: jsonl (requires text output) |
| `--step-timeout <seconds>` | number | no | Default step timeout in seconds |
#### Examples
```bash
bl pipeline run --file workflow.yaml --input '{"brief":"hello"}'
```
```bash
bl pipeline run --file workflow.json --input-file inputs.json --concurrency 3
```
```bash
bl pipeline run --file workflow.yaml --dry-run
```
```bash
bl pipeline run --file workflow.json --output text --events jsonl
```
```bash
bl pipeline run --file workflow.yaml --output json
```
### `bl pipeline validate`
| Field | Value |
| ------------------ | ------------------------------------------------ |
| **Name** | `pipeline validate` |
| **Description** | Validate a pipeline definition without executing |
| **Authentication** | No Auth |
| **Usage** | `bl pipeline validate --file <path>` |
#### Flags
| Flag | Type | Required | Description |
| --------------- | ------ | -------- | ------------------------------------ |
| `--file <path>` | string | yes | Pipeline definition file (YAML/JSON) |
#### Examples
```bash
bl pipeline validate --file workflow.yaml
```
```bash
bl pipeline validate --file workflow.json --output json
```
reference/plugin.md
# `bl plugin` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------------- | -------------- | ------------------------------------------------------ |
| `bl plugin install` | No Auth | Install or upgrade an allowlisted Command Pack |
| `bl plugin link` | No Auth | Link an allowlisted local Command Pack for development |
| `bl plugin list` | No Auth | List installed Command Packs and their load status |
| `bl plugin remove` | No Auth | Remove an installed Command Pack |
## Command details
### `bl plugin install`
| Field | Value |
| ------------------ | ---------------------------------------------- |
| **Name** | `plugin install` |
| **Description** | Install or upgrade an allowlisted Command Pack |
| **Authentication** | No Auth |
| **Usage** | `bl plugin install --package <name[@version]>` |
#### Flags
| Flag | Type | Required | Description |
| ---------------------------- | ------ | -------- | ------------------------------------------------------------ |
| `--package <name[@version]>` | string | yes | Allowlisted Command Pack package and optional version or tag |
#### Examples
```bash
bl plugin install --package @ali/bailian-plugin-agent
```
```bash
bl plugin install --package @ali/bailian-plugin-agent@beta
```
### `bl plugin link`
| Field | Value |
| ------------------ | ------------------------------------------------------ |
| **Name** | `plugin link` |
| **Description** | Link an allowlisted local Command Pack for development |
| **Authentication** | No Auth |
| **Usage** | `bl plugin link --path <directory>` |
#### Flags
| Flag | Type | Required | Description |
| -------------------- | ------ | -------- | ------------------------------------ |
| `--path <directory>` | string | yes | Local Command Pack package directory |
#### Examples
```bash
bl plugin link --path ../bailian-plugin-agent
```
### `bl plugin list`
| Field | Value |
| ------------------ | -------------------------------------------------- |
| **Name** | `plugin list` |
| **Description** | List installed Command Packs and their load status |
| **Authentication** | No Auth |
| **Usage** | `bl plugin list` |
#### Flags
_No command-specific flags._
#### Examples
```bash
bl plugin list
```
```bash
bl plugin list --output json
```
### `bl plugin remove`
| Field | Value |
| ------------------ | ----------------------------------- |
| **Name** | `plugin remove` |
| **Description** | Remove an installed Command Pack |
| **Authentication** | No Auth |
| **Usage** | `bl plugin remove --name <package>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ------------------------------------- |
| `--name <package>` | string | yes | Allowlisted Command Pack package name |
#### Examples
```bash
bl plugin remove --name @ali/bailian-plugin-agent
```
reference/quota.md
# `bl quota` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------------ | -------------- | ------------------------------------------------------------- |
| `bl quota check` | Console | Check current usage against rate limits |
| `bl quota delete` | API Key | Clear all custom rate limits (QPM/TPM) for a model |
| `bl quota history` | Console | View quota change history |
| `bl quota list` | API Key | View model rate limits (QPM/TPM, account and workspace level) |
| `bl quota update` | API Key | Update model rate limits (QPM/TPM) |
## Command details
### `bl quota check`
| Field | Value |
| ------------------ | ------------------------------------------ |
| **Name** | `quota check` |
| **Description** | Check current usage against rate limits |
| **Authentication** | Console |
| **Usage** | `bl quota check [--model <model>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--model <model>` | string | no | Model name(s), comma-separated |
| `--period <minutes>` | string | no | Query usage for the last N minutes (default: 2) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl quota check
```
```bash
bl quota check --model qwen3.6-plus
```
```bash
bl quota check --period 5
```
```bash
bl quota check --model qwen3.6-plus,qwen-turbo
```
```bash
bl quota check --output json
```
### `bl quota delete`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------- |
| **Name** | `quota delete` |
| **Description** | Clear all custom rate limits (QPM/TPM) for a model |
| **Authentication** | API Key |
| **Usage** | `bl quota delete --model <model>` |
| **Risk** | `high` |
| **Risk message** | This permanently clears all custom QPM/TPM rate limits for the specified model and cannot be undone. |
> **Agent safety:** Never add `--yes` automatically. On `type="requires_confirmation"`, stop and ask for explicit user confirmation of the same action and scope.
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | -------------------------------- |
| `--model <model>` | string | yes | Model name (required) |
| `--yes` | switch | no | Confirm this high-risk operation |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Examples
```bash
bl quota delete --model qwen-plus
```
```bash
bl quota delete --model qwen-plus --dry-run --output json
```
```bash
# Only after explicit user confirmation:
bl quota delete --model qwen-plus --yes
```
### `bl quota history`
| Field | Value |
| ------------------ | -------------------------- |
| **Name** | `quota history` |
| **Description** | View quota change history |
| **Authentication** | Console |
| **Usage** | `bl quota history [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--page <n>` | string | no | Page number (default: 1) |
| `--page-size <n>` | string | no | Page size (default: 10) |
| `--model <model>` | string | no | Filter by model name |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl quota history
```
```bash
bl quota history --page 2
```
```bash
bl quota history --page-size 20
```
```bash
bl quota history --model qwen-turbo
```
```bash
bl quota history --output json
```
### `bl quota list`
| Field | Value |
| ------------------ | -------------------------------------------------------------------------------- |
| **Name** | `quota list` |
| **Description** | View model rate limits (QPM/TPM, account and workspace level) |
| **Authentication** | API Key |
| **Usage** | `bl quota list [--model <model>] [--name <name>] [--page <n>] [--page-size <n>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | -------------------------------------------- |
| `--model <model>` | string | no | Model name(s), comma-separated (exact match) |
| `--name <name>` | string | no | Fuzzy search by model name |
| `--page <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Results per page (default: 20) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Usage-vs-limit pressure checks live in `quota check` (console auth).
#### Examples
```bash
bl quota list
```
```bash
bl quota list --model qwen3-max
```
```bash
bl quota list --model qwen3-max,qwen-plus
```
```bash
bl quota list --name qwen --page-size 50
```
```bash
bl quota list --output json
```
### `bl quota update`
| Field | Value |
| ------------------ | --------------------------------------------------------- |
| **Name** | `quota update` |
| **Description** | Update model rate limits (QPM/TPM) |
| **Authentication** | API Key |
| **Usage** | `bl quota update --model <model> [--rpm <n>] [--tpm <n>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------ | ------ | -------- | ----------------------------- |
| `--model <model>` | string | yes | Model name (required) |
| `--rpm <n>` | number | no | Max requests per minute (QPM) |
| `--tpm <n>` | number | no | Max tokens per minute (TPM) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Fields you omit keep their current values (server-side OVERLAY merge). Clear all custom limits with the "quota delete" command instead.
- Setting TPM without an existing QPM limit is rejected server-side — pass --rpm first or together.
#### Examples
```bash
bl quota update --model qwen-plus --rpm 60 --tpm 100000
```
```bash
bl quota update --model qwen3-max --tpm 500000
```
```bash
bl quota update --model qwen-plus --rpm 60 --output json
```
reference/search.md
# `bl search` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
> **Agent routing (mandatory):** Before running any `bl search *` command, Read skill `bailian-web-search` if installed and follow its routing (default `bl search web` = model mode for every identity, including Token Plan; the WebSearch MCP service requires explicit `--mode mcp` and a regular DashScope key; eligible MCP failures → fall back to model mode once). Do **not** route Token Plan keys to `bl search web --mode mcp` — they cannot authorize Bailian MCP search. If that skill is missing, run `bl skill init` or fall back to `bl search web --help` / `bl text chat --help` after checking `bl config show --output json`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| --------------- | -------------- | --------------------------------------------------------------------------------------------------------- |
| `bl search web` | API Key | Search the web via a chat model with built-in web search (default) or the DashScope MCP WebSearch service |
## Command details
### `bl search web`
| Field | Value |
| ------------------ | --------------------------------------------------------------------------------------------------------- |
| **Name** | `search web` |
| **Description** | Search the web via a chat model with built-in web search (default) or the DashScope MCP WebSearch service |
| **Authentication** | API Key |
| **Usage** | `bl search web --query <text> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| --------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| `--query <text>` | string | no | Search query text |
| `--count <n>` | number | no | Number of search results (default: 10) |
| `--list-tools` | switch | no | List available MCP tools and exit |
| `--mode <mcp\|model>` | string | no | Search mode: model answers via Chat Completions with enable_search, mcp calls the WebSearch MCP service (default: model) |
| `--model <model>` | string | no | Model ID for --mode model (default: qwen3.8-max) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- Defaults to --mode model: one non-streaming Chat Completions request with enable_search: true, returning the model answer as a single content[].text block (no pages list). Use --mode mcp for the WebSearch MCP service (pages list); --count and --list-tools are MCP-mode only. The model resolves from --model, default_text_model, then qwen3.8-max.
#### Examples
```bash
bl search web --query "Alibaba Cloud Bailian latest features"
```
```bash
bl search web --query "Today's news"
```
```bash
bl search web --mode mcp --query "TypeScript 5.9 new features" --count 5
```
```bash
bl search web --mode mcp --query "Alibaba Cloud Bailian latest features"
```
```bash
bl search web --list-tools
```
reference/skill.md
# `bl skill` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------- | -------------- | ---------------------------------------------------------------------- |
| `bl skill add` | No Auth | Install skills from the Bailian skill registry into local agents |
| `bl skill init` | No Auth | Install all bailian-* skills (one-shot bootstrap for new environments) |
| `bl skill list` | No Auth | List registry skills and diff against local installs |
| `bl skill remove` | No Auth | Remove locally installed skills (registry is untouched) |
| `bl skill update` | No Auth | Update installed skills to the latest registry versions |
## Command details
### `bl skill add`
| Field | Value |
| ------------------ | ---------------------------------------------------------------- |
| **Name** | `skill add` |
| **Description** | Install skills from the Bailian skill registry into local agents |
| **Authentication** | No Auth |
| **Usage** | `bl skill add --all \| --name <name,...>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------- | ------ | -------- | -------------------------------------- |
| `--all` | switch | no | Install all skills from the registry |
| `--name <name,...>` | string | no | Comma-separated skill names to install |
#### Examples
```bash
bl skill add --all
```
```bash
bl skill add --name spark-video,bailian-model-recommend
```
### `bl skill init`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------- |
| **Name** | `skill init` |
| **Description** | Install all bailian-* skills (one-shot bootstrap for new environments) |
| **Authentication** | No Auth |
| **Usage** | `bl skill init` |
#### Flags
_No command-specific flags._
#### Notes
- Fetches the registry index and installs every skill whose name starts with `bailian-`.
- Equivalent to: `bl skill add --all` (filtered to `bailian-*` skills).
#### Examples
```bash
bl skill init
```
### `bl skill list`
| Field | Value |
| ------------------ | ---------------------------------------------------- |
| **Name** | `skill list` |
| **Description** | List registry skills and diff against local installs |
| **Authentication** | No Auth |
| **Usage** | `bl skill list` |
#### Flags
_No command-specific flags._
#### Notes
- STATUS: installed | outdated | not-installed | missing (lock has it, dir deleted) | untracked (dir exists, not managed)
#### Examples
```bash
bl skill list
```
```bash
bl skill list --output json
```
### `bl skill remove`
| Field | Value |
| ------------------ | ------------------------------------------------------- |
| **Name** | `skill remove` |
| **Description** | Remove locally installed skills (registry is untouched) |
| **Authentication** | No Auth |
| **Usage** | `bl skill remove --name <all\|name,...>` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------ | ------ | -------- | ---------------------------------------------------- |
| `--name <all\|name,...>` | string | yes | Skills to remove: all or comma-separated skill names |
#### Examples
```bash
bl skill remove --name spark-video
```
```bash
bl skill remove --name all
```
### `bl skill update`
| Field | Value |
| ------------------ | ------------------------------------------------------- |
| **Name** | `skill update` |
| **Description** | Update installed skills to the latest registry versions |
| **Authentication** | No Auth |
| **Usage** | `bl skill update [--all] [--name <name,...>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------- | ------ | -------- | ---------------------------------------------------------------------------- |
| `--all` | switch | no | Update all installed skills (default when neither --all nor --name is given) |
| `--name <name,...>` | string | no | Comma-separated skill names to update (must be already installed) |
#### Examples
```bash
bl skill update
```
```bash
bl skill update --all
```
```bash
bl skill update --name spark-video
```
reference/text.md
# `bl text` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| -------------- | -------------- | -------------------------------------------------------- |
| `bl text chat` | API Key | Send a text model request (OpenAI compatible, DashScope) |
## Command details
### `bl text chat`
| Field | Value |
| ------------------ | ------------------------------------------------------------------- |
| **Name** | `text chat` |
| **Description** | Send a text model request (OpenAI compatible, DashScope) |
| **Authentication** | API Key |
| **Usage** | `bl text chat (--message <text> \| --messages-file <path>) [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------- | ------- | -------- | ------------------------------------------------------------------------------------- |
| `--api <chat\|responses>` | string | no | API to call (default: chat) |
| `--model <model>` | string | no | Model ID (default: qwen3.8-max) |
| `--message <text>` | array | no | Message text (repeatable, prefix role: to set role); or use --messages-file |
| `--messages-file <path>` | string | no | Messages array for one request (use - for stdin) |
| `--system <text>` | string | no | System prompt |
| `--max-tokens <n>` | number | no | Maximum tokens to generate (default: 4096) |
| `--temperature <n>` | number | no | Sampling temperature (0.0, 2.0] |
| `--top-p <n>` | number | no | Nucleus sampling threshold |
| `--enable-search <true\|false>` | boolean | no | Enable built-in web search (Chat Completions API only; default: true for qwen3.8-max) |
| `--stream` | switch | no | Stream response tokens (default: on in TTY) |
| `--tool <json-or-path>` | array | no | Tool definition as JSON or file path (repeatable) |
| `--enable-thinking` | switch | no | Enable thinking/reasoning mode (for qwen3/qwq models) |
| `--thinking-budget <n>` | number | no | Max tokens for thinking (default: 4096) |
| `--batch` | switch | no | Single synchronous Batch Chat request (non-streaming) |
| `--prime` | switch | no | Use Prime mode with a workspace-scoped endpoint |
| `--workspace-id <id>` | string | no | Workspace ID for the default Prime endpoint (or set BAILIAN_WORKSPACE_ID) |
| `--api-key <key>` | string | no | API key |
| `--base-url <url>` | string | no | API base URL |
#### Notes
- --batch sends one synchronous Batch Chat request, non-streaming even in TTY; cannot combine with --prime, --api responses or --stream. --message/--messages-file supply one request's conversation context, not independent file requests. File inference uses batch create/get/download: create returns a task ID without waiting for completion. Explicit realtime/international/Token Plan hosts are rejected; explicit Batch/custom proxy URLs retain existing credentials. No automatic fallback or POST replay.
- Batch Chat total request timeout defaults to 300s; --timeout must be 60–3600s.
- Prime mode requires an explicit model and currently supports only the Chat Completions API.
- Prime endpoint: configured --base-url, DASHSCOPE_BASE_URL, or profile base_url takes precedence; otherwise workspace is resolved from --workspace-id, BAILIAN_WORKSPACE_ID, then config workspace_id.
- --enable-search maps to the Chat Completions enable_search parameter and requires a model with built-in web search support; whitelisted models (qwen3.8-max) enable it by default unless --enable-search false is passed; for the Responses API use --tool '{"type":"web_search"}' instead.
#### Examples
```bash
bl text chat --message "What is Qwen?"
```
```bash
bl text chat --api responses --model qwen3.8-max --tool '{"type":"web_search"}' --message "Search for recent Alibaba Cloud news"
```
```bash
bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"
```
```bash
bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"
```
```bash
bl text chat --batch --model qwen-plus --message "Hello" --timeout 3600
```
```bash
bl text chat --batch --model qwen-plus --messages-file messages.json --timeout 3600
```
```bash
bl text chat --messages-file - --stream
```
```bash
bl text chat --message "Hello" --output json
```
```bash
bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking
```
```bash
bl text chat --enable-search true --message "Latest news about Alibaba Cloud"
```
```bash
bl text chat --prime --workspace-id <id> --model glm-5.3-prime --message "Explain this code"
```
reference/token-plan.md
# `bl token-plan` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------------------------- | -------------- | ----------------------------------------------- |
| `bl token-plan add-member` | AK/SK | Add a member to a Token Plan organization |
| `bl token-plan assign-seats` | AK/SK | Batch assign Token Plan seats to members |
| `bl token-plan create-key` | AK/SK | Create a Token Plan API key for a seat |
| `bl token-plan harness-quota` | Console | Show Token Plan harness entitlement quota usage |
| `bl token-plan list-seats` | AK/SK | List Token Plan subscription seat details |
## Command details
### `bl token-plan add-member`
| Field | Value |
| ------------------ | ---------------------------------------------------------------------- |
| **Name** | `token-plan add-member` |
| **Description** | Add a member to a Token Plan organization |
| **Authentication** | AK/SK |
| **Usage** | `bl token-plan add-member --account-name <name> --org-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ---------------------------------------------------------------------- |
| `--account-name <name>` | string | yes | Member display name |
| `--org-id <id>` | string | yes | Organization ID |
| `--org-role-code <code>` | string | no | Organization role: ORG_ADMIN or ORG_MEMBER (default: ORG_MEMBER) |
| `--spec-type <type>` | string | no | Seat tier to assign on creation: standard, pro, or max |
| `--caller-uac-account-id <id>` | string | no | Caller UAC account ID |
| `--namespace-id <id>` | string | no | Product namespace ID (Token Plan default: namespace-1) |
| `--access-key-id <key>` | string | no | Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID) |
| `--access-key-secret <key>` | string | no | Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET) |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN) |
#### Examples
```bash
bl token-plan add-member --account-name dev_user --org-id org_123
```
```bash
bl token-plan add-member --account-name admin_user --org-id org_123 --org-role-code ORG_ADMIN
```
```bash
bl token-plan add-member --account-name member1 --org-id org_123 --spec-type standard
```
### `bl token-plan assign-seats`
| Field | Value |
| ------------------ | --------------------------------------------------------------------------------------------- |
| **Name** | `token-plan assign-seats` |
| **Description** | Batch assign Token Plan seats to members |
| **Authentication** | AK/SK |
| **Usage** | `bl token-plan assign-seats --workspace-id <id> --seat-type <type> --account-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ---------------------------------------------------------------------- |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID, config: workspace_id) |
| `--seat-type <type>` | string | yes | Seat tier: standard, pro, or max |
| `--account-id <id>` | array | no | Target member account ID (repeatable) |
| `--caller-uac-account-id <id>` | string | no | Caller UAC account ID |
| `--namespace-id <id>` | string | no | Product namespace ID (Token Plan default: namespace-1) |
| `--locale <locale>` | string | no | Language: zh-CN or en-US |
| `--access-key-id <key>` | string | no | Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID) |
| `--access-key-secret <key>` | string | no | Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET) |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN) |
#### Examples
```bash
bl token-plan assign-seats --workspace-id ws_456 --seat-type standard --account-id acc_123
```
```bash
bl token-plan assign-seats --workspace-id ws_456 --seat-type pro --account-id acc_1 --account-id acc_2
```
### `bl token-plan create-key`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------ |
| **Name** | `token-plan create-key` |
| **Description** | Create a Token Plan API key for a seat |
| **Authentication** | AK/SK |
| **Usage** | `bl token-plan create-key --account-id <id> --workspace-id <id> [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ---------------------------------------------------------------------- |
| `--account-id <id>` | string | yes | Target member account ID |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID, config: workspace_id) |
| `--description <text>` | string | no | API key description |
| `--caller-uac-account-id <id>` | string | no | Caller UAC account ID |
| `--namespace-id <id>` | string | no | Product namespace ID (Token Plan default: namespace-1) |
| `--access-key-id <key>` | string | no | Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID) |
| `--access-key-secret <key>` | string | no | Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET) |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN) |
#### Examples
```bash
bl token-plan create-key --account-id acc_123 --workspace-id ws_456
```
```bash
bl token-plan create-key --account-id acc_123 --workspace-id ws_456 --description 'Dev key'
```
### `bl token-plan harness-quota`
| Field | Value |
| ------------------ | ----------------------------------------------- |
| **Name** | `token-plan harness-quota` |
| **Description** | Show Token Plan harness entitlement quota usage |
| **Authentication** | Console |
| **Usage** | `bl token-plan harness-quota [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ---------------------------------------- | ------ | -------- | ---------------------------------------------------------- |
| `--type <official_tool\|infrastructure>` | string | no | Filter harness list by type: official_tool, infrastructure |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl token-plan harness-quota
```
```bash
bl token-plan harness-quota --type official_tool
```
```bash
bl token-plan harness-quota --output json
```
### `bl token-plan list-seats`
| Field | Value |
| ------------------ | ----------------------------------------- |
| **Name** | `token-plan list-seats` |
| **Description** | List Token Plan subscription seat details |
| **Authentication** | AK/SK |
| **Usage** | `bl token-plan list-seats [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | --------------------------------------------------------------------------------- |
| `--page-no <n>` | number | no | Page number (default: 1) |
| `--page-size <n>` | number | no | Page size (default: 10) |
| `--caller-uac-account-id <id>` | string | no | Caller UAC account ID |
| `--namespace-id <id>` | string | no | Product namespace ID (Token Plan default: namespace-1) |
| `--status <status>` | array | no | Seat status filter (repeatable): CREATING, NORMAL, LIMIT, RELEASE, STOP, REFUNDED |
| `--status-list-str <json>` | string | no | StatusList as JSON string, e.g. '["NORMAL"]' |
| `--seat-id <id>` | string | no | Filter by seat ID |
| `--seat-type <type>` | string | no | Seat tier: standard, pro, or max |
| `--query-assigned <bool>` | string | no | Filter by assignment: true=assigned, false=unassigned |
| `--access-key-id <key>` | string | no | Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID) |
| `--access-key-secret <key>` | string | no | Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET) |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN) |
#### Examples
```bash
bl token-plan list-seats
```
```bash
bl token-plan list-seats --page-size 20 --status NORMAL
```
```bash
bl token-plan list-seats --query-assigned true --seat-type standard
```
reference/update.md
# `bl update` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ----------- | -------------- | --------------------------------------------------- |
| `bl update` | No Auth | Update the CLI to the latest or a specified version |
## Command details
### `bl update`
| Field | Value |
| ------------------ | --------------------------------------------------- |
| **Name** | `update` |
| **Description** | Update the CLI to the latest or a specified version |
| **Authentication** | No Auth |
| **Usage** | `bl update [--to <version>]` |
#### Flags
| Flag | Type | Required | Description |
| ---------------- | ------ | -------- | ------------------------------------------------ |
| `--to <version>` | string | no | Install this exact version instead of the latest |
#### Examples
```bash
bl update
```
```bash
bl update --to 0.1.14
```
reference/usage.md
# `bl usage` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ---------------------- | -------------- | ------------------------------------------------------------------------------------------ |
| `bl usage coding-plan` | Console | Show Coding Plan quota usage |
| `bl usage free` | Console | Query free-tier quota for models (all models if --model is omitted) |
| `bl usage freetier` | Console | Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable |
| `bl usage stats` | Console | Query model usage statistics |
| `bl usage summary` | Console | Show a unified usage summary: free-tier quota and recent usage overview |
| `bl usage token-plan` | Console | Show Token Plan quota usage |
## Command details
### `bl usage coding-plan`
| Field | Value |
| ------------------ | ------------------------------ |
| **Name** | `usage coding-plan` |
| **Description** | Show Coding Plan quota usage |
| **Authentication** | Console |
| **Usage** | `bl usage coding-plan [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl usage coding-plan
```
```bash
bl usage coding-plan --output json
```
### `bl usage free`
| Field | Value |
| ------------------ | ------------------------------------------------------------------- |
| **Name** | `usage free` |
| **Description** | Query free-tier quota for models (all models if --model is omitted) |
| **Authentication** | Console |
| **Usage** | `bl usage free [--model <model>[,model2,...]] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------------------------------------- |
| `--model <model>` | string | no | Model name(s) to query, comma-separated for multiple; omit for all models |
| `--expiring <days>` | string | no | Only show quotas expiring within N days |
| `--sort <remaining\|expires>` | string | no | Sort by: remaining (ascending), expires (ascending) |
| `--all` | switch | no | Show all models instead of the top rows |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl usage free
```
```bash
bl usage free --model qwen3-max
```
```bash
bl usage free --model qwen3-max,qwen-turbo
```
```bash
bl usage free --expiring 30
```
```bash
bl usage free --sort remaining
```
```bash
bl usage free --all
```
```bash
bl usage free --model qwen-turbo --output json
```
```bash
bl usage free --model qwen3-max --console-region cn-beijing
```
### `bl usage freetier`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------ |
| **Name** | `usage freetier` |
| **Description** | Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable |
| **Authentication** | Console |
| **Usage** | `bl usage freetier <--model <model>[,model2,...] \| --all> [--off] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--model <model>` | string | no | Model name(s), comma-separated for multiple |
| `--all` | switch | no | Apply to all free-tier models |
| `--on` | switch | no | Enable auto-stop (default behavior) |
| `--off` | switch | no | Disable auto-stop |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl usage freetier --model qwen3-max
```
```bash
bl usage freetier --model qwen3-max,qwen-turbo
```
```bash
bl usage freetier --all
```
```bash
bl usage freetier --on --model qwen3-max
```
```bash
bl usage freetier --off --model qwen3-max
```
```bash
bl usage freetier --off --all
```
### `bl usage stats`
| Field | Value |
| ------------------ | ---------------------------------------------------------- |
| **Name** | `usage stats` |
| **Description** | Query model usage statistics |
| **Authentication** | Console |
| **Usage** | `bl usage stats [--model <model>] [--days <days>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--model <model>` | string | no | Model name(s), comma-separated; omit for overview |
| `--days <days>` | string | no | Number of days (default: 7) |
| `--type <type>` | string | no | Model type: Text, Vision, Multimodal, Audio, Embedding |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl usage stats
```
```bash
bl usage stats --days 30
```
```bash
bl usage stats --model qwen-turbo
```
```bash
bl usage stats --model qwen-turbo --days 7
```
```bash
bl usage stats --model qwen3.6-plus,deepseek-v4-pro
```
```bash
bl usage stats --type Text --days 14
```
```bash
bl usage stats --output json
```
### `bl usage summary`
| Field | Value |
| ------------------ | ----------------------------------------------------------------------- |
| **Name** | `usage summary` |
| **Description** | Show a unified usage summary: free-tier quota and recent usage overview |
| **Authentication** | Console |
| **Usage** | `bl usage summary [--days <days>] [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--days <days>` | string | no | Number of days for the usage overview (default: 7) |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl usage summary
```
```bash
bl usage summary --days 30
```
```bash
bl usage summary --output json
```
### `bl usage token-plan`
| Field | Value |
| ------------------ | ----------------------------- |
| **Name** | `usage token-plan` |
| **Description** | Show Token Plan quota usage |
| **Authentication** | Console |
| **Usage** | `bl usage token-plan [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl usage token-plan
```
```bash
bl usage token-plan --output json
```
reference/workspace.md
# `bl workspace` commands
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
Index: [index.md](index.md)
## Commands in this group
| Command | Authentication | Description |
| ------------------- | -------------- | ----------------------------------------------------------- |
| `bl workspace init` | No Auth | Initialize Bailian workspace and activate postpaid services |
| `bl workspace list` | Console | List all workspaces |
## Command details
### `bl workspace init`
| Field | Value |
| ------------------ | ------------------------------------------------------------------------------------------------ |
| **Name** | `workspace init` |
| **Description** | Initialize Bailian workspace and activate postpaid services |
| **Authentication** | No Auth |
| **Usage** | `bl workspace init --access-key-id <id> --access-key-secret <secret> [--security-token <token>]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | ------------------------------------------- |
| `--access-key-id <id>` | string | no | Alibaba Cloud Access Key ID |
| `--access-key-secret <secret>` | string | no | Alibaba Cloud Access Key Secret |
| `--security-token <token>` | string | no | Alibaba Cloud STS Security Token (optional) |
#### Examples
```bash
bl workspace init --access-key-id LTAIxxxxx --access-key-secret xxxxx
```
### `bl workspace list`
| Field | Value |
| ------------------ | --------------------------- |
| **Name** | `workspace list` |
| **Description** | List all workspaces |
| **Authentication** | Console |
| **Usage** | `bl workspace list [flags]` |
#### Flags
| Flag | Type | Required | Description |
| ------------------------------ | ------ | -------- | -------------------------------------------------------- |
| `--list <n>` | string | no | Limit number of results |
| `--console-region <region>` | string | no | Console gateway region (e.g. cn-beijing, ap-southeast-1) |
| `--console-site <site>` | string | no | Console site: domestic, international |
| `--console-switch-agent <uid>` | number | no | Switch agent UID for delegated access |
| `--workspace-id <id>` | string | no | Workspace ID (env: BAILIAN_WORKSPACE_ID) |
#### Examples
```bash
bl workspace list
```
```bash
bl workspace list --list 5
```
```bash
bl workspace list --output json
```
SKILL.md
---
name: bailian-cli
metadata:
version: "2.8.4"
requires:
bins: ["bl"]
description: >-
阿里云百炼 / Aliyun Bailian / DashScope 资源管理与 `bl` CLI hub:
应用调用(bl app)、决策模型推理(bl decision)、模型目录/模型列表、用量/额度/配额、免费额度、
工作空间、MCP 市场、pipeline、文件上传、ParseX 文档/音视频解析与字段抽取、Batch 批量推理与 CSV 转换、同步 Batch Chat、console API、登录鉴权与配置、
Agent skill 安装/列表/更新/卸载(bl skill add|list|update|remove,百炼 skill registry)。
用户点名百炼 / DashScope / `bl`,或继续既有 `bl` 工作流时直接使用。
共享协议(consent / 版本预检 / 鉴权 / 错误上报)在 bailian-protocol;官方安装 `bl skill init`。
家族路由:生图/生视频/配音/语音合成/转写 → bailian-gen;精调/微调/训练/训练数据集 → bailian-finetune;
agents.yaml 托管 Agent → bailian-managed-agent;Sandbox 实例与模版 → bailian-sandbox;
个人长期记忆与应用记忆资源 → bailian-memory;个人历史资料辅助任务、资料接入与知识库管理 → bailian-knowledge;
联网搜索路由(默认模型搜索 vs 显式 `--mode mcp` + 兜底)→ bailian-web-search。
不要用于普通问答、编程、写作、翻译、摘要、泛搜索,或图片理解等宿主自己能做的任务(普通问答、编程、写作、翻译、摘要、泛搜索不触发)。
未命名用量/额度问题:先问用户使用哪个产品,再运行 `bl usage` / `bl quota` 查询。
---
# Aliyun Model Studio CLI (`bl`)
**CRITICAL — Before executing, MUST read the shared protocol in [`../bailian-protocol/SKILL.md`](../bailian-protocol/SKILL.md): Provider selection and consent, Version & updates (pre-flight checklist), Call attribution (every Agent `bl` command), Setup & auth, and CLI errors: report an issue. If that protocol file is missing, stop and run `bl skill init`; do not guess auth/consent.**
**Call attribution:** Examples below and in `reference/` stay bare `bl …`. When running a command, wrap it with [`bailian-protocol` → Call attribution](../bailian-protocol/SKILL.md#call-attribution-mandatory-for-every-agent-bl-command) (bash or PowerShell). One sample for this skill (`BAILIAN_SKILL_NAME=bailian-cli`; replace `codex` with this host):
```bash
BAILIAN_CALLER_TYPE=agent BAILIAN_CALLER_NAME=codex BAILIAN_SKILL_NAME=bailian-cli BAILIAN_SKILL_VERSION=2.5.0 bl text chat --message "Write a poem about spring"
```
> **Family hub** — This skill owns Bailian resource commands and the hub `reference/` (apps, usage, auth, config, …).
> Shared protocol → [`../bailian-protocol/SKILL.md`](../bailian-protocol/SKILL.md) (install the full family with `bl skill init`).
> Soft hand-offs by skill name (Read if installed; else `bl … --help` / prompt `bl skill init`): `bailian-gen` (media) · `bailian-finetune` (training) · `bailian-managed-agent` (agents.yaml IaC) · `bailian-sandbox` (Sandbox lifecycle) · `bailian-web-search` (web search routing) · `bailian-knowledge` (personal documents in everyday tasks and knowledge workflows).
> Tasks that need the user’s own historical documents belong to `bailian-knowledge`; ordinary writing does not itself select a cloud provider.
> Do not invoke it for ordinary reasoning, coding, writing, translation, summarization, generic research, or image understanding the host agent can complete directly.
>
> **Install (supported):** `bl skill init`
## Command reference (authoritative)
**Hub-owned commands, flags, usage strings, and examples are documented in:**
- [`reference/index.md`](reference/index.md) — hub quick index, global flags, links by group
- [`reference/<group>.md`](reference/) — per hub top-level command (e.g. [`reference/app.md`](reference/app.md))
Domain skills own their own generated reference trees (soft hand-off — do not require them for hub work):
- `bailian-gen` → `image` / `video` / `speech` / `omni` / `vision` (fallback: `bl image\|video\|speech\|omni\|vision --help`)
- `bailian-finetune` → `dataset` / `finetune` / `deploy` (fallback: `bl dataset\|finetune\|deploy --help`)
- `bailian-managed-agent` → `managed-agent` (fallback: `bl managed-agent --help`)
- `bailian-sandbox` → `sandbox` (fallback: `bl sandbox --help`)
- `bailian-web-search` → web search **routing** (hub still owns `reference/search.md` flags; **must** route via this skill before `bl search web`)
Auto-generated from the CLI source at build time (`pnpm --filter bailian-cli run generate:reference`). Before running an unfamiliar command:
1. Open the owning skill's `reference/index.md` (if that skill is installed) → **Quick index** (or **By group**) to locate the command.
2. Open the matching `reference/<group>.md` for **Usage**, **Flags**, and **Examples**.
3. Run `bl <command> --help` for the same information in the terminal.
Do not guess flags — use the reference files or `--help`.
---
## When to use which command
Use this table only after the decision table in [`bailian-protocol`](../bailian-protocol/SKILL.md#provider-selection-and-consent) has routed the request to `bl` (class 4, or class 2 after the user picks Bailian). Hub-owned intents only — for media / fine-tune / agents.yaml / Sandbox, soft hand-off to the domain skill.
| User intent | Command | Notes |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Explicit Bailian model chat / text execution | `bl text chat` | Default `qwen3.8-max` |
| 百炼异步文件批量推理 / CSV 转换 | `bl batch convert` / `create` / `list` / `get` / `cancel` / `download` | CSV → JSONL → 异步任务 → 原始结果,可额外导出 CSV;格式样例见 `reference/batch.md` |
| 百炼单次同步 Batch Chat | `bl text chat --batch` | 等待单次响应,不创建任务 ID;messages-file 是同一请求的对话上下文,边界见 `reference/text.md` |
| Typed decision model inference | `bl decision` | Workspace endpoint; returns `choice` / `noul` / `score` values and probabilities, not generated text |
| Explicit ParseX parsing / structured field extraction | `bl parsex parse submit` / `result`; `bl parsex extract submit` / `result` | Workspace + API key; submit returns biz_id, result --follow waits. HTTP(S) source URLs; extraction can reuse a parsed document. See `reference/parsex.md`. |
| Bailian agent / workflow | `bl app call` | Needs `--app-id` |
| Find app by name | `bl app list` then `bl app call` | Console auth |
| Personal memory / Bailian memory resources | → skill `bailian-memory` | User-enabled personal memory; explicit resource operations use `bl memory --help` as fallback. |
| Personal documents / Bailian knowledge workflows | Read skill `bailian-knowledge` | If missing: `bl knowledge --help` or `bl skill init` |
| Upload a file as a step of a Bailian workflow | `bl file upload` | When you need `oss://` URL explicitly; not for generic hosting |
| Bailian model selection / recommendation | `bl advisor recommend` | Intent → candidate recall → LLM ranking |
| Bailian model catalog / pricing / params | `bl model list` | No auth (public catalog); `--model <family>` for detail, `--enrich` for input params |
| Find a model by keyword / modality | `bl model search` | Weighted ranking; `--input-modality` / `--output-modality`; offline models hidden by default |
| SDK sample code for calling a model | `bl model code` | `--sdk openai\|dashscope`, `--lang`; text output is the snippet alone, safe to redirect |
| Install / list / update / remove registry skills | `bl skill add` / `list` / `update` / `remove` | Bailian skill registry; see [`reference/skill.md`](reference/skill.md) |
| Bailian MCP marketplace discovery / call | `bl mcp list` / `tools` / `call` | — |
| Register or remove a Bailian MCP in an Agent | `bl mcp connect` / `disconnect` | Codex, Claude Code, Cursor, Qoder, Qoder Work, QwenWork, Qwen Code, Gemini, OpenCode, OpenClaw, DeepSeek Harness, ZCode, WorkBuddy |
| Bailian pipeline workflow (a step in a bl flow) | `bl pipeline run` / `validate` | JSON/YAML workflow definitions |
| Bailian rate limits / quota | `bl quota list` / `check` / `request` | Console auth; class 2 — ask which product first if unnamed |
| Bailian free tier / usage stats | `bl usage free` / `stats` / `freetier` | Console auth; class 2 — ask which product first if unnamed |
| Bailian Token Plan quota usage | `bl usage token-plan` | Console auth; class 2 — ask which product first if unnamed |
| Token Plan harness entitlement quota | `bl token-plan harness-quota` | Console auth; issued quota usage + still-issuing harnesses |
| Bailian Coding Plan quota usage | `bl usage coding-plan` | Console auth; class 2 — ask which product first if unnamed |
| Model monitoring (calls, latency, errors, delivery) | `bl monitor overview` / `models` / `metrics` / `errors` / `delivery *` | Console auth; see [`reference/monitor.md`](reference/monitor.md) |
| Model call logs / traces | `bl log audit *` / `bl log inference *` / `bl log status` / `bl log trace *` | Console auth; audit and inference logs have separate APIs and switches; see [`reference/log.md`](reference/log.md) |
| Model alert rules / templates / history | `bl alert list` / `create` / `update` / `delete` / `enable` / `disable` / `history` / `metrics` / `template *` | Console auth; contacts are managed in the CloudMonitor console; see [`reference/alert.md`](reference/alert.md) |
| Console API (advanced) | `bl console call` | Console auth |
| Bailian workspace listing | `bl workspace list` | Console auth |
| Switch CLI Help / Quick Start language | `bl config set --key language --value zh-CN` | Use `en-US` to switch back; follows the active config profile |
| Image / video / speech / omni / vision | → skill `bailian-gen` | Fallback: `bl image\|video\|speech\|omni\|vision --help` |
| Training dataset / fine-tune / deploy | → skill `bailian-finetune` | Fallback: `bl dataset\|finetune\|deploy --help` |
| agents.yaml IaC / managed-agent sessions | → skill `bailian-managed-agent` | Fallback: `bl managed-agent --help`; `apply`/`destroy` need `--yes` after `plan` |
| Bailian Sandbox instance / template lifecycle | → skill `bailian-sandbox` | Fallback: `bl sandbox --help` |
| Web search (mode-aware routing) | → skill `bailian-web-search` | Default model mode vs explicit `--mode mcp` + fallback; fallback: `bl search web --help` |
Flags, usage, and examples: see hub [`reference/`](reference/index.md) or `bl <command> --help` — do not guess flags. Domain command details live in the owning skill's `reference/`. Examples in `reference/` stay bare; wrap with Call attribution when running.
---
## Quick examples
```bash
bl text chat --message "Write a poem about spring in Chinese"
bl decision --workspace-id <id> --state "Is this requesting a refund?" --questions '{"refund":{"type":"noul"}}'
bl app list --output json
bl app call --app-id <code> --prompt "Hello"
bl usage stats
bl model list --model qwen
```
More examples per command: see `reference/<group>.md` (e.g. [`reference/text.md`](reference/text.md), [`reference/app.md`](reference/app.md)).
---
## Agent workflows
### Find and call an app
1. `bl app list --name <keyword> --output json`
2. Pick `code` (app ID); handle `user_prompt_params` via `--biz-params '{"key":"value"}'`
3. `bl app call --app-id <code> --prompt "..."`
### Batch 文件工作流
1. 文件推理统一使用异步任务。读取 `reference/batch.md` 的数据样例;CSV 用 `bl batch convert` 构造,已有标准 Batch JSONL 可直接使用。
2. `batch create --dry-run` 完整校验;确认模型、数据上传和费用后创建任务。create 上传/提交后返回任务 ID,不等待完成。
3. 用返回的 ID 执行 `batch get --follow` 等待终态,再 `batch download --csv` 下载。Ctrl-C 仅结束本地等待;JSONL 为保真产物,CSV 为有损展示。下载部分失败保留原文件,确认目标后按提示用 `--force` 恢复。
单次同步推理使用 `text chat --batch`,通过 message 或 messages-file 提供同一请求的对话上下文,不用于独立请求文件;命令等待该次响应,不创建任务 ID。Batch 不适用于 Token Plan;显式 Batch/自定义代理使用现有解析凭证,不推断 Key 类型。端点、请求超时及互斥参数见 `reference/text.md`。
### Command metadata for agents
Use the owning skill's [`reference/index.md`](reference/index.md) (or sibling skill reference trees), the matching `reference/<group>.md`,
and `bl <command> --help` as the command schema surface. Do not call removed
schema-export commands.
---
## Routing reminders
- Image/video/audio generation or editing → skill `bailian-gen` (class 3 consent from `bailian-protocol`). Fine-tuning / datasets / deployments → `bailian-finetune`. agents.yaml IaC → `bailian-managed-agent`. Soft hand-off: Read sibling skill if installed; else `bl … --help` or prompt `bl skill init`. Image understanding the host agent can do → host-first; use `bl vision` / `bl omni` only when the user names a Bailian model or the media (video/audio files) exceeds host capability.
- Web search inside a Bailian workflow → skill `bailian-web-search` (routing: default `bl search web` model mode for every identity; explicit `--mode mcp` for regular keys; MCP failure → fall back once). Generic web research the host can do stays host-first — do not bounce it through `bl`.
- Answer ordinary reasoning, coding, writing, translation, summarization, and generic research with the host agent's native capabilities; do not bounce them through `bl text chat` or `bl search web`.
- Usage / quota / credits questions that do not name a product → ask which product (Bailian or another AI service) first; run `bl usage` / `bl quota` only after the user picks Bailian or Bailian context is already established.
- Personal recall, new long-term personal facts, and "remember this" requests → read `bailian-memory` if installed to check enablement, including first-use onboarding. Once enabled, use it for authorized personal recall/extraction; installation alone does not authorize cloud uploads. If unavailable or declined, respect the user’s host-memory choice. Explicit Bailian memory resource operations also route to `bailian-memory`.
- `bl file upload` and `bl pipeline run` are steps inside a Bailian workflow; do not use them to capture generic "upload this file" or "run a pipeline" requests.
- For `risk: high` commands or `requires_confirmation`, follow the shared protocol; never add `--yes` automatically.
- `bl managed-agent apply` / `destroy` have an additional domain rule: run `plan` first and show the diff before asking for confirmation.
- When a matched `bl` command accepts a file URL, pass local paths directly; never require the user to host the file first.
- Console login → use `bl auth login --console` for China; add `--console-site international` for the international site. It may create an ordinary API Key. Token Plan and other subscription plans must use `bl auth login --api-key <key>`. See [`../bailian-protocol/assets/setup.md`](../bailian-protocol/assets/setup.md#authentication).