Skip to main content

Batch Inference

Bailian CLI asynchronous Batch inference: convert CSV to JSONL, create jobs, track progress, cancel, and download results.

Manage asynchronous Batch inference from the terminal: convert CSV to JSONL, create Chat or Embedding batch jobs, track progress, cancel jobs, and download results and error files.
Asynchronous Batch jobs differ from bl text chat --batch. --batch sends one synchronous request; the commands on this page manage file-based asynchronous jobs. For local-file batch inference, use bl batch create with bl batch get / bl batch download.
Append --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.5.

Command reference

bl batch convert

Convert CSV to Batch JSONL 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, and input
--endpoint <path>stringnoBatch endpoint: /v1/chat/completions, /v1/embeddings, or /v1/chat/ds-test; defaults to /v1/chat/completions, and embedding input requires /v1/embeddings
--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 Embedding input with shared body defaults
bl batch convert --file input.csv --model text-embedding-v4 --endpoint /v1/embeddings --body-file defaults.json --output-file vectors.jsonl
The CSV must contain at least custom_id and content:
custom_id,content
req-001,Introduce yourself
req-002,2+2?
Example Chat JSONL output:
{"custom_id":"req-001","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen-plus","messages":[{"role":"user","content":"Introduce yourself"}]}}
  • Only text and Embedding field mapping is supported. Write native JSONL for multimodal or multi-turn input.
  • IDs remain strings. Set the ID column to text in spreadsheet software to keep leading zeros.
  • --dry-run makes no business API calls and writes no business files.

bl batch create

Upload or reference input and create an asynchronous Batch job. Requires API Key authentication. Usage
bl batch create (--file <jsonl> | --input-file-id <source> --endpoint <path>) [flags]
ParameterTypeRequiredDescription
--file <jsonl>stringnoLocal Batch JSONL; mutually 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>stringnoJob name (max 100 characters)
--description <text>stringnoJob description (max 200 characters)
--callback-url <url>stringnoCompletion callback URL (documented for Beijing only)
--metadata <KEY=VALUE>arraynoCustom job metadata (repeatable)
--endpoint <path>stringnoBatch endpoint: /v1/chat/completions, /v1/embeddings, or /v1/chat/ds-test; inferred from local JSONL by default, and required with --input-file-id
Example: Preview job creation
bl batch create --file input.jsonl --name eval-1 --dry-run
Example: Create a job with a 7-day completion window from an OSS file
bl batch create --input-file-id oss:cn-beijing:my-bucket/input.jsonl --endpoint /v1/chat/completions --completion-window 7d
  • Local input is limited to 50,000 requests, 500 MiB, and 6 MiB per line; batch-test-model is limited to 100 requests and 1 MiB. The CLI warns when a line exceeds 1 MiB because documentation limits conflict.
  • Remote references must be authorized and the URL must remain valid. The CLI does not download remote files for validation.
  • A failed create does not replay the POST or clean up uploaded input files.
  • --dry-run makes no business API calls and writes no business files.

bl batch get

Get Batch job details and optionally follow progress. Requires API Key authentication. Usage
bl batch get --batch-id <id> [--follow] [--interval <seconds>] [--poll-timeout <seconds>]
ParameterTypeRequiredDescription
--batch-id <id>stringyesBatch job ID
--followswitchnoPoll until a terminal state; Ctrl-C stops only local polling
--interval <seconds>numbernoQuery interval, minimum 60 seconds (default: 65; --follow only)
--poll-timeout <seconds>numbernoTotal polling budget (default: unlimited; --follow only)
Example: Follow a job to a terminal state
bl batch get --batch-id batch_xxx --follow --interval 65 --poll-timeout 86400
  • A single query exits 0 after a successful request regardless of job state.
  • --follow exits 0 for completed (results may still contain failed rows), 1 for failed, expired, or cancelled, 5 on client timeout, and 130 on Ctrl-C.
  • finalizing and cancelling are not terminal. Progress goes to stderr; the final result goes to stdout.
  • Only transport errors, timeouts, and HTTP 429/5xx are retried, up to 3 times. The service retains results for a limited time; download them promptly.

bl batch list

List Batch jobs one page at a time. 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>stringnoFilter by job name
--input-file-id <id>arraynoFilter by input file (repeatable, max 20)
--status <status>arraynoFilter by job status (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 jobs
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 job. Requires API Key authentication. Usage
bl batch cancel --batch-id <id>
ParameterTypeRequiredDescription
--batch-id <id>stringyesBatch job ID
Example: Request cancellation
bl batch cancel --batch-id batch_xxx
  • An accepted cancellation may return cancelling, not cancelled; use bl batch get --follow to confirm.
  • Already executed requests still incur charges, and input and output files are not deleted.

bl batch download

Download original results or error files, optionally generating CSV. Requires API Key authentication. Usage
bl batch download --batch-id <id> [--out-dir <path>] [--csv] [--force]
ParameterTypeRequiredDescription
--batch-id <id>stringyesBatch job 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 generate 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; tool calls and additional choices are omitted.
  • CSV escapes formula-like text. Set the ID column to text in spreadsheet software to keep leading zeros.
  • Results are not guaranteed to preserve input order. Writes are atomic per file, not per directory; if CSV generation fails, downloaded JSONL is kept and --force can retry.
  • The service retains results for a limited time; download them promptly after the job completes.