Skip to main content

batches

Creates, updates, deletes, gets or lists a batches resource.

Overview

Namebatches
TypeResource
Iddigitalocean.inference.batches

Fields

The following fields are returned by SELECT queries:

The batch job.

NameDatatypeDescription
batch_idstring (uuid)Unique identifier for the batch job. (example: 0e9d1d35-3d1e-4d66-9a2f-8c7e0f6b3e21)
error_file_idstring (uuid)Error sidecar file. Null when no errors were produced.
input_file_idstring (uuid)The uploaded JSONL input file. (example: a1b2c3d4-e5f6-4789-90ab-cdef12345678)
output_file_idstring (uuid)Output JSONL file. Populated once the job completes.
request_idstringThe idempotency key supplied at creation. (example: c7e3ad1e-20c3-4e47-9bf2-6f2a4d6a2f11)
cancelled_atstring (date-time) (example: 2026-04-24T19:45:11Z)
completed_atstring (date-time) (example: 2026-04-24T20:15:30Z)
completion_windowstring (24h) (example: 24h)
created_atstring (date-time) (example: 2026-04-24T19:19:19Z)
endpointstringInference endpoint each request is dispatched to. (example: /v1/chat/completions)
errorsarrayTop-level errors that prevented the batch from completing.
expires_atstring (date-time)Derived from created_at plus completion_window. (example: 2026-04-25T19:19:19Z)
failed_atstring (date-time) (example: 2026-04-24T19:50:00Z)
finalizing_atstring (date-time) (example: 2026-04-24T20:10:42Z)
in_progress_atstring (date-time) (example: 2026-04-24T19:20:05Z)
metadataobjectMetadata attached at creation.
providerstring (openai, anthropic) (example: openai)
request_countsobjectAggregate request counts.
statusstringLifecycle status. Terminal states: completed, failed, expired, cancelled. (validating, in_progress, finalizing, completed, failed, expired, cancelling, cancelled) (example: in_progress)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
inference_get_batchselectbatch_idReturns the current state of a batch job. Poll until status reaches a terminal value (completed, failed, expired, or cancelled).
inference_list_batchesselectafter, limit, statusReturns a cursor-paginated list of batch jobs, ordered newest first. Use limit to control page size and after to page forward using the last_id from the previous response.
inference_create_batchinsertfile_id, provider, completion_window, request_idSubmits a batch job against a previously uploaded JSONL input file. The upload must have completed before this call; otherwise the request is rejected.

Supply a unique request_id to make the submission idempotent — retries with the same value return the existing job. When provider is openai, the url on each JSONL line must match endpoint.
inference_cancel_batchexecbatch_idRequests cancellation of a batch job. The job transitions to cancelling and, once in-flight requests drain, to cancelled. Jobs already in a terminal state (completed, failed, expired, cancelled) cannot be cancelled and return 409 Conflict. Cancellation is also rejected with 409 Conflict while the job has not yet been submitted to the upstream provider — there is nothing to cancel until the provider batch id is assigned.

Partial results produced before cancellation remain available via GET /v1/batches/{batch_id}/results.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
batch_idstring (uuid)The batch job identifier. (example: 0e9d1d35-3d1e-4d66-9a2f-8c7e0f6b3e21)
afterstring (uuid)Cursor for pagination. Pass the last_id value from the previous response to fetch the next page. Omit for the first page. (example: 7b2e9c1a-6f4d-4d9b-a0f1-5c4b7e2f8a12)
limitintegerMaximum number of batches to return per page. (example: 20)
statusstringOptional filter restricting results to batches in the given lifecycle state. (example: in_progress)

SELECT examples

Returns the current state of a batch job. Poll until status reaches a terminal value (completed, failed, expired, or cancelled).

SELECT
batch_id,
error_file_id,
input_file_id,
output_file_id,
request_id,
cancelled_at,
completed_at,
completion_window,
created_at,
endpoint,
errors,
expires_at,
failed_at,
finalizing_at,
in_progress_at,
metadata,
provider,
request_counts,
status
FROM digitalocean.inference.batches
WHERE batch_id = '{{ batch_id }}' -- required
;

INSERT examples

Submits a batch job against a previously uploaded JSONL input file. The upload must have completed before this call; otherwise the request is rejected.

Supply a unique request_id to make the submission idempotent — retries with the same value return the existing job. When provider is openai, the url on each JSONL line must match endpoint.

INSERT INTO digitalocean.inference.batches (
file_id,
provider,
endpoint,
completion_window,
request_id,
metadata
)
SELECT
'{{ file_id }}' /* required */,
'{{ provider }}' /* required */,
'{{ endpoint }}',
'{{ completion_window }}' /* required */,
'{{ request_id }}' /* required */,
'{{ metadata }}'
RETURNING
batch_id,
error_file_id,
input_file_id,
output_file_id,
request_id,
cancelled_at,
completed_at,
completion_window,
created_at,
endpoint,
errors,
expires_at,
failed_at,
finalizing_at,
in_progress_at,
metadata,
provider,
request_counts,
status
;

Lifecycle Methods

Requests cancellation of a batch job. The job transitions to cancelling and, once in-flight requests drain, to cancelled. Jobs already in a terminal state (completed, failed, expired, cancelled) cannot be cancelled and return 409 Conflict. Cancellation is also rejected with 409 Conflict while the job has not yet been submitted to the upstream provider — there is nothing to cancel until the provider batch id is assigned.

Partial results produced before cancellation remain available via GET /v1/batches/{batch_id}/results.

EXEC digitalocean.inference.batches.inference_cancel_batch
@batch_id='{{ batch_id }}' --required
;