LAS 为您提供多个在线算子 API,您可单个调用对应算子 API,同时,LAS 也为您提供了批量提交算子任务的批任务(Batch Task) API,通过 Batch Task API,您可通过一次批任务同时提交多个算子子任务,可减少 submit/poll API 使用次数,减少等待时 client 端资源占。本文为您介绍 Batch Task 涉及的 API 列表、参数介绍及使用示例。
Batch Task 为您提供了 submit、get、list 等接口,通过 Batch Task 的 submit 接口提交批任务时,您可以指定本次批任务包含哪些算子处理的子任务,将子任务的任务详情通过 input.json 文件上传到 TOS,Batch Task 读取 TOS 中需要批量处理的子任务列表后,批量提交子任务,并将任务处理结果写回 TOS 指定的输出路径中。
task_id(复用现有 submit/poll 异步任务)。results.jsonl 与 errors.jsonl。批任务以“文件驱动”的方式运行:您需要上传输入文件到 TOS,服务端负责拆分、编排、聚合。
细分 | 详细说明 |
|---|---|
格式规范 | 输入文件为 JSONL,每行是一个 JSON 对象(一个算子子任务)。以 PDF 算子为例:
字段说明:
|
输入文件限制 |
|
输入 TOS 路径 | 通过批任务的
|
批任务完成后在指定 TOS 输出目录下写入标准化结果文件。
细分 | 详细说明 |
|---|---|
格式规范 |
处理结果文件中包含:
|
处理结果文件中包含:
| |
输出 TOS 路径 | 通过批任务的
|
细分项 | 准备工作说明 |
|---|---|
获取 LAS API Key | 提交批任务前,您需要先生成算子调用的API Key,并建议将API Key配置为环境变量,便于更安全地调用算子,详情请参见获取 API Key 并配置。 |
获取 BaseURL | 提交批任务前,您需要先根据您当前使用的LAS服务所在地域,了解算子调用的BaseURL,用于配置算子调用路径参数取值。 |
规划输入与输出 JSON 文件的 TOS 路径 | 提交批任务前,您需要先将本次批任务涉及的子任务,参考对应算子的 API 参数要求,整理好子任务的输入文件,并上传至 TOS;并规划好输出结果文件的输出 TOS 路径,用于提交批任务时配置。 |
使用 submit 创建任务,返回 batch_task_id。
参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | String | 是 | 批任务名称 |
description | String | 否 | 描述信息 |
operator_id | String | 是 | 算子 ID |
operator_version | String | 是 | 算子版本 |
input_tos_url | String | 是 | 批量任务输入文件(TOS 地址) |
output_tos_url | String | 是 | 批量任务输出目录(TOS 目录/前缀) |
extra_params | Object | 否 | 批量任务公共参数;若 JSONL 中有相同参数,按约定由单行参数覆盖公共参数。 |
project_name | String | 否 | 项目名,默认 |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_id | String | 批任务 ID |
# submit curl --location "${BASE_URL}/api/v1/batch-task/submit" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${API_KEY}" \ --data '{ "name": "demo_batch_task", "description": "batch task demo", "operator_id": "las_long_video_understand", "operator_version": "v1", "input_tos_url": "tos://liuliu-test/batch_task_test/input_1.jsonl", "output_tos_url": "tos://liuliu-test/batch_task_test/output/", "extra_params": { "model_name": "doubao-seed-2-0-lite-260215" }, "project_name": "default" }'
{ "batch_task_id": "bt-1234567890" }
batch_task_id。status 与 request_counts(total/completed/failed/terminated)。output_tos_url 获取结果文件。参数名称 | 参数类型 | 是否必须 | 默认值 | 说明 |
|---|---|---|---|---|
batch_task_id | String | 是 | 批任务 ID |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_detail | BatchTaskDetail | 批任务详情 |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_id | String | 批任务 ID |
name | String | 批任务名称 |
description | String | 描述信息 |
input_tos_url | String | 批量任务输入文件的 TOS 地址 |
output_tos_url | String | 批量任务输出目录的 TOS 地址 |
status | String | 批任务状态 |
request_counts | RequestCounts | 批任务请求数量统计 |
create_time | String | 创建时间 |
update_time | String | 更新时间 |
stop_time | String | 停止时间 |
end_time | String | 结束时间 |
error_message | String | 错误信息 |
owner_id | Integer | 创建者 ID |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
total | Long | 请求总数 |
completed | Long | 已完成请求数 |
failed | Long | 失败请求数 |
terminated | Long | 已终止请求数 |
# get curl --location "${BASE_URL}/api/v1/batch-task/get" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${API_KEY}" \ --data "{\n \"batch_task_id\": \"${BATCH_TASK_ID}\"\n }"
{ "batch_task_detail": { "batch_task_id": "bt-1234567890", "name": "demo_batch_task", "description": "batch task demo", "input_tos_url": "tos://liuliu-test/batch_task_test/input_100.jsonl", "output_tos_url": "tos://liuliu-test/batch_task_test/output/", "status": "RUNNING", "request_counts": { "total": 100, "completed": 80, "failed": 2, "terminated": 0 }, "create_time": "2026-07-13T03:10:11Z", "update_time": "2026-07-13T03:20:00Z", "stop_time": "", "end_time": "", "error_message": "", "owner_id": 12345678 } }
用于批量查看任务列表。
参数名称 | 参数类型 | 是否必须 | 默认值 | 说明 |
|---|---|---|---|---|
batch_task_ids | Array | 否 | 批任务 ID 过滤 | |
batch_task_name | String | 否 | 批任务名称过滤,支持模糊查询 | |
statuses | Array | 否 | 状态过滤 | |
owner_ids | Array | 否 | 创建者 ID 过滤 | |
sort_order | String | 否 | Desc | 排序顺序 |
sort_by | String | 否 | 排序字段 | |
max_results | Integer | 否 | 10 | 单页记录数 |
next_token | String | 否 | 0 | 下一次查询起始 ID(不包含)或页码 |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
items | Array | 批任务简要信息列表 |
total_count | Long | 总记录数 |
max_results | Integer | 单次查询可返回的最大记录数 |
next_token | String | 下一次查询起始 ID(不包含)或页码 |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_id | String | 批任务 ID |
name | String | 批任务名称 |
description | String | 描述信息 |
output_tos_url | String | 批量任务输出目录的 TOS 地址 |
status | String | 批任务状态 |
completion_window | Integer | 批量任务的最大等待时间,单位小时 |
request_counts | RequestCounts | 批任务请求数量统计 |
create_time | String | 创建时间 |
stop_time | String | 停止时间 |
end_time | String | 结束时间 |
error_message | String | 错误信息 |
owner_id | Integer | 创建者 ID |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
total | Long | 请求总数 |
completed | Long | 已完成请求数 |
failed | Long | 失败请求数 |
terminated | Long | 已终止请求数 |
# list curl --location "${BASE_URL}/api/v1/batch-task/list" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${API_KEY}" \ --data "{\n \"batch_task_ids\": [\"batch_001\", \"batch_002\"],\n \"batch_task_name\": \"demo\",\n \"statuses\": [\"QUEUED\", \"RUNNING\", \"FAILED\"],\n \"owner_ids\": [12345678],\n \"sort_order\": \"Desc\",\n \"sort_by\": \"update_time\",\n \"max_results\": 10,\n \"next_token\": \"0\"\n }"
{ "items": [ { "batch_task_id": "bt-1234567890", "name": "demo_batch_task", "description": "batch task demo", "output_tos_url": "tos://liuliu-test/batch_task_test/output/", "status": "RUNNING", "completion_window": 24, "request_counts": { "total": 100, "completed": 80, "failed": 2, "terminated": 0 }, "create_time": "2026-07-13T03:10:11Z", "stop_time": "", "end_time": "", "error_message": "", "owner_id": 12345678 } ], "total_count": 1, "max_results": 10, "next_token": "0" }
当需要终止执行时:
batch_task_id。TERMINATING,最终到 TERMINATED。说明
如果任务已生成部分结果,建议仍按 custom_id 规则消费已产出的 results.jsonl / errors.jsonl。
参数名称 | 参数类型 | 是否必须 | 说明 |
|---|---|---|---|
batch_task_id | String | 是 | 批任务 ID |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_id | String | 已接受停止操作的批任务 ID |
# stop curl --location "${BASE_URL}/api/v1/batch-task/stop" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${API_KEY}" \ --data "{\n \"batch_task_id\": \"${BATCH_TASK_ID}\"\n }"
{ "batch_task_id": "bt-1234567890" }
update 用于更新批任务的元信息(如 name、description)。
参数名称 | 参数类型 | 是否必须 | 说明 |
|---|---|---|---|
batch_task_id | String | 是 | 批任务 ID |
name | String | 否 | 批任务名称 |
description | String | 否 | 描述信息 |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_id | String | 批任务 ID |
# update curl --location "${BASE_URL}/api/v1/batch-task/update" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${API_KEY}" \ --data "{\n \"batch_task_id\": \"${BATCH_TASK_ID}\",\n \"name\": \"demo_batch_task_updated\",\n \"description\": \"updated description\"\n }"
{ "batch_task_id": "bt-1234567890" }
delete 用于删除批任务(控制面操作),通常用于清理不再需要的任务记录。
参数名称 | 参数类型 | 是否必须 | 说明 |
|---|---|---|---|
batch_task_id | String | 是 | 批任务 ID |
参数名 | 参数类型 | 参数描述 |
|---|---|---|
batch_task_id | String | 已接受删除操作的批任务 ID |
# delete curl --location "${BASE_URL}/api/v1/batch-task/delete" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${API_KEY}" \ --data "{\n \"batch_task_id\": \"${BATCH_TASK_ID}\"\n }"
{ "batch_task_id": "bt-1234567890" }
status | 含义 |
|---|---|
QUEUED | 批任务当前在排队中 |
INITIALIZING | 初始化中(拆分 JSONL 等准备阶段) |
RUNNING | 运行中(提交/回调/轮询/聚合) |
FAILED | 批任务失败(系统级失败或达到停止条件),例如 TOS 路径不存在等 |
TERMINATING | 终止中 |
TERMINATED | 已终止 |
DELETING | 删除中 |
DELETED | 已删除 |
现象 | 可能原因 | 处理建议 |
|---|---|---|
任务失败(status=FAILED) | 输入文件不可读、TOS 权限错误、持续超时等系统级失败 | 检查 |
部分子任务失败( | 单行参数非法、资源不可达、业务侧失败等 | 按 |