Batch
Batch API for asynchronous bulk request processing.
Inherits: EndPoint
# 1. build a .jsonl file of requests and upload it
data := FileReader->ReadFile("requests.jsonl")->ToByteArray();
file := File->Create("requests.jsonl", "batch", data, token);
# 2. create a batch job
job := Batch->Create(file->GetId(), "/v1/chat/completions", token);
job->ToString()->PrintLine();
# 3. poll until done
job = Batch->Get(job->GetId(), token);
"Status: {$job->GetStatus()}"->PrintLine();Operations
Cancel
Cancel a running batch job
function : Cancel(batch_id:String, token:String) ~ BatchJobParameters
| Name | Type | Description |
|---|---|---|
| batch_id | String | batch ID |
| token | String | API key |
Return
| Type | Description |
|---|---|
| BatchJob | updated batch job, Nil on error |
Create
Create a batch job with the 24-hour completion window
function : Create(file_id:String, endpoint:String, token:String) ~ BatchJobParameters
| Name | Type | Description |
|---|---|---|
| file_id | String | uploaded .jsonl file ID |
| endpoint | String | target API endpoint (e.g. '/v1/chat/completions') |
| token | String | API key |
Return
| Type | Description |
|---|---|
| BatchJob | created batch job, Nil on error |
Create
Create a batch job with a custom completion window
function : Create(file_id:String, endpoint:String, completion_window:String, token:String) ~ BatchJobParameters
| Name | Type | Description |
|---|---|---|
| file_id | String | uploaded .jsonl file ID |
| endpoint | String | target API endpoint |
| completion_window | String | time allowed for completion (only '24h' is currently supported) |
| token | String | API key |
Return
| Type | Description |
|---|---|
| BatchJob | created batch job, Nil on error |
Get
Retrieve a batch job by ID
function : Get(batch_id:String, token:String) ~ BatchJobParameters
| Name | Type | Description |
|---|---|---|
| batch_id | String | batch ID |
| token | String | API key |
Return
| Type | Description |
|---|---|
| BatchJob | batch job, Nil on error |