All Products
Search
Document Center

Alibaba Cloud Model Studio:Batch inference

Last Updated:Nov 05, 2026

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]
ParameterTypeRequiredDescription
--file <csv>stringyesUTF-8 CSV with headers
--output-file <jsonl>stringyesLocal JSONL output path
--model <model>stringyesModel for every record
--id-column <name>stringnoID column (default: custom_id)
--input-column <name>stringnoInput column (default: content)
--system <text>stringnoShared system prompt (Chat only)
--body-file <json>stringnoShared body parameters, excluding model, messages, or input
--endpoint </v1/chat/completions|/v1/embeddings|/v1/chat/ds-test>stringnoBatch endpoint, inferred from the local JSONL
--forceswitchnoReplace 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]
ParameterTypeRequiredDescription
--file <jsonl>stringnoLocal Batch JSONL (exclusive with --input-file-id)
--input-file-id <source>stringnoFile ID, OSS HTTPS URL, or oss:region:bucket/path
--completion-window <24h|7d>stringnoCompletion window: 24–336 hours (default: 24h)
--name <text>stringnoTask name (max 100 characters)
--description <text>stringnoTask description (max 200 characters)
--callback-url <url>stringnoCompletion callback; currently documented for the China (Beijing) region only
--metadata <KEY=VALUE>arraynoCustom task metadata (repeatable)
--endpoint </v1/chat/completions|/v1/embeddings|/v1/chat/ds-test>stringnoBatch 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-model is 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>]
ParameterTypeRequiredDescription
--batch-id <id>stringyesBatch task ID
--followswitchnoPoll until a terminal state (Ctrl-C stops only local polling)
--interval <seconds>numbernoQuery interval, min 60s (default: 65s; --follow only)
--poll-timeout <seconds>numbernoTotal 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.
  • finalizing and cancelling are 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>]
ParameterTypeRequiredDescription
--limit <n>numbernoPage size: 1–100 (default: 20)
--after <id>stringnoPrevious page last_id
--name <text>stringnoTask name filter
--input-file-id <id>arraynoInput file filter (repeatable, max 20)
--status <status>arraynoTask status filter (repeatable): validating, in_progress, finalizing, completed, failed, expired, cancelling, cancelled
--created-after <yyyyMMddHHmmss>stringnoCreated after this API timestamp
--created-before <yyyyMMddHHmmss>stringnoCreated before this API timestamp

Example: List completed and failed tasks

bl batch list --status completed --status failed --limit 20
  • Returns data, last_id, and has_more. Pass last_id to --after for 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>
ParameterTypeRequiredDescription
--batch-id <id>stringyesBatch task ID

Example: Request task cancellation

bl batch cancel --batch-id batch_xxx
  • An accepted cancellation may return cancelling, not cancelled. Use batch get --follow to 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]
ParameterTypeRequiredDescription
--batch-id <id>stringyesBatch task ID
--out-dir <path>stringnoOutput directory (default: ./batch-results/<batch-id>/)
--csvswitchnoAlso generate result.csv (lossy display projection)
--forceswitchnoReplace 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, and error.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 --force to recover.

For a synchronous single request, use bl text chat --batch. It does not create an asynchronous task. See Text chat and Omni.