Skip to content

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_id must be unique.
  • Completion window: fixed at 24h (completion_window=24h; after creation, expires_at = created_at + 24h).
  • Status semantics: completed only means processing has finished, not that every request succeeded. Check request_counts for 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):

LimitDefaultResponse when exceeded
In-progress batches20429 batch_limit_exceeded
Pending rows200,000429 batch_limit_exceeded
Pending bytes500 MB429 batch_limit_exceeded

Common Conventions ​

Base URL & Authentication ​

  • Base URL: https://neolink.com/api
  • Authentication: all endpoints take the API Key in the header
http
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}/content and DELETE /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} and POST /v1/batches/{id}/cancel can 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_id must belong to the current API Key, otherwise 404 file_not_found is returned. The models in the file must also be within the callable scope of the current API Key, otherwise 403 model_access_denied is 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_found rather than 403, 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):

json
{
  "error": {
    "message": "Error description",
    "type": "invalid_request_error",
    "param": "file",
    "code": "invalid_jsonl"
  }
}
FieldTypeDescription
messagestringError description
typestringinvalid_request_error / permission_error / insufficient_quota / rate_limit_exceeded / server_error
paramstringName of the offending parameter; "" when there is no corresponding parameter
codestringMachine-readable error code, see Error Codes

Input JSONL Format ​

The file is JSONL with one JSON object per line:

jsonl
{"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"}]}}
FieldRequiredDescription
custom_idYesRow identifier: non-empty, ≤256 characters, unique within the batch. Result rows are matched by this field
methodNoOnly POST is allowed; treated as POST when omitted
urlYesMust be /v1/chat/completions, identical across all rows, and equal to the endpoint used when creating the batch
bodyYesRequest 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_options inside 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 ​

json
{
  "id": "file-fa7326de39c3402cbc12007522f78c69",
  "object": "file",
  "bytes": 1024,
  "created_at": 1764031200,
  "filename": "batch1.jsonl",
  "purpose": "batch"
}
FieldTypeDescription
idstringFile identifier, in the form file-<32-char hex>
objectstringAlways file
bytesint64File size in bytes
created_atint64Creation time, Unix seconds
filenamestringFile name
purposestringbatch (uploaded by the caller) / batch_output (success results) / batch_error (failure results)

Batch Object ​

json
{
  "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"
}
FieldTypeDescription
idstringBatch identifier, in the form batch-<32-char hex>
objectstringAlways batch
endpointstringBatch endpoint; currently only /v1/chat/completions
errorsarray | nullBatch-level error details [{code, message, param?}]; null under normal conditions
error_totalintTotal number of error details; a platform extension field, omitted when 0
input_file_idstringInput file identifier
completion_windowstringAlways echoed back as 24h
statusstringBatch status, see "Batch Status"
output_file_idstringSuccess result file identifier. Only present when the batch has finished and has succeeded rows; otherwise the field is omitted
error_file_idstringFailure result file identifier. Only present when the batch has finished and has failed rows; otherwise the field is omitted
created_atint64Creation time, Unix seconds
in_progress_atint64 | nullTime execution started; null if not started
expires_atint64 | nullExpiration time, equal to created_at + 24h
finalizing_atint64 | nullTime the platform started generating result files
completed_atint64 | nullTime processing finished (completed / failed / expired)
cancelling_atint64 | nullTime the cancellation request was accepted
cancelled_atint64 | nullTime cancellation completed
expired_atint64 | nullTime the batch expired
failed_atint64 | nullTime the batch failed
request_countsobject{total, completed, failed}: total rows, succeeded rows, failed rows
metadataobjectString key-value pairs submitted when creating the batch, echoed back unchanged; {} when not submitted
warning_messagestringPlatform extension field: non-failure warning messages, omitted when there is no warning

Batch Status ​

StatusMeaningTerminal
validatingAccepted and being prepared for executionNo
in_progressExecutingNo
finalizingGenerating result filesNo
cancellingBeing cancelledNo
completedProcessing finished (does not mean all rows succeeded)Yes
cancelledCancelledYes
expiredExceeded the 24-hour windowYes
failedBatch 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:

json
{"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:

json
{"id":"req-2","custom_id":"fail-1","response":{"status_code":400,"body":{"error":{"code":"invalid_request","message":"..."}}},"error":{"code":"invalid_request","message":"..."}}
  • request_counts.completed equals the number of rows in the output file, and request_counts.failed equals the number of rows in the error file.
  • Result files cannot be deleted before their owning batch has finished processing.