Batch Tasks
The Batch API submits large volumes of model requests asynchronously: write the requests into a JSONL file and upload it, create a batch, and the platform completes execution within a 24-hour window. You then download the success/failure result files and match them by
custom_id. The API is shaped identically to the OpenAI Batch API.Throughout this document, a "batch" is the batch object defined by the OpenAI Batch API. Endpoint paths, field names and error codes consistently use
batch(for example/v1/batches,"object": "batch",batch_not_found).This documentation covers the Files API and the Batches API: read "API Overview" first to understand the common conventions and data structures, then consult Files API, Batches API, Workflow and Error Codes as needed.
Data permissions
All Batch APIs isolate data strictly by API Key: files, batches and result files are visible only to the API Key that created them, and list endpoints return only the data belonging to the current API Key. Different API Keys under the same account or the same enterprise are likewise invisible to one another. See Data Visibility.
Capabilities & Limits
- Supported endpoint: currently only
/v1/chat/completions(OpenAI-compatible chat completion). - One model, one endpoint: all requests in a batch must use the same model and the same endpoint, and each
custom_idmust be unique. - Completion window: fixed at
24h(completion_window=24h; after creation,expires_at = created_at + 24h). - Status semantics:
completedonly means processing has finished, not that every request succeeded. Checkrequest_countsfor the number of succeeded/failed rows. - Result matching: result row order is not guaranteed, so callers must match rows by
custom_id.
Batch submission limits (per API Key):
| Limit | Default | Response when exceeded |
|---|---|---|
| In-progress batches | 20 | 429 batch_limit_exceeded |
| Pending rows | 200,000 | 429 batch_limit_exceeded |
| Pending bytes | 500 MB | 429 batch_limit_exceeded |
Common Conventions
Base URL & Authentication
- Base URL:
https://neolink.com/api - Authentication: all endpoints take the API Key in the header
Authorization: Bearer <api-key>Data Visibility
All Batch APIs isolate data strictly by API Key: whether data is visible or operable is determined solely by the API Key in the request header. Different API Keys under the same account or the same enterprise are also invisible to, and inoperable by, one another.
- Files:
GET /v1/files,GET /v1/files/{id},GET /v1/files/{id}/contentandDELETE /v1/files/{id}can only operate on files uploaded by the current API Key. Result files (batch_output/batch_error) belong to the API Key that created the batch. - Batches:
GET /v1/batches,GET /v1/batches/{id}andPOST /v1/batches/{id}/cancelcan only operate on batches created by the current API Key. - List isolation: file lists and batch lists return only the data belonging to the current API Key. They never include files uploaded or batches created by other API Keys, including other API Keys under the same account or enterprise.
- Reference validation: when creating a batch,
input_file_idmust belong to the current API Key, otherwise404 file_not_foundis returned. The models in the file must also be within the callable scope of the current API Key, otherwise403 model_access_deniedis returned. - No existence disclosure: accessing a file or batch that does not belong to the current API Key always returns
404 file_not_found/404 batch_not_foundrather than403, so the API never reveals whether the resource actually exists. - Independent quotas: submission limits such as in-progress batches, pending rows and pending bytes are calculated separately per API Key.
Recommendation
A complete batch flow (upload → create batch → poll → download results) must always use the same API Key. After switching to a different API Key, you can no longer read the previously uploaded files, batches or their result files.
Response Format
Batch APIs return OpenAI-shaped objects directly and do not use a success/message/data envelope.
On success, the top level of the response body is the file object, the batch object, or the list object.
On failure (business error):
{
"error": {
"message": "Error description",
"type": "invalid_request_error",
"param": "file",
"code": "invalid_jsonl"
}
}| Field | Type | Description |
|---|---|---|
message | string | Error description |
type | string | invalid_request_error / permission_error / insufficient_quota / rate_limit_exceeded / server_error |
param | string | Name of the offending parameter; "" when there is no corresponding parameter |
code | string | Machine-readable error code, see Error Codes |
Input JSONL Format
The file is JSONL with one JSON object per line:
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"glm-5.3","messages":[{"role":"user","content":"one"}]}}
{"custom_id":"req-2","method":"POST","url":"/v1/chat/completions","body":{"model":"glm-5.3","messages":[{"role":"user","content":"hello"}]}}
{"custom_id":"req-3","method":"POST","url":"/v1/chat/completions","body":{"model":"glm-5.3","messages":[{"role":"user","content":"continue"}]}}| Field | Required | Description |
|---|---|---|
custom_id | Yes | Row identifier: non-empty, ≤256 characters, unique within the batch. Result rows are matched by this field |
method | No | Only POST is allowed; treated as POST when omitted |
url | Yes | Must be /v1/chat/completions, identical across all rows, and equal to the endpoint used when creating the batch |
body | Yes | Request body for that row (a JSON object). Must contain model, and the model must be identical across all rows |
Notes:
- Batch requests are always executed in non-streaming mode;
stream/stream_optionsinside a row have no effect. - Custom fields inside a row are passed through unchanged, and the uploaded input file is never modified.
- Empty lines are ignored; a UTF-8 BOM is allowed on the first line of the file.
Output Data Objects
File Object
{
"id": "file-fa7326de39c3402cbc12007522f78c69",
"object": "file",
"bytes": 1024,
"created_at": 1764031200,
"filename": "batch1.jsonl",
"purpose": "batch"
}| Field | Type | Description |
|---|---|---|
id | string | File identifier, in the form file-<32-char hex> |
object | string | Always file |
bytes | int64 | File size in bytes |
created_at | int64 | Creation time, Unix seconds |
filename | string | File name |
purpose | string | batch (uploaded by the caller) / batch_output (success results) / batch_error (failure results) |
Batch Object
{
"id": "batch-63c583173a0a472bb8d3e48207041690",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-51428aca4e0a47808012aaa03d1734ff",
"completion_window": "24h",
"status": "completed",
"output_file_id": "file-fa7326de39c3402cbc12007522f78c69",
"error_file_id": "file-1234deadbeef",
"created_at": 1764031200,
"in_progress_at": 1764031215,
"expires_at": 1764117600,
"finalizing_at": 1764031300,
"completed_at": 1764031310,
"cancelling_at": null,
"cancelled_at": null,
"expired_at": null,
"failed_at": null,
"request_counts": { "total": 4, "completed": 3, "failed": 1 },
"metadata": { "job": "nightly" },
"error_total": 1,
"warning_message": "Pricing was abnormal for 2 result rows; they were billed as 0"
}| Field | Type | Description |
|---|---|---|
id | string | Batch identifier, in the form batch-<32-char hex> |
object | string | Always batch |
endpoint | string | Batch endpoint; currently only /v1/chat/completions |
errors | array | null | Batch-level error details [{code, message, param?}]; null under normal conditions |
error_total | int | Total number of error details; a platform extension field, omitted when 0 |
input_file_id | string | Input file identifier |
completion_window | string | Always echoed back as 24h |
status | string | Batch status, see "Batch Status" |
output_file_id | string | Success result file identifier. Only present when the batch has finished and has succeeded rows; otherwise the field is omitted |
error_file_id | string | Failure result file identifier. Only present when the batch has finished and has failed rows; otherwise the field is omitted |
created_at | int64 | Creation time, Unix seconds |
in_progress_at | int64 | null | Time execution started; null if not started |
expires_at | int64 | null | Expiration time, equal to created_at + 24h |
finalizing_at | int64 | null | Time the platform started generating result files |
completed_at | int64 | null | Time processing finished (completed / failed / expired) |
cancelling_at | int64 | null | Time the cancellation request was accepted |
cancelled_at | int64 | null | Time cancellation completed |
expired_at | int64 | null | Time the batch expired |
failed_at | int64 | null | Time the batch failed |
request_counts | object | {total, completed, failed}: total rows, succeeded rows, failed rows |
metadata | object | String key-value pairs submitted when creating the batch, echoed back unchanged; {} when not submitted |
warning_message | string | Platform extension field: non-failure warning messages, omitted when there is no warning |
Batch Status
| Status | Meaning | Terminal |
|---|---|---|
validating | Accepted and being prepared for execution | No |
in_progress | Executing | No |
finalizing | Generating result files | No |
cancelling | Being cancelled | No |
completed | Processing finished (does not mean all rows succeeded) | Yes |
cancelled | Cancelled | Yes |
expired | Exceeded the 24-hour window | Yes |
failed | Batch failed (for example a service error made the batch unexecutable) | Yes |
Typical transitions: validating → in_progress → finalizing → completed; cancellation goes validating/in_progress → cancelling → cancelled; expiration goes → expired.
Result File Lines
output_file_id and error_file_id point to platform-hosted result files. Their content is OpenAI Batch-shaped JSONL, and every row contains at least custom_id and id.
Succeeded row:
{"id":"req-1","custom_id":"req-1","response":{"status_code":200,"body":{"id":"...","object":"chat.completion","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":20,"total_tokens":30}}},"error":null}Failed row:
{"id":"req-2","custom_id":"fail-1","response":{"status_code":400,"body":{"error":{"code":"invalid_request","message":"..."}}},"error":{"code":"invalid_request","message":"..."}}request_counts.completedequals the number of rows in the output file, andrequest_counts.failedequals the number of rows in the error file.- Result files cannot be deleted before their owning batch has finished processing.
