| name | vastai |
| description | Vast.ai CLI to manage GPU instances, volumes, serverless endpoints, and billing. |
| allowed-tools | Bash(vastai:*) |
| compatibility | Linux, macOS |
| metadata | {"author":"vast-ai"} |
vastai
Manage GPU instances, templates, volumes, serverless endpoints, SSH keys, and billing on Vast.ai.
Command is vastai (lowercase). Always use --raw for machine-readable JSON output.
Install
pip install vastai
Quick start
vastai set api-key <YOUR_API_KEY>
vastai show user
vastai create ssh-key ~/.ssh/id_ed25519.pub
vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1 rentable=true' -o 'dlperf_usd-'
vastai create instance <OFFER_ID> --image pytorch/pytorch:@vastai-automatic-tag --disk 20 --ssh --direct
vastai show instance <INSTANCE_ID>
vastai ssh-url <INSTANCE_ID>
vastai copy local:./data/ <INSTANCE_ID>:/workspace/
vastai destroy instance <INSTANCE_ID> -y
API key: https://console.vast.ai/manage-keys/
Global flags
Available on every command:
--api-key KEY Override stored API key
--raw Output machine-readable JSON (agents should always use this)
--full Print full results (don't page with less)
--explain Show underlying API calls (useful for debugging)
--curl Show equivalent curl command
--no-color Disable colored output
--url URL Override server REST API URL
--retry RETRY Set retry limit for API calls
--version Show CLI version
Query syntax
Search commands accept filter expressions. Operators: =, !=, >, >=, <, <=, in, notin.
'gpu_name=RTX_4090 num_gpus=1'
'gpu_ram>=48 reliability>0.95'
'geolocation=EU dph_total<=2.0'
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
Common sort fields: score (default — overall value), dlperf_usd (DL perf per dollar), dph_total (price), num_gpus, reliability
Commands
Instances
vastai show instances
vastai show instances-v1
vastai show instances-v1 --status running loading
vastai show instances-v1 --gpu-name 'RTX 4090'
vastai show instances-v1 --label training
vastai show instances-v1 --order-by start_date desc
vastai show instances-v1 --cols id,status,gpu,dph
vastai show instance <id>
vastai create instance <offer-id> --image pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime --disk 20 --ssh --direct
vastai launch instance --gpu-name RTX_4090 --num-gpus 1 --image pytorch/pytorch
vastai start instance <id>
vastai stop instance <id>
vastai reboot instance <id>
vastai destroy instance <id> -y
vastai destroy instances <id1> <id2> -y
vastai label instance <id> --label "training-run-1"
vastai update instance <id>
vastai prepay instance <id>
vastai recycle instance <id>
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):
vastai/base-image:@vastai-automatic-tag
vastai/pytorch:@vastai-automatic-tag
vastai/linux-desktop:@vastai-automatic-tag
vastai create instance <id> --image vastai/vllm:@vastai-automatic-tag --disk 40 --ssh --direct \
--env '-e MODEL_NAME=Qwen/Qwen2.5-3B-Instruct -e HF_TOKEN=hf_xxx'
vastai create instance <id> --image vastai/comfy:@vastai-automatic-tag --disk 40 --ssh --direct \
--env '-e CHECKPOINT_MODEL=black-forest-labs/FLUX.1-schnell -e HF_TOKEN=hf_xxx'
create instance flags:
--image IMAGE — Docker image
--disk DISK — Local disk in GB
--ssh / --jupyter — Connection type
--direct — Faster direct connections
--label LABEL — Instance label
--env ENV — Env vars and port mappings, e.g. '-e TZ=UTC -p 8080:8080'
--onstart FILE — Path to a startup script file
--onstart-cmd CMD — Startup script as inline string (for longer scripts use --onstart or gzip+base64 encode)
--bid_price PRICE — Interruptible (spot) pricing in $/hr
--template_hash HASH — Create from template
--create-volume ID — Attach new volume
--link-volume ID — Attach existing volume
--cancel-unavail — Fail if no machine available (vs. create stopped)
Instance status values:
actual_status | Meaning |
|---|
null | Provisioning |
created | Instance created, not yet provisioned |
loading | Image downloading / container starting |
running | Active — GPU charges apply |
stopped | Halted — disk charges only |
frozen | Paused with memory — GPU charges apply |
exited | Container process exited unexpectedly |
rebooting | Restarting (transient) |
unknown | No recent heartbeat from host |
offline | Host disconnected from Vast servers |
Poll loop warning: If actual_status becomes exited, unknown, or offline it will never reach running. Always add a timeout and error branch — otherwise your script loops forever while disk charges accrue. Destroy and retry with a different offer.
Charges: Storage charges begin at creation. GPU charges begin when status reaches running.
Interruptible (spot) rentals
Interruptible (spot) instances are priced below on-demand instances, but can be interrupted at any time by another user with a lower bid. Note: search offers --type bid exposes min_bid, but create instance defaults to on-demand at dph_total unless you pass --bid_price <floor>. Always pass --bid_price after a --type bid search, otherwise the instance will be rented as an on-demand instance/price instead of as an interruptible.
When outbid, the instance moves to stopped (not destroyed) and storage charges continue. Resume by raising the bid via update instance --bid_price.
Search
vastai search offers
vastai search offers 'gpu_name=RTX_4090 num_gpus=1 verified=true direct_port_count>=1' -o 'dlperf_usd-'
vastai search offers 'num_gpus>=4 reliability>0.99' -o 'num_gpus-'
vastai search offers --type bid
vastai search offers --type reserved
vastai search offers -n 'gpu_name=H100_SXM'
vastai search volumes
vastai search templates "pytorch"
vastai search benchmarks
vastai search invoices
search offers flags: --type on-demand|reserved|bid, --order/-o FIELD[-], --limit, --storage GB, --no-default/-n
SSH & File Transfer
vastai ssh-url <id>
vastai scp-url <id>
vastai attach ssh <id> "ssh-ed25519 AAAA..."
vastai detach ssh <id> <ssh_key_id>
vastai show ssh-keys
vastai create ssh-key ~/.ssh/id_ed25519.pub
vastai create ssh-key
vastai create ssh-key "ssh-ed25519 AAAA..."
vastai delete ssh-key <id>
vastai update ssh-key <id> "ssh-ed25519 AAAA..."
Note: ssh-url returns a connection string — it does not open an interactive session. Use $(vastai ssh-url <id>) to extract the URL, or parse --raw JSON output.
File Copy
vastai copy <src> <dst>
vastai copy local:./data/ <id>:/workspace/data/
vastai copy <id>:/workspace/results/ local:./results/
vastai copy <id-a>:/workspace/ <id-b>:/workspace/
vastai cloud copy --src ./data --dst s3://bucket/path \
--instance 12345 --connection <conn-id> \
--transfer "Instance To Cloud"
vastai cancel copy <dst-id>
cloud copy flags: --src, --dst, --instance, --connection, --transfer
Logs & Exec
vastai logs <id>
vastai logs <id> --tail 100
vastai logs <id> --filter "error"
vastai execute <id> "nvidia-smi"
vastai execute <id> "ls /workspace" --schedule DAILY
Volumes
vastai search volumes
vastai show volumes
vastai create volume <offer_id> [-s SIZE] [-n NAME]
vastai clone volume <source_id> <dest_id> [-s SIZE]
vastai delete volume <id>
vastai create network-volume ...
vastai list network-volume
vastai take snapshot <instance_id> --repo REPO --docker_login_user USER --docker_login_pass PASS
Serverless & Deployments
vastai show endpoints
vastai create endpoint --name "my-ep" ...
vastai update endpoint <id> ...
vastai delete endpoint <id>
vastai get endpt-logs <id>
vastai show workergroups
vastai create workergroup --name "wg" ...
vastai update workergroup <id> ...
vastai update workers <id>
vastai delete workergroup <id>
vastai get wrkgrp-logs <id>
vastai show deployments
vastai show deployment <id>
vastai show deployment-versions <id>
vastai delete deployment <id>
vastai show scheduled-jobs
vastai delete scheduled-job <id>
Templates
vastai search templates "pytorch"
vastai create template --name "x" --image "img"
vastai update template <id> ...
vastai delete template <id>
Account & API Keys
vastai set api-key <key>
vastai show api-key <id>
vastai show api-keys
vastai create api-key --name "ci" --permissions '{...}'
vastai delete api-key <id>
vastai reset api-key
vastai show user
vastai show audit-logs
vastai show connections
vastai show ipaddrs
Billing
vastai show invoices-v1
vastai show invoices-v1 --charges
vastai show invoices-v1 --invoices
vastai show invoices-v1 --start-date 2026-01-01 --end-date 2026-02-01
vastai show invoices-v1 --limit 50 --latest-first
vastai show deposit <id>
Teams
vastai create team --name "myteam"
vastai show members
vastai invite member --email user@example.com
vastai remove member <id>
vastai create team-role --name "viewer" ...
vastai show team-role <id>
vastai show team-roles
vastai update team-role <id> ...
vastai remove team-role <id>
vastai destroy team
Environment Variables
vastai show env-vars
vastai create env-var KEY val
vastai update env-var KEY newval
vastai delete env-var KEY
Machine Management (hosts)
vastai show machines
vastai list machine <id>
vastai show machine <id>
vastai cleanup machine <id>
vastai schedule maint <id> ...
vastai cancel maint <id>
vastai show maints
vastai unlist machine <id>
Common errors
| Error | Cause | Fix |
|---|
401 Unauthorized | Invalid or expired API key | vastai set api-key <new-key> |
Insufficient credits | Account balance too low | Add credits at https://cloud.vast.ai/billing/ |
No offers found | Filters too restrictive | Relax filters, try --no-default/-n |
Permission denied | SSH key not attached | vastai create ssh-key before create instance |
Connection refused | Instance not yet running | Poll show instance <id> until actual_status == "running" |
Hangs on destroy instance | Confirmation prompt waiting for input | Add -y flag: vastai destroy instance <id> -y |
URLs
Console
https://console.vast.ai/instances/ # Your instances
https://console.vast.ai/create/ # Search GPU offers
https://console.vast.ai/manage-keys/ # Create and manage API keys
https://cloud.vast.ai/billing/ # Billing
API
https://console.vast.ai/api/v0/instances/ # Instances endpoint
https://console.vast.ai/api/v0/asks/ # Offers search
Instance Ports
Access a port exposed on your instance:
ssh://root@<ssh_host>:<ssh_port> # SSH (from vastai ssh-url)
Direct connections (when --direct used at creation): <direct_port_end> field in instance JSON.
Documentation
Fetch the complete documentation index at: https://docs.vast.ai/llms.txt