API reference · Batches
List the lines of a batch in input order: status, error, tokens and cost
/v1/batches/{batch_id}/lines- TypeScript
client.batches.listLines()- Python
client.batches.list_lines()- CLI
hayonix batches lines
One entry per request line of the input file, in line order, once the batch is validated. Use it to follow a batch line by line, or to find the lines that failed (status=failed) without downloading the error file. Response bodies are in the output file.
Project API key (Authorization: Bearer sk_…), or a console session. Requires the batch:read permission (a key's scope, or a role that includes it).
Examples
The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.
curl -sS "$API_BASE_URL/batches/bat_01jc5zq4m8k3v6x9t2w7r0b1e4/lines" \
-H "Authorization: Bearer $API_KEY"Request
| Header | Required | Description |
|---|---|---|
Authorization | yes | Bearer and your API key. The key implies its project. |
X-Project-Id | session only | The project to act in, for console sessions. Requests with an API key leave it out. |
Path parameters
batch_idstringrequiredID of the batch
ID with prefix bat_
Query parameters
limitinteger1–200, default 50
1–200
cursorstring`next_cursor` of the previous page
up to 200 characters
statusstringOnly lines in this status (default: every line)
One of
pendingrunningcompletedfailed
Response
200 a page of results — A page of lines
The items of this page.
ShowHide 13 fields of
dataobjectstringrequiredAlways `batch_line`: the type of this object
One of
batch_linelineintegerrequiredLine number in the input file, from 1
custom_idstringrequiredThe `custom_id` the line carries
modelstring | nullrequiredModel the line names (null when the line could not be read)
statusstringrequired`pending` (waiting to run, or waiting to be retried), `running`, `completed` (a response is in the output file), `failed` (an error is in the error file)
One of
pendingrunningcompletedfailedstatus_codeinteger | nullrequiredHTTP status of the recorded result (null until there is one)
errorobject | nullrequiredWhy the line failed (null unless `status` is `failed`)
ShowHide 2 fields of
errorcodestringrequiredMachine-readable reason, as in the error file
messagestringrequiredOne sentence for people
last_errorobject | nullrequiredWhy the latest attempt was put back to be retried (for example `model_unavailable` while the model has no running replica); null when none was
ShowHide 2 fields of
last_errorcodestringrequiredMachine-readable reason, as in the error file
messagestringrequiredOne sentence for people
attemptsintegerrequiredTimes the request was sent; retries after a failure count
usageobject | nullrequiredTokens of the completed request (null until it completes)
ShowHide 3 fields of
usageinput_tokensstringrequiredPrompt tokens (decimal string)
cached_input_tokensstringrequiredPrompt tokens served from cache (decimal string)
output_tokensstringrequiredGenerated tokens (decimal string)
coststring | nullrequiredCharged for this line, nano-USD (null until it completes; failures cost 0)
pattern ^-?[0-9]+$
started_atstring (date-time) | nullrequiredWhen its current attempt started (null until it ran)
finished_atstring (date-time) | nullrequiredWhen it completed or failed (null until then)
next_cursorstring | nullrequiredPass as `cursor` for the next page; null on the last page.
Example response
{
"data": [
{
"object": "batch_line",
"line": 1,
"custom_id": "string",
"model": "string",
"status": "pending",
"status_code": 1,
"error": {
"code": "string",
"message": "string"
},
"last_error": {
"code": "string",
"message": "string"
},
"attempts": 1,
"usage": {
"input_tokens": "string",
"cached_input_tokens": "string",
"output_tokens": "string"
},
"cost": "1500000000",
"started_at": "2026-01-01T00:00:00.000Z",
"finished_at": "2026-01-01T00:00:00.000Z"
}
],
"next_cursor": "string"
}Errors
Errors use the standard envelope. What this operation can answer:
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | A parameter or body field is missing or not allowed; param names it. |
401 | authentication_error | The key or session is missing, revoked or expired. |
403 | permission_error | The credential lacks the permission this needs, or the organization is suspended. |
404 | not_found_error | No such resource in this project (an ID from another project is answered the same way). |
429 | rate_limit_error rate_limited | Too many requests; retry after retry-after seconds. |