Skip to content
  • There are no suggestions because the search field is empty.

Batch API Reference

Create large batches of API requests for asynchronous processing. The Batch returns completions within 24 hours.

Create Batch

Creates and executes a batch from an uploaded file of requests.

Request

POST https://api.core42.ai/batch-api/v1/batches

Request Parameters

Name

Required

Type

Description

input_file_id

true

string

The ID of an uploaded file that contains requests for the new batch. Your input file must be formatted as a JSONL file and must be uploaded with the purpose, batch.

endpoint

true

string

The endpoint to use for all requests in the batch. The supported endpoint is /v1/chat/completions.

completion_window

true

string

The time frame within which the batch should be processed. Currently, only 24h is supported.

metadata

false

object or null

Optional custom metadata for the batch.

Retrieve Batch

Retrieves a batch.

Request

GET https://api.core42.ai/batch-api/v1/batches/{batch_id}

Request Parameters

Name 

Required

Type

Description

batch_id

true

string

The ID of the batch to retrieve.

Cancel Batch

Cancels an in-progress batch. The batch will be in status cancelling for up to 10 minutes, before changing to cancelled, where it will have partial results (if any) available in the output file.

Request

POST https://api.core42.ai/batch-api/v1/batches/{batch_id}/cancel

Request Parameters 

Name 

Required 

Type 

Description 

batch_id

true

string

The ID of the batch to cancel.

List Batch

List your batches.

Request

GET https://api.core42.ai/batch-api/v1/batches

Request Parameters 

Name 

Required 

Type 

Description 

after

false

string

A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

limit

false

integer

A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 20.

 The Batch Object

Name 

Required 

Type 

Description 

id

false

string

N/A

object

false

string

The object type, is always batch.

endpoint

false

string

The API endpoint used by the batch.

errors

false

object

N/A

object

false

string

The object type, which is always list.

data

false

array

N/A

code

false

string

An error code identifying the error type.

message

false

string

A human-readable message providing more details about the error.

param

false

string or null

The name of the parameter that caused the error, if applicable.

line

false

string

The line number of the input file where the error occurred, if applicable.

input_file_id

false

string

The ID of the input file for the batch.

completion_window

false

string

The time frame within which the batch should be processed.

status

false

string

The current status of the batch.

output_file_id

false

string

The ID of the file containing the outputs of successfully executed requests.

error_file_id

false

string

The ID of the file containing the outputs of requests with errors.

created_at

false

integer

The Unix timestamp (in seconds) when the batch was created.

in_progress_at

false

integer

The Unix timestamp (in seconds) when the batch started processing.

expires_at

false

integer

The Unix timestamp (in seconds) when the batch will expire.

finalizing_at

false

integer

The Unix timestamp (in seconds) when the batch started finalizing.

completed_at

false

integer

The Unix timestamp (in seconds) when the batch was completed.

failed_at

false

integer

The Unix timestamp (in seconds) when the batch failed.

expired_at

false

integer

The Unix timestamp (in seconds) when the batch expires.

cancelling_at

false

integer

The Unix timestamp (in seconds) when the batch started cancelling.

cancelled_at

false

integer

The Unix timestamp (in seconds) when the batch was cancelled.

request_counts

false

integer

The request counts for different statuses within the batch.

total

false

integer

Total number of requests in the batch.

completed

false

integer

Number of requests that have been completed successfully.

failed

false

integer

Number of requests that have failed.

metadata

false

map

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

The Request Input Object

The per-line object of the batch input file. 

Name

 

Required

 

Type

 

Description

 

custom_id

false

string

A developer-provided per-request ID that will be used to match outputs to inputs. Must be unique for each request in a batch.

method

false

string

The HTTP method is to be used for the request. Only POST is supported.

url

false

string

The URL is to be used for the request. The supported endpoint is /v1/chat/completions.

The Request Output Object

The per-line object of the batch output and error files.

Name 

Required 

Type 

Description

id

false

string

N/A

custom_id

false

string

A developer-provided per-request ID that will be used to match outputs to inputs.

response

false

object or null

N/A

status_code

false

integer

The HTTP status code of the response.

request_id

false

string

A unique identifier for the API request. Please include this request ID when contacting support.

body

false

map

The JSON body of the response.

error

false

object or null

For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure.

code

false

string

A machine-readable error code.

message

false

string

A human-readable error message.