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

# Response formats and payload size

> Choose JSON or binary responses for protein model APIs.

Protein model APIs return JSON by default. Supported endpoints also offer opt-in Python pickle responses, which can reduce payload size for tensors and arrays.
The `esm` Python SDK requests pickle automatically on these endpoints and decodes the response for you.

## Supported endpoints

JSON and pickle responses are available for:

| Operation | Endpoints |
| - | - |
| Tokenization and decoding | [encode](/api/protein/models/encode), [decode](/api/protein/models/decode) |
| Generation and sampling | [generate](/api/protein/models/generate), [generate\_tensor](/api/protein/models/generate_tensor), [forward\_and\_sample](/api/protein/models/forward_and_sample) |
| Representations | [logits](/api/protein/models/logits) |
| Structure prediction and inverse folding | [fold](/api/protein/models/fold), [inverse\_fold](/api/protein/models/inverse_fold) |

[fold\_all\_atom](/api/protein/models/fold_all_atom) uses dedicated compact serialization for its molecular-complex payload and does not negotiate pickle responses.

## Choose a format for direct API calls

Keep the request body as JSON with `Content-Type: application/json` for either response format.
Use the `Accept` header to select the response format.

### JSON

Request JSON when you need a language-independent response:

```http theme={null}
Accept: application/json
```

The response has `Content-Type: application/json`. Array values are represented as JSON arrays.
Omitting `Accept` also returns JSON.

### Pickle

Request pickle with a JSON fallback:

```http theme={null}
Accept: application/vnd.evolutionaryscale.pickle, application/json
```

A pickle response has `Content-Type: application/vnd.evolutionaryscale.pickle` and contains a pickled response dictionary.
Array fields can retain PyTorch tensors or NumPy arrays instead of being converted to lists.
Read the response's `Content-Type` before decoding it; the Python SDK handles this automatically.

## HTTP compression

Pickle determines how response data is serialized. HTTP gzip compression reduces the size of those serialized bytes and is supported for both JSON and pickle.
To allow gzip responses, send:

```http theme={null}
Accept-Encoding: gzip
```

Use the response's `Content-Encoding` header to determine whether decompression is needed.
The Python SDK's HTTP clients handle decompression automatically.

Payload savings depend on the data. Large coordinate or embedding arrays benefit from binary representation, while pickle's object metadata can make small responses larger than JSON.
