Python SDK: Batches

⚠️
Preview — this feature is being built; the design below is the spec.

Asynchronous processing at the batch price.

from syntic import Syntic
 
client = Syntic()  # reads SYNTIC_API_KEY
MethodEndpointReturns
batches.createPOST /v1/batchesBatch
batches.listGET /v1/batchesSyncPage[Batch]
batches.retrieveGET /v1/batches/{batch_id}Batch
batches.wait(helper; polls GET /v1/batches/{batch_id})Batch
batches.resultsGET /v1/batches/{batch_id}/resultsIterator of BatchResult
batches.cancelPOST /v1/batches/{batch_id}/cancelBatch
batches.deleteDELETE /v1/batches/{batch_id}BatchDeleted

Methods

batches.create

From an uploaded JSONL input_file_id, or up to 1,000 inline requests. Maps to POST /v1/batches.

result = client.batches.create(input_file_id="file_01JBXF1Z")

batches.list

List batches. Maps to GET /v1/batches.

for item in client.batches.list(limit=20):
    print(item.id if hasattr(item, 'id') else item)

batches.retrieve

Status and counts. Maps to GET /v1/batches/{batch_id}.

result = client.batches.retrieve('batch_01JBXF3P8K')

batches.wait

Helper: poll until the batch ends, with back-off. Returns the final batch.

result = client.batches.wait('batch_01JBXF3P8K', poll_interval=30)

batches.results

Iterate result lines as typed objects, streaming from the server. Maps to GET /v1/batches/{batch_id}/results.

for item in client.batches.results('batch_01JBXF3P8K'):
    print(item.id if hasattr(item, 'id') else item)

batches.cancel

Cancel a running batch. Maps to POST /v1/batches/{batch_id}/cancel.

result = client.batches.cancel('batch_01JBXF3P8K')

batches.delete

Delete an ended batch and its result files. Maps to DELETE /v1/batches/{batch_id}.

result = client.batches.delete('batch_01JBXF3P8K')

Conventions

Every method accepts extra_headers, extra_query, extra_body and timeout keyword arguments, and has an async twin on AsyncSyntic. List methods return pages that iterate across all pages automatically.

See the Python SDK overview for installation, errors and retries.

Was this page helpful?