> ## 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 folding

> Predict protein structures and molecular complexes asynchronously with ESMFold2.

Use [Batch Submit](https://docs.biohub.ai/api/protein/models/batch_submit.md) with `endpoint: "fold"` for protein sequences or `endpoint: "fold_all_atom"` for complexes containing proteins, RNA, DNA, and ligands.
Supported models: `esmfold2-2026-05`, `esmfold2-fast-2026-05`, and `esmfold2-2026-05-cutoff-2025`.

Each task predicts one structure with your folding configuration.
Unlike [fold\_max\_accuracy](https://docs.biohub.ai/api/protein/models/fold_max_accuracy.md), these endpoints do not generate an MSA automatically or select the best of multiple predictions.
You can supply an MSA to `esmfold2-2026-05` and `esmfold2-2026-05-cutoff-2025`; the fast model ignores MSAs.

## Sequence length

The total input length is limited to 4096 tokens.
This is the same limit as [fold\_max\_accuracy](https://docs.biohub.ai/api/protein/models/fold_max_accuracy.md) and more than the 768 tokens that 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 accept.
Protein residues and RNA/DNA nucleotides count as one token each; ligands and modified residues count by heavy atom.

## Fold protein sequences

```python theme={null}
import os

from esm.sdk.api import FoldRequest, FoldingConfig
from esm.sdk.forge import ForgeBatchClient

with ForgeBatchClient(
    token=os.environ["ESM_API_KEY"], model="esmfold2-fast-2026-05"
) as client:
    submission = client.fold.submit(
        requests=[
            FoldRequest(sequence="MKTAYIAKQRQISFVKSHFSRQ"),
            FoldRequest(sequence="GSHMASMTGGQQMGRGS"),
        ],
        config=FoldingConfig(include_pae=True),
    )
    print("Batch ID:", submission.batch_id)
    client.fold.wait(submission)
    proteins = client.fold.results(submission)
```

Each successful result is an `ESMProtein` with predicted structure and confidence metrics.
Use `|` to separate protein chains within a sequence.

To name chains instead, pass `chains` as a list of `ChainInput(id, sequence)` objects.
Each `FoldRequest` takes either `sequence` or `chains`, not both.

```python theme={null}
from esm.sdk.api import ChainInput, FoldRequest

request = FoldRequest(
    chains=[
        ChainInput(id="T", sequence="MKTAYIAKQRQISFVKSHFSRQ"),
        ChainInput(id="B", sequence="GSHMASMTGGQQMGRGS"),
    ]
)
```

For a multi-chain result, `protein.chains` lists the chain IDs in fold order.
`protein.chain_plddt` holds one pLDDT tensor per chain with separator slots removed.
Compute per-chain confidence from `chain_plddt` rather than indexing `plddt`, which keeps a NaN slot at each chain separator.

For molecular complexes, use `client.fold_all_atom` with `FoldAllAtomRequest`; successful results are `MolecularComplexResult` objects. See [Fold all atom](https://docs.biohub.ai/api/protein/models/fold_all_atom.md) for input construction.

Both handlers also provide `async_submit`, `async_wait`, `async_results`, and `async_run`.
Save the returned batch ID before waiting so you can recover results later.
See the [Batch API overview](https://docs.biohub.ai/api/protein/models/batch_overview.md) for failures, cancellation, and result retention.


## Related topics

- [Biohub MCP folding tools](https://docs.biohub.ai/biohub-mcp/folding-tools.md)
- [Protein Models API](https://docs.biohub.ai/api/protein/models/overview.md)
- [fold_all_atom](https://docs.biohub.ai/api/protein/models/fold_all_atom.md)
- [fold](https://docs.biohub.ai/api/protein/models/fold.md)
- [Biohub MCP server](https://docs.biohub.ai/biohub-mcp/overview.md)
