$npx -y skills add vast-ai/vast-cli --skill vastaiVast.ai CLI to manage GPU instances, volumes, serverless endpoints, and billing.
| 1 | # vastai |
| 2 | |
| 3 | Manage GPU instances, templates, volumes, serverless endpoints, SSH keys, and billing on Vast.ai. |
| 4 | |
| 5 | > Command is `vastai` (lowercase). Always use `--raw` for machine-readable JSON output. |
| 6 | |
| 7 | ## Install |
| 8 | |
| 9 | ```bash |
| 10 | # PyPI (recommended) |
| 11 | pip install vastai |
| 12 | ``` |
| 13 | |
| 14 | ## Quick start |
| 15 | |
| 16 | ```bash |
| 17 | vastai set api-key <YOUR_API_KEY> # Authenticate (one-time); Create API Key in account at https://console.vast.ai/manage-keys/ |
| 18 | vastai show user # Verify auth + check balance |
| 19 | vastai create ssh-key ~/.ssh/id_ed25519.pub # Register SSH key (do BEFORE create) |
| 20 | vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1 rentable=true' -o 'dlperf_usd-' |
| 21 | # Note the offer ID from the output |
| 22 | vastai create instance <OFFER_ID> --image pytorch/pytorch:@vastai-automatic-tag --disk 20 --ssh --direct |
| 23 | # Automatically grab appropriate image tag; Response: {"success": true, "new_contract": <INSTANCE_ID>} |
| 24 | vastai show instance <INSTANCE_ID> # Poll until actual_status == "running" (see Instance status values below) |
| 25 | vastai ssh-url <INSTANCE_ID> # Get SSH connection string |
| 26 | vastai copy local:./data/ <INSTANCE_ID>:/workspace/ # Upload files |
| 27 | vastai destroy instance <INSTANCE_ID> -y # Clean up (stops all billing; -y skips confirmation) |
| 28 | ``` |
| 29 | |
| 30 | API key: https://console.vast.ai/manage-keys/ |
| 31 | |
| 32 | ## Global flags |
| 33 | |
| 34 | Available on every command: |
| 35 | |
| 36 | ``` |
| 37 | --api-key KEY Override stored API key |
| 38 | --raw Output machine-readable JSON (agents should always use this) |
| 39 | --full Print full results (don't page with less) |
| 40 | --explain Show underlying API calls (useful for debugging) |
| 41 | --curl Show equivalent curl command |
| 42 | --no-color Disable colored output |
| 43 | --url URL Override server REST API URL |
| 44 | --retry RETRY Set retry limit for API calls |
| 45 | --version Show CLI version |
| 46 | ``` |
| 47 | |
| 48 | ## Query syntax |
| 49 | |
| 50 | Search commands accept filter expressions. Operators: `=`, `!=`, `>`, `>=`, `<`, `<=`, `in`, `notin`. |
| 51 | |
| 52 | ```bash |
| 53 | # Examples |
| 54 | 'gpu_name=RTX_4090 num_gpus=1' # Exact match + numeric |
| 55 | 'gpu_ram>=48 reliability>0.95' # Greater-than filters |
| 56 | 'geolocation=EU dph_total<=2.0' # Region + price cap |
| 57 | ``` |
| 58 | |
| 59 | Common filter fields: `num_gpus`, `gpu_name`, `gpu_ram`, `cpu_ram`, `disk_space`, `reliability`, `compute_cap`, `inet_up`, `inet_down`, `dph_total`, `geolocation`, `direct_port_count`, `verified`, `rentable` |
| 60 | |
| 61 | Common sort fields: `score` (default — overall value), `dlperf_usd` (DL perf per dollar), `dph_total` (price), `num_gpus`, `reliability` |
| 62 | |
| 63 | ## Commands |
| 64 | |
| 65 | ### Instances |
| 66 | |
| 67 | ```bash |
| 68 | vastai show instances # List all your instances |
| 69 | vastai show instances-v1 # Paginated instances with full filter/sort/cols support |
| 70 | vastai show instances-v1 --status running loading # Filter by status |
| 71 | vastai show instances-v1 --gpu-name 'RTX 4090' # Filter by GPU |
| 72 | vastai show instances-v1 --label training # Filter by label |
| 73 | vastai show instances-v1 --order-by start_date desc # Sort by column |
| 74 | vastai show instances-v1 --cols id,status,gpu,dph # Custom columns |
| 75 | vastai show instance <id> # Poll single instance (use for status checks) |
| 76 | vastai create instance <offer-id> --image pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime --disk 20 --ssh --direct |
| 77 | # Response includes "new_contract": <id> — that is your instance ID |
| 78 | vastai launch instance --gpu-name RTX_4090 --num-gpus 1 --image pytorch/pytorch |
| 79 | vastai start instance <id> # Start stopped instance |
| 80 | vastai stop instance <id> # Stop (preserves disk, no GPU charges) |
| 81 | vastai reboot instance <id> # Stop + start |
| 82 | vastai destroy instance <id> -y # Delete permanently (irreversible; -y required for non-interactive use) |
| 83 | vastai destroy instances <id1> <id2> -y # Batch delete (-y skips confirmation prompt) |
| 84 | vastai label instance <id> --label "training-run-1" # Tag instance |
| 85 | vastai update instance <id> # Recreate from updated template |
| 86 | vastai prepay instance <id> # Deposit credits into reserved instance |
| 87 | vastai recycle instance <id> # Destroy + recreate |
| 88 | ``` |
| 89 | |
| 90 | **Recommended Vast.ai images** (use `@vastai-automatic-tag` to get the right tag for the machine automatically; browse pre-configured models at https://vast.ai/model-library): |
| 91 | |
| 92 | <!-- Note: @vastai-automatic-tag is resolved server-side — CLI passes it unchanged --> |
| 93 | |
| 94 | ```bash |
| 95 | vastai/base-image:@vastai-automatic-tag # Minimal Ubuntu base |
| 96 | vastai/pytorch:@vastai-automatic-tag # PyTorch + CU |