> This page is for Boltz-2, version 1.7.0.
> For other versions, use one of these documentation indexes:
> - 1.10.0 (Latest) (default): https://docs.nvidia.com/nim/bionemo/boltz2/1.10.0/llms.txt
> - 1.9.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.9.0/llms.txt
> - 1.8.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.8.0/llms.txt
> - 1.7.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.7.0/llms.txt
> - 1.6.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.6.0/llms.txt
> - 1.5.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.5.0/llms.txt
> - 1.4.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.4.0/llms.txt
> - 1.3.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.3.0/llms.txt
> - 1.2.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.2.0/llms.txt
> - 1.1.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.1.0/llms.txt
> - 1.0.0: https://docs.nvidia.com/nim/bionemo/boltz2/1.0.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/bionemo/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nim/bionemo/_mcp/server.

# Getting Started

## Prerequisites

- Refer to the [Support Matrix](/nim/bionemo/boltz2/1.7.0/support-matrix) to make sure that you have the supported hardware and software stack.
- An NGC personal API key.
  The NIM microservice uses the API key to download models from NVIDIA NGC.
  Refer to [Generating a Personal API Key](https://docs.nvidia.com/ngc/gpu-cloud/ngc-user-guide/index.html#generating-personal-api-key) in the NVIDIA NGC User Guide for more information.
- To run the below examples you must have `curl`, `jq`, and the Python `requests` module installed.

  When you create an NGC API personal key, select at least the option for **NGC Catalog** from the **Services Included** menu.
  You can specify more services to use the key for additional purposes.

### Installing curl, jq, and the Python requests module

1. `curl` is required to send requests from the command line. On Ubuntu and other Debian-based Linux distributions, `curl` can be installed with the following command, which may require `sudo` access:

    ```bash
    sudo apt-get update && sudo apt-get install curl
    ```
1. `jq` is used to process and reformat responses from the NIM so they are easier to read. `jq` can be installed using the following command, which may require `sudo` access:

    ```bash
    sudo apt-get update && sudo apt-get install jq
    ```
1. The Python `requests` module facilitates HTTP requests made in many of the examples for this NIM. The Python requests module can be installed using `pip`:

    ```bash
    pip install requests
    ```

### NGC Authentication

#### Generate an API key

To access NGC resources, you need an NGC API key. You can generate a key here: [Generate Personal Key](https://org.ngc.nvidia.com/setup/personal-keys).

When creating an NGC API Personal key, ensure that "NGC Catalog" is selected from the "Services Included" dropdown. You can include more services if you reuse this key for other purposes.

<Note>
Personal keys allow you to configure an expiration date, revoke, or delete the key using an action button, and rotate the key as needed. For more information about key types, refer to the [NGC User Guide](https://docs.nvidia.com/ngc/gpu-cloud/ngc-user-guide/index.html#ngc-api-keys).
</Note>

#### Export the API key

Pass the value of the API key to the `docker run` command in the next section as the `NGC_API_KEY` environment variable to download the appropriate models and resources when starting the NIM.

If you're not familiar with how to create the `NGC_API_KEY` environment variable, the simplest way is to export it in your terminal:

```bash
export NGC_API_KEY=<value>
```

Run one of the following commands to make the key available at startup:

```bash
# If using bash
echo "export NGC_API_KEY=<value>" >> ~/.bashrc

# If using zsh
echo "export NGC_API_KEY=<value>" >> ~/.zshrc
```

<Note>
Other, more secure options include saving the value in a file, so that you can retrieve with `cat $NGC_API_KEY_FILE`, or using a [password manager](https://www.passwordstore.org/).
</Note>

#### Docker Login to NGC

To pull the NIM container image from NGC, first authenticate with the NVIDIA Container Registry with the following command:

```bash
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
```

Use `$oauthtoken` as the username and `NGC_API_KEY` as the password. The `$oauthtoken` username is a special name that indicates that you will authenticate with an API key and not a username and password.

## Starting the NIM Container

1. Ensure you have logged in to Docker and set your `NGC_API_KEY` environment variable as detailed in the preceding section.

1. Create a NIM Cache. If one already exists, you may use the existing one.

    ```bash
    export LOCAL_NIM_CACHE=~/.cache/nim
    mkdir -p ${LOCAL_NIM_CACHE}
    chmod 777 ${LOCAL_NIM_CACHE}
    ```

1. Start the NIM container:

    ```bash
    ## Note: these two commands are not required if you have already set the appropiate variables in previous instructions.
    ## They are provided here as part of a one-click startup sequence.
    export LOCAL_NIM_CACHE=~/.cache/nim
    export NGC_API_KEY=<Your NGC API Key>
    ```

    ```bash
    docker run --rm --name boltz2 --runtime=nvidia \
        --shm-size=16G \
        -e NGC_API_KEY \
        -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
        -p 8000:8000 \
        nvcr.io/nim/mit/boltz2:1.7.0
    ```
    

   > **Note**: The `--runtime=nvidia` flag is the legacy approach for GPU access and may require additional Docker daemon configuration. For Docker 19.03+, you can use the `--gpus` flag instead, which works without additional configuration:
   >
   > Use all GPUs:
   >
   > ```bash
   > docker run --rm --name boltz2 --gpus all \
   >     --shm-size=16G \
   >     -e NGC_API_KEY \
   >     -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
   >     -p 8000:8000 \
   >     nvcr.io/nim/mit/boltz2:1.7.0
   > ```
   > 
   >
   > Or specify a specific GPU device:
   >
   > ```bash
   > docker run --rm --name boltz2 --gpus "device=0" \
   >     --shm-size=16G \
   >     -e NGC_API_KEY \
   >     -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
   >     -p 8000:8000 \
   >     nvcr.io/nim/mit/boltz2:1.7.0
   > ```
   > 

   The preceding command starts the container with the default profile, using all available system GPUs. **Note**: This will require localizing up to 30 Gigabytes of data to disk. If you have the model cached, the version in the NIM cache specified at `LOCAL_NIM_CACHE` will be used.

1. (Optional) Confirm the service is ready to respond to inference requests:

   ```console
   $ curl -i -X GET http://localhost:8000/v1/health/ready
   ```

   *Example Output*

   ```console
   HTTP/1.1 200 OK
   content-type: application/json

   true
   ```

1. Send an inference request:

<Tabs>
<Tab title="Curl">

```bash
#!/bin/bash

# Define the protein sequence
SEQUENCE="MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN"

# Create JSON payload for protein structure prediction
JSON_DATA='{
"polymers": [
    {
    "id": "A",
    "molecule_type": "protein",
    "sequence": "'"$SEQUENCE"'"
    }
],
"recycling_steps": 3,
"sampling_steps": 50,
"diffusion_samples": 1,
"step_scale": 1.638,
"output_format": "mmcif"
}'

echo "Making request..."

# Make the POST request
# Note: This script requires jq to be installed for JSON processing
response=$(curl -s -X POST \
-H "Content-Type: application/json" \
-d "$JSON_DATA" \
http://localhost:8000/biology/mit/boltz2/predict)

# Extract and display the structure information
# Using jq to parse the JSON response
echo "Structure prediction completed"
echo "Format: $(echo $response | jq -r '.structures[0].format')"
echo "Confidence score: $(echo $response | jq -r '.confidence_scores[0]')"
echo "Structure (first 500 chars): $(echo $response | jq -r '.structures[0].structure' | head -c 500)..."
```

</Tab>
<Tab title="Python">

```python
import requests
import json


if __name__ == "__main__":
    sequence = "MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN"  # Replace with your sequence value of interest
    headers = {
        "content-type": "application/json"
        }
    data = {
        "polymers": [
            {
            "id": "A",
            "molecule_type": "protein",
            "sequence": sequence
            }
        ],
        "recycling_steps": 3,
        "sampling_steps": 50,
        "diffusion_samples": 1,
        "step_scale": 1.638,
        "output_format": "mmcif"
        }
    print("Making request...")
    response = requests.post("http://localhost:8000/biology/mit/boltz2/predict", headers=headers, data=json.dumps(data))
    result = response.json()
    print("Structure prediction completed")
    # Access the first predicted structure
    if result.get("structures"):
        structure = result["structures"][0]
        print(f"Structure format: {structure['format']}")
        print(f"Confidence score: {result['confidence_scores'][0]}")
        print(f"Structure (first 500 chars): {structure['structure'][:500]}...")
```

</Tab>
</Tabs>

   The description of all API parameters could be found in the [Input Parameters section](/nim/bionemo/boltz2/1.7.0/inference#input-parameters) of the Inference Guide.

## Runtime Parameters for the Container

| Flags                            | Description                                                                                                                                                                                                                                                                                                     |
|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-it`                            | `--interactive` + `--tty` (see [Docker docs](https://docs.docker.com/reference/cli/docker/container/run/))                                                                                                                                                                                                      |
| `--rm`                           | Delete the container after it stops (see [Docker docs](https://docs.docker.com/reference/cli/docker/container/run/)).                                                                                                                                                                                           |
| `--name=<container-name>`        | Give a name to the NIM container. Use any preferred value.                                                                                                                                                                                                                                                      |
| `--runtime=nvidia`               | (Legacy) Ensure NVIDIA drivers are accessible in the container. Requires additional Docker daemon configuration. For Docker 19.03+, using `--gpus` is recommended as it works without additional configuration.                                                                                                 |
| `--gpus all`                     | (Recommended for Docker 19.03+) Expose all available NVIDIA GPUs inside the container. This is the modern approach for GPU access.                                                                                                                                                                              |
| `--gpus '"device=0"'`            | Expose specific NVIDIA GPU(s) inside the container (e.g., device 0). If you are running on a host with multiple GPUs, you can specify which GPU(s) to use. See [GPU Enumeration](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html) for further information.   |
| `-e NGC_API_KEY=$NGC_API_KEY`    | Provide the container with the token necessary to download adequate models and resources from NGC. See [above](#ngc-authentication).                                                                                                                                                                           |
| `-e NIM_MODEL_PROFILE=<profile>` | Specify the profile to use for the NIM. See the [Support Matrix section](/nim/bionemo/boltz2/1.7.0/support-matrix) for more information about available  profiles.                                                                                                                                                                         |
| `-e NIM_HTTP_API_PORT=8000`         | Specify the port that would be used by NIM inside the container (default is `8000`).                                                                                                                                                                                                                            |
| `-p 8000:8000`                   | Forward the port where the NIM HTTP server is published inside the container to access from the host system. The left-hand side of `:` is the host system ip:port (`8000` here), while the right-hand side is the container port where the NIM HTTP server is published.                                        |

## Caching Models

The first time you start the container, the microservice downloads the model from NGC.
You can avoid this download step on future runs by caching the model locally.

```bash
# Create the cache directory on the host machine.
export LOCAL_NIM_CACHE=~/.cache/nim
mkdir -p "$LOCAL_NIM_CACHE"
chmod 777 $LOCAL_NIM_CACHE

# Run the container with the cache directory as a volume mount.
```

```bash
docker run --rm --name boltz2 --runtime=nvidia \
    --shm-size=16G \
    -e NGC_API_KEY \
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    nvcr.io/nim/mit/boltz2:1.7.0
```



## Stopping the Container

The following commands stop the container by stopping and removing the running docker container.

```bash
docker stop boltz2
docker rm boltz2
```


## Running on Slurm With Enroot

This section describes how to run the Boltz2 NIM on a Slurm-based HPC cluster using [Enroot](https://github.com/NVIDIA/enroot) to run the NGC container.

<Warning>
**NGC_API_KEY**: You must export your NGC API key **before** running the Slurm script so that Enroot can pull the image from NGC. Then run the script (for example, `bash boltz2_srun.sh`).
</Warning>

Example:

```bash
export NGC_API_KEY=<your_NGC_API_key>
bash boltz2_srun.sh
```

### Environment

- **Enroot**: Version 3.4.1 or newer is supported.

### 1. Check Enroot is Available

On the login node, verify Enroot is installed:

```bash
enroot version
which enroot
```

If Enroot is not installed, contact your cluster administrator. Create the Enroot config directory if it does not exist:

```bash
mkdir -p ~/.config/enroot
```

### 2. Create and Add NGC Credentials

Create the credentials file so Enroot can pull images from NGC. Replace `YOUR_NGC_API_KEY` with your [NGC API key](https://org.ngc.nvidia.com/setup/api-key):

```bash
echo 'machine nvcr.io login $oauthtoken password YOUR_NGC_API_KEY' > ~/.config/enroot/.credentials
chmod 600 ~/.config/enroot/.credentials
```

### 3. Configure and Run the Slurm Job Script

Copy the script below to a file, such as `boltz2_srun.sh`. Set the variables at the top for your cluster and paths:

- **ACCOUNT**: Slurm account name
- **PARTITION**: Slurm partition (for example, `interactive` or `gpu`)
- **ROOT_DIR**: Your working directory on the cluster (for example, Lustre or NFS path)
- **NGC_API_KEY**: Must be **exported in your environment before running** the script (for example, `export NGC_API_KEY=<your_key>`)

Use a **shared filesystem path** for `ROOT_DIR` and `CACHE_PATH` so that the SQSH image and cache are visible from the node where the job runs.

Save the following as `boltz2_srun.sh` and run it with `bash boltz2_srun.sh`:

```bash
#!/bin/bash

# --- Slurm job configuration (customize for your cluster) ---
ACCOUNT="your_slurm_account"
PARTITION="interactive"
GPUS_PER_NODE=1
MEMORY="32G"
TIME="04:00:00"

# --- Paths (customize for your cluster) ---
ROOT_DIR="/path/to/your/workspace"
CACHE_PATH="${ROOT_DIR}/.nim_cache"
WORKING_CACHE_DIR="/opt/nim/.cache"
WORKING_PATH="${ROOT_DIR}"
MOUNT_PATH="/workspace/data"
TMP_PATH="${ROOT_DIR}/tmp"
MOUNT_TMP_PATH="${MOUNT_PATH}/tmp"

# --- NGC image (use # between registry and image path for Enroot) ---
NGC_IMAGE="docker://nvcr.io#nim/mit/boltz2:1.7.0"

CONTAINER_NAME="boltz2"
ACTIVE_SQSH_PATH="${ROOT_DIR}/boltz2.sqsh"

handle_error() { echo "Error: $1"; exit 1; }
mkdir -p "$(dirname "${ACTIVE_SQSH_PATH}")" || handle_error "Failed to create directory for SQSH file"
mkdir -p "${CACHE_PATH}" || handle_error "Failed to create cache directory"
mkdir -p "${TMP_PATH}" || handle_error "Failed to create tmp directory"

echo "Step 1: Requesting interactive resources..."
srun --account="${ACCOUNT}" \
     --partition="${PARTITION}" \
     --gpus-per-node="${GPUS_PER_NODE}" \
     --mem="${MEMORY}" \
     --time="${TIME}" \
     --export=ALL \
     -o /dev/tty -e /dev/tty \
     bash -c "
    echo \"Step 2: Importing Docker image\"
    if [ ! -f \"${ACTIVE_SQSH_PATH}\" ]; then
        mkdir -p \"\$(dirname \"${ACTIVE_SQSH_PATH}\")\" || { echo \"Failed to create directory\"; exit 1; }
        enroot import -o \"${ACTIVE_SQSH_PATH}\" ${NGC_IMAGE} || { echo \"Failed to import Docker image\"; exit 1; }
    else
        echo \"Docker image already exists, skipping import.\"
    fi

    echo \"Step 3: Creating Enroot container...\"
    if enroot list 2>/dev/null | grep -q \"${CONTAINER_NAME}\"; then
        enroot remove -f ${CONTAINER_NAME} || true
    fi
    enroot create --name ${CONTAINER_NAME} \"${ACTIVE_SQSH_PATH}\" || { echo \"Failed to create container\"; exit 1; }

    NODE=\$(hostname)
    echo \"\$NODE\" > \"${WORKING_PATH}/.boltz2_node\"
    echo \"Step 4: Boltz2 container ready.\"
    echo \"=====================================\"
    echo \"Working directory in container: ${MOUNT_PATH}\"
    echo \"From another terminal run:  ssh -L 8000:localhost:8000 \$NODE\"
    echo \"Node name saved to: ${WORKING_PATH}/.boltz2_node\"
    echo \"=====================================\"

    cat > \"\${TMPDIR:-/tmp}/rc.local\" << RCEOF
#!/bin/sh
export TMPDIR=${MOUNT_TMP_PATH}
export TEMP=${MOUNT_TMP_PATH}
export TMP=${MOUNT_TMP_PATH}
export HOME=${MOUNT_PATH}
export XDG_CACHE_HOME=${WORKING_CACHE_DIR}
export XDG_DATA_HOME=${MOUNT_PATH}/.local/share
mkdir -p ${MOUNT_TMP_PATH} ${MOUNT_PATH}/.local/share
/opt/nim/start_server.sh &
exec /bin/bash
RCEOF
    chmod +x \"\${TMPDIR:-/tmp}/rc.local\"
    enroot start \\
      --mount ${CACHE_PATH}:${WORKING_CACHE_DIR} \\
      --mount ${WORKING_PATH}:${MOUNT_PATH} \\
      --mount \"\${TMPDIR:-/tmp}/rc.local:/etc/rc.local\" \\
      -e NGC_API_KEY \\
      -e TMPDIR=${MOUNT_TMP_PATH} \\
      -e TEMP=${MOUNT_TMP_PATH} \\
      -e TMP=${MOUNT_TMP_PATH} \\
      -e HOME=${MOUNT_PATH} \\
      -e XDG_CACHE_HOME=${WORKING_CACHE_DIR} \\
      -e XDG_DATA_HOME=${MOUNT_PATH}/.local/share \\
      ${CONTAINER_NAME} || { echo \"Failed to start container\"; exit 1; }
"
```


### 4. Call the API From Your Machine

After the container is running on a compute node:

1. Create an SSH tunnel from your machine or the login node:

   ```bash
   ssh -L 8000:localhost:8000 $(cat /path/to/your/workspace/.boltz2_node)
   ```

2. In another terminal (with the tunnel open), send an inference request:

   ```bash
   curl -s -X POST "http://localhost:8000/biology/mit/boltz2/predict" \
     -H "Content-Type: application/json" \
     -d '{"polymers":[{"id":"A","molecule_type":"protein","sequence":"MTEYKLVVVGACGVGKSALTIQLIQNHFVDEYDPTIEDSYRKQVVID"}]}' \
     --max-time 300
   ```

If the request succeeds, you will get a JSON response containing the prediction result.

## Next Steps

- Refer to the [Deployment section](/nim/bionemo/boltz2/1.7.0/inference#deployment) in the Inference Guide for more detailed instructions on how to deploy the NIM.
- Refer to [Optimization](/nim/bionemo/boltz2/1.7.0/optimization) for settings related to optimizing performance of the NIM on your hardware and software stack.