Bailian CLI command reference for creating, tracking, and downloading asynchronous batch inference tasks.
bl batch converts CSV to Batch JSONL, creates asynchronous Chat or Embedding batch tasks, tracks progress, cancels tasks, and downloads result and error files. Asynchronous file-based batch tasks are separate from the synchronous single-request bl text chat --batch.
Notebatch convert runs locally and needs no authentication. Creating, querying, cancelling, and downloading tasks require a model API Key. Batch availability and limits depend on the model and service.
ImportantAppend --help to any command for full parameter details, e.g. bl batch create --help. Command details on this page are verified against bl 2.8.0.
Quick start
bl batch convert --file input.csv --model qwen-plus --output-file input.jsonl
bl batch create --file input.jsonl
bl batch get --batch-id <batch-id> --follow
bl batch download --batch-id <batch-id> --csv
Task management
bl batch convert
Build Batch JSONL from a UTF-8 CSV locally. No authentication required.
Usage
bl batch convert --file <csv> --model <model> --output-file <jsonl> [flags]
| Parameter | 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, or input |
--endpoint </v1/chat/completions|/v1/embeddings|/v1/chat/ds-test> | string | no | Batch endpoint, inferred from the local JSONL |
--force | switch | no | Replace existing output files (atomic per file) |
Example: Convert CSV to Chat JSONL
bl batch convert --file input.csv --model qwen-plus --output-file input.jsonl
Example: Convert CSV to Embedding JSONL
bl batch convert --file input.csv --model text-embedding-v4 --endpoint /v1/embeddings --output-file vectors.jsonl
- Only text and embedding field mapping is supported. Write JSONL directly for multimodal or multi-turn input.
- IDs remain strings. Import CSV IDs as text in spreadsheet software to keep leading zeros.
- Dry-run makes no business requests and writes no business files.
bl batch create
Upload or reference input and create an asynchronous Batch task. Requires API Key authentication.
Usage
bl batch create (--file <jsonl> | --input-file-id <source> --endpoint <path>) [flags]
| Parameter | 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; currently documented for the China (Beijing) region 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 the local JSONL |
Example: Preview task creation
bl batch create --file input.jsonl --name eval-1 --dry-run
Example: Create a task from a file ID
bl batch create --input-file-id file-batch-xxx --endpoint /v1/chat/completions
Example: Reference an OSS path with a 7-day completion window
bl batch create --input-file-id oss:ap-southeast-1:my-bucket/input.jsonl --endpoint /v1/chat/completions --completion-window 7d
Chat JSONL example:
{"custom_id":"req-001","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen-plus","messages":[{"role":"user","content":"Introduce yourself"}]}}
Embedding JSONL example:
{"custom_id":"req-001","method":"POST","url":"/v1/embeddings","body":{"model":"text-embedding-v4","input":"Introduce yourself","encoding_format":"float"}}
- Local input limits: 50,000 requests, 500 MiB, and 6 MiB per line. Lines above 1 MiB produce a warning.
batch-test-modelis limited to 100 requests and 1 MiB.- Remote references require authorization and a valid URL; the CLI does not download them for validation.
- A successful create returns a task ID without waiting for completion. No POST replay or uploaded-file cleanup occurs on failure.
bl batch get
Get Batch task details, optionally following progress. Requires API Key authentication.
Usage
bl batch get --batch-id <id> [--follow] [--interval <seconds>] [--poll-timeout <seconds>]
| Parameter | Type | Required | Description |
|---|---|---|---|
--batch-id <id> | string | yes | Batch task ID |
--follow | switch | no | Poll until a 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) |
Example: Follow a task until it ends
bl batch get --batch-id batch_xxx --follow
- A single get exits 0 after a successful query regardless of task state.
- With
--follow, exit 0 means completed (may contain failed rows), 1 means failed, expired, or cancelled, 5 means client timeout, and 130 means Ctrl-C. finalizingandcancellingare not terminal.- Progress goes to stderr; the final result goes to stdout.
- Only transport errors, timeouts, or HTTP 429/5xx are retried, up to three times.
- Server retention is limited; download results promptly.
bl batch list
List one page of Batch tasks. Requires API Key authentication.
Usage
bl batch list [filters] [--after <id>] [--limit <n>]
| Parameter | 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 <status> | array | no | Task status filter (repeatable): validating, in_progress, finalizing, completed, failed, expired, cancelling, cancelled |
--created-after <yyyyMMddHHmmss> | string | no | Created after this API timestamp |
--created-before <yyyyMMddHHmmss> | string | no | Created before this API timestamp |
Example: List completed and failed tasks
bl batch list --status completed --status failed --limit 20
- Returns
data,last_id, andhas_more. Passlast_idto--afterfor the next page. - API timestamps are not timezone-converted.
bl batch cancel
Request cancellation of a Batch task. Requires API Key authentication.
Usage
bl batch cancel --batch-id <id>
| Parameter | Type | Required | Description |
|---|---|---|---|
--batch-id <id> | string | yes | Batch task ID |
Example: Request task cancellation
bl batch cancel --batch-id batch_xxx
- An accepted cancellation may return
cancelling, notcancelled. Usebatch get --followto confirm. - Requests already executed still incur charges; files are not deleted.
bl batch download
Download original results or error files, optionally exporting CSV. Requires API Key authentication.
Usage
bl batch download --batch-id <id> [--out-dir <path>] [--csv] [--force]
| Parameter | Type | Required | Description |
|---|---|---|---|
--batch-id <id> | string | yes | Batch task ID |
--out-dir <path> | string | no | Output directory (default: ./batch-results/<batch-id>/) |
--csv | switch | no | Also generate result.csv (lossy display projection) |
--force | switch | no | Replace existing output files (atomic per file) |
Example: Download results and export CSV
bl batch download --batch-id batch_xxx --out-dir ./out --csv
- JSONL is authoritative. CSV reads only
choices[0].message.content, embedding data,response.request_id,status_code, usage, anderror.code/error.message. - CSV omits tool calls and additional choices, and treats formula-like text as text. Import IDs as text to keep leading zeros.
- Original input order is not guaranteed.
- Files are published atomically per file, not per directory. If CSV generation fails, downloaded JSONL is preserved; rerun with
--forceto recover.
Related commands
For a synchronous single request, use bl text chat --batch. It does not create an asynchronous task. See Text chat and Omni.