| name | vastai-hello-world |
| description | Rent your first GPU instance on Vast.ai and run a workload.
Use when starting a new Vast.ai integration, testing your setup,
or learning basic Vast.ai GPU rental patterns.
Trigger with phrases like "vastai hello world", "vastai example",
"vastai quick start", "rent first gpu", "vastai first instance".
|
| allowed-tools | Read, Write, Edit, Bash(vastai:*), Bash(curl:*), Bash(ssh:*) |
| version | 1.11.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","vast-ai","api","testing"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Vast.ai Hello World
Overview
Rent your first GPU instance on Vast.ai, run a PyTorch workload, and destroy the instance when done. Demonstrates the full lifecycle: search offers, create instance, connect via SSH, run a job, and tear down.
Prerequisites
- Completed
vastai-install-auth setup
- Vast.ai account with credits ($1+ recommended for testing)
- SSH key uploaded to Vast.ai (cloud.vast.ai > Account > SSH Keys)
Instructions
Step 1: Search for Available GPUs (CLI)
vastai search offers 'num_gpus=1 gpu_ram>=8 inet_down>100 reliability>0.95' \
--order 'dph_total' --limit 5
Step 2: Search for Available GPUs (REST API)
curl -s -H "Authorization: Bearer $VASTAI_API_KEY" \
"https://cloud.vast.ai/api/v0/bundles/?q=%7B%22num_gpus%22%3A%7B%22eq%22%3A1%7D%2C%22gpu_ram%22%3A%7B%22gte%22%3A8%7D%2C%22reliability2%22%3A%7B%22gte%22%3A0.95%7D%2C%22rentable%22%3A%7B%22eq%22%3Atrue%7D%7D&order=dph_total&limit=5" \
| jq '.offers[:3] | .[] | {id, gpu_name, num_gpus, gpu_ram, dph_total, reliability2}'
Step 3: Create an Instance (CLI)
vastai create instance OFFER_ID \
--image pytorch/pytorch:2.2.0-cuda12.1-cudnn8-runtime \
--disk 20 \
--onstart-cmd "echo 'Instance ready'"
Step 4: Create an Instance (Python)
from vastai_client import VastClient
client = VastClient()
offers = client.search_offers({
"num_gpus": {"eq": 1},
"gpu_name": {"eq": "RTX_4090"},
"reliability2": {"gte": 0.95},
: {: },
})
best = (offers[], key= o: o[])[]
()
instance = client.create_instance(
offer_id=best[],
image=,
disk_gb=,
onstart=,
)
()