Workflow
A complete Batch call has four steps: upload the input file → create the batch → poll the status → download the results. Below are the flow description and ready-to-run examples.
Flow Overview
1. POST /v1/files Upload the JSONL file (purpose=batch) → file-xxx
2. POST /v1/batches Create a batch using input_file_id → batch-xxx (validating)
3. GET /v1/batches/{id} Poll the status until the batch finishes
4. GET /v1/files/{output_file_id}/content Download the success result JSONL
GET /v1/files/{error_file_id}/content Download the failure result JSONL (if any)Terminal statuses are completed, cancelled, expired and failed.
Use the same API Key
Files, batches and result files belong entirely to the API Key that uploaded / created them, so all four steps must use the same API Key. Switching to a different API Key midway (even within the same account or enterprise) results in 404 when reading or downloading. See API Overview · Data Visibility.
Step 1: Upload the Input File
Prepare a JSONL file. For the complete format, see API Overview · Input JSONL Format. Example:
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"glm-5.3","messages":[{"role":"user","content":"one"}]}}curl --request POST \
--url 'https://neolink.com/api/v1/files' \
--header 'Authorization: Bearer <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form 'purpose=batch' \
--form 'file=@batch1.jsonl'Take the id from the response as the input_file_id for the next step.
Step 2: Create the Batch
curl --request POST \
--url 'https://neolink.com/api/v1/batches' \
--header 'Authorization: Bearer <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"input_file_id": "file-51428aca4e0a47808012aaa03d1734ff",
"endpoint": "/v1/chat/completions"
}'On successful creation, the returned status is validating.
Step 3: Poll the Batch Status
curl --location 'https://neolink.com/api/v1/batches/batch-63c583173a0a472bb8d3e48207041690' \
--header 'Authorization: Bearer <api-key>'Polling recommendation: after the batch is created, query every 10–30 seconds at first. For the meaning of each field, see Batches API · Retrieve Batch Details.
Step 4: Download the Result Files
# Success results
curl --location 'https://neolink.com/api/v1/files/file-fa7326de39c3402cbc12007522f78c69/content' \
--header 'Authorization: Bearer <api-key>' \
-o output.jsonl
# Failure results (error_file_id is only present when the batch has failed rows)
curl --location 'https://neolink.com/api/v1/files/file-1234deadbeef/content' \
--header 'Authorization: Bearer <api-key>' \
-o error.jsonlResult rows are JSONL and are matched to the input rows by custom_id. For examples, see API Overview · Result File Lines.
To abandon a batch midway, call Cancel a Batch. When a call fails, troubleshoot with Error Codes.
