> ## Documentation Index
> Fetch the complete documentation index at: https://docs.biohub.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Batch API

> Submit inference jobs, track their progress, and retrieve results asynchronously.

The Batch API supports larger and longer-running asynchronous workloads.
Submit inputs, poll the batch, then retrieve each completed item's result.

| Operation | Purpose |
| - | - |
| [Submit](https://docs.biohub.ai/api/protein/models/batch_submit.md) | Queue inputs and return a batch ID. |
| [List](https://docs.biohub.ai/api/protein/models/batch_list.md) | Read batch status, counts, and pages of items. |
| [Status](https://docs.biohub.ai/api/protein/models/batch_status.md) | Read one task and retrieve its result and artifact URLs. |
| [Cancel](https://docs.biohub.ai/api/protein/models/batch_cancel.md) | Cancel queued tasks. |

## Submit inputs

Choose the inference operation with `endpoint` and put its inputs in `payload`.
Each payload entry becomes a task.

| Endpoint | One payload entry is |
| - | - |
| [`fold`](https://docs.biohub.ai/api/protein/models/batch_folding) | Protein structure prediction with ESMFold2. |
| [`fold_all_atom`](https://docs.biohub.ai/api/protein/models/batch_folding) | Molecular-complex prediction with ESMFold2. |
| [`fold_max_accuracy`](https://docs.biohub.ai/api/protein/models/fold_max_accuracy) | Maximum-accuracy molecular-complex prediction with ESMFold2. |
| [`design_binder`](https://docs.biohub.ai/api/protein/models/design_binder) | Run binder design trajectories. |

Each item costs GPU time, so each endpoint caps how many items you can queue.
See [Limits](#limits).

```bash theme={null}
curl https://biohub.ai/api/v1/batch/submit \
  -H "Authorization: Bearer $BIOHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "fold",
    "payload": [
      {
        "model": "esmfold2-fast-2026-05",
        "sequence": "MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ",
        "include_pae": true
      }
    ]
  }'
```

Save `data.batch_id` from the response.
A one-item batch also returns `data.task_id`.
Task IDs append a zero-padded index, such as `<batch_id>-00000`.
For repeated payloads, ordering is by repeat first, then position within `payload`.

## Retry a submission

API-key clients can add an optional lowercase UUIDv4 `submission_id` to any supported batch request.
Generate the ID once and save it with the request before submitting. It becomes the `batch_id`.
After a timeout or uncertain response, resend the same request with the same ID.
An exact replay returns the existing batch with `data.replayed: true`, without queuing more work.
Without `submission_id`, each submission creates a new batch.

## Limits

Each endpoint caps the items in one submission and the items one user can submit over a rolling window.
A submission's item count is the `payload` length times `repeat`.

| Limit | `fold` and `fold_all_atom` | `fold_max_accuracy` | `design_binder` |
| - | - | - | - |
| Items per submission | 2000 | 10 | 256 |
| Items per user per rolling window | 5000 per day for each endpoint | 10 per day | 5000 per hour |

Every fold endpoint accepts inputs up to 4096 tokens, compared with 768 for the on-demand [`fold`](https://docs.biohub.ai/api/protein/models/fold) and [`fold_all_atom`](https://docs.biohub.ai/api/protein/models/fold_all_atom) operations.

A submission above the per-submission limit returns `400`.
The rolling quota counts every item you submitted in the window, including items that later failed.
If a submission would exceed the quota, the API rejects the entire submission with `429`.
The `Retry-After` header gives the number of seconds until capacity is available.
The `fold` and `fold_all_atom` quotas each count items across all three ESMFold2 models.
`fold` and `fold_all_atom` also allow at most 20 submissions and 1,000,000 tokens per minute for each model.
`design_binder` also allows at most 10 submissions per minute.
A compute grant doubles the rolling quotas and the per-minute limit, but not the per-submission limit.
Credit checks apply separately.

## Track progress

Poll [List](https://docs.biohub.ai/api/protein/models/batch_list.md) with the saved `batch_id`:

```bash theme={null}
curl https://biohub.ai/api/v1/batch/list \
  -H "Authorization: Bearer $BIOHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"batch_id": "<batch_id>"}'
```

The aggregate batch state is `in_progress`, `done`, `failed`, or `cancelled`.
An aggregate `done` means all tasks are terminal; some or all tasks may have failed.
A cancelled batch can still contain running tasks.

| Task state | Meaning |
| - | - |
| `queued` | Waiting to start. |
| `in_progress` | Processing has started. |
| `done` | A result is available. |
| `failed` | Processing failed. Read the task's error. |
| `cancelled` | Cancelled before processing started, by you or by the 24-hour queue limit. |

`counts` covers the whole batch and omits states with zero items.
Set `include_responses: true` to retrieve an item page, then follow the returned `cursor` until it is null.
The default page size is 100 and the maximum is 1000.
A full final page can require one additional empty-page request.
A `status` filter narrows the item page, while counts remain batch-wide.

Tasks that have not started 24 hours after the batch was submitted are cancelled and will not be charged, while tasks already running finish normally.
Status and List return this deadline as `data.expires_at`.

## Retrieve results

Call [Status](https://docs.biohub.ai/api/protein/models/batch_status.md) with a `task_id` from the submission response or an item page:

```bash theme={null}
curl https://biohub.ai/api/v1/batch/status \
  -H "Authorization: Bearer $BIOHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"task_id": "<task_id>"}'
```

When the task is `done`, `data.response` contains an inline result object, inline text, or a signed URL to download it, depending on the endpoint.
For `design_binder`, it is an inline [design record](https://docs.biohub.ai/api/protein/models/design_binder.md#result), and `data.artifacts.structure` is a signed PDB download of the complex.
Other outputs, when present, are signed URLs in `data.artifacts`, keyed by artifact name.
List responses can include inline results but omit artifact URLs.
`response_available: true` indicates an externally stored result.

Download signed URLs without the Biohub bearer token.
Read status again to refresh expired URLs.
When present, `data.artifacts_expire_in` gives the shortest artifact URL lifetime in seconds.

## Result retention

Results are kept for 31 days after the batch is submitted, after which they are deleted.
Status and List return the deadline as `data.results_expire_at`. After that, Status returns `410` and List still reports each item's `status` but omits `response`, `response_available`, and `error`.

## Responses and failures

A successful HTTP operation returns this envelope:

```json theme={null}
{"status": "success", "data": {}, "request_id": "<request-id>"}
```

Route errors carry `message` instead:

```json theme={null}
{"status": "error", "message": "Batch not found", "request_id": "<request-id>"}
```

Authentication failures can use `error` instead of `message`; handle both shapes.
Retain `request_id` when reporting a failed call.
The envelope's `status` describes the HTTP operation, while `data.status` describes the job.
An HTTP `200` can report a failed task; inspect `data.error` on the status response.
Failure to read status does not mean the task failed.

Passing a batch ID to Status returns `404` with instructions to use List or an item ID.

## Cancel

[Cancel](https://docs.biohub.ai/api/protein/models/batch_cancel.md) accepts exactly one of `task_id` or `batch_id`.
It affects queued tasks only. Running tasks continue and retain their usage charges.
A batch with no cancellable work returns `409`; cancelling an already cancelled batch succeeds.


## Related topics

- [Batch folding](https://docs.biohub.ai/api/protein/models/batch_folding.md)
- [Protein Models API](https://docs.biohub.ai/api/protein/models/overview.md)
- [Biohub Platform API](https://docs.biohub.ai/api/overview.md)
- [fold_max_accuracy](https://docs.biohub.ai/api/protein/models/fold_max_accuracy.md)
- [design_binder](https://docs.biohub.ai/api/protein/models/design_binder.md)
