# vast-ai-provisioner

This script will provision a [Vast.ai](https://vast.ai) instance with a specific template which can be overridden and customized beyond what is available with Vast's template system. The repo currently provides the following templates:

- [ComfyUI](https://github.com/comfyanonymous/ComfyUI) - A node-based AI image/video generation suite
- [FP-Studio](https://github.com/FP-Studio/FramePack-Studio) - A FramePack-based video editor

Additionally, there are several modules available to add to the base ComfyUI install:

- Animagine: Animagine XL 4.0, a best-in-class anime model
- Flux 2 Dev: Adds Flux 2.Dev
- Flux 3 Klein: Adds Flux 3 Klein, a state of the art multi-image to image model
- Flux Dev: Adds Flux 1.Dev and ControlNet
- Flux Kontext: Adds Flux Kontext for image editing
- Ideogram 4: A newer image model with state of the art design and placement abilities
- MOSS Image: A newer image model with state of the art design and placement abilities
- Pixel Art: Adds Pixel Art LoRAs for SDXL
- SDXL: Stable Diffusion XL and ControlNet
- Upscalers: A collection of high quality 2x and 4x upscalers
- Utility Nodes: A set of Comfy nodes to make building workflows easier
- WAN2.2 (5B or 14B): A powerful text-to-video or image-to-video model

## Requirements

- Node >=24
- Vast.ai API key
- Pastebin API key (if using custom modules)

## Usage

```sh
npm install -g vast-ai-provisioner
vast-ai-provisioner -h

OR

npx vast-ai-provisioner -h
```

Run `cp .env.default .env` in this directory, then edit `.env` to set your Vast and Pastebin API keys.

Template is an optional argument - if you do not provide it, the application will ask you which one you want to deploy.

### Offer filtering

Offers are only shown if they have enough free disk for the template plus every selected module, and enough VRAM for the most demanding module. Modules can declare a `minVram` (in GB); if it is higher than `--min-vram`, the minimum is raised automatically. Listed prices include the cost of the calculated disk size.

| Option                      | Default | Description                                  |
| --------------------------- | ------- | -------------------------------------------- |
| `--min-vram <gb>`           | 16      | Min. per-GPU VRAM in GB                      |
| `--num-gpus <num>`          | 1       | Number of GPUs on the instance               |
| `--max-hourly-cost <cost>`  | 1       | Max. total cost in $/hr                      |
| `--max-ports <count>`       | 1000    | Max. number of ports on the machine          |
| `--min-inet-down <mbps>`    | 1000    | Min. download bandwidth in Mbps              |
| `--min-reliability <ratio>` | 0.95    | Min. host reliability, from 0 to 1           |
| `--region <codes...>`       | any     | Only offers in these countries, e.g. `US CA` |
| `--no-exclude-rtx50`        | unset   | Include RTX 50-series GPUs                   |

### Managing instances

After deploying, the tool waits until the instance is running, then prints its address and links (Instance Portal, ComfyUI, etc.). Press S to stop the instance, D to detach and leave it running, or Ctrl-C to destroy it. Detached or not, instances can be managed later from any terminal:

| Command        | Description                                                    |
| -------------- | -------------------------------------------------------------- |
| `list [--all]` | List instances created by this tool (`--all` shows every one)  |
| `status <id>`  | Show an instance's state, address and links                    |
| `start <id>`   | Start a stopped instance and wait for it (`--no-wait` to skip) |
| `stop <id>`    | Stop an instance (storage is still billed)                     |
| `destroy <id>` | Destroy an instance and its data (`-y` skips the prompt)       |

Instances are labeled `vast-ai-provisioner/<template>` so `list` can tell them apart from your other instances.

### Gated models

Some modules (e.g. Flux 3 Klein) download gated models from Hugging Face. Accept the model's license on huggingface.co first, then either set `HF_TOKEN` in your `.env` file or enter a token when prompted. The token is validated locally and passed to the instance as an environment variable; it is never written into the provisioning script.

## Development

```sh
corepack enable
yarn install
yarn run build
node lib/index.js <template>
```
