Vast.ai CLI & SDK

raw JSON →
1.0.12 verified Sat May 09 auth: no python

Official CLI and Python SDK for Vast.ai GPU cloud service, enabling users to rent GPU instances, manage storage, and interact with the platform programmatically. Current version 1.0.12, release cadence is irregular (multiple releases in 2025).

pip install vastai
error from vast import VastClient ImportError: cannot import name 'VastClient' from 'vast'
cause Incorrect import path; VastClient is available from 'vast' package but only after installing vastai.
fix
Install vastai with pip install vastai and then use from vast import VastClient.
error AttributeError: module 'vast' has no attribute 'VastClient'
cause Common mistake of importing 'vast' instead of 'vastai' package or missing install.
fix
Ensure you have installed vastai (pip install vastai) and use from vast import VastClient.
error vast: command not found
cause The CLI is not installed or not in PATH.
fix
Run pip install vastai and ensure Python scripts directory is in PATH.
breaking Auto-update is now off by default as of v0.3.1. To enable it, set `should_check_for_update = True`.
fix Create a configuration file or set environment variable as per documentation.
gotcha The `copy` command behavior changed in v0.4.0. Refer to https://docs.vast.ai/data-movement for new syntax.
fix Use new data movement options as described in the docs.
deprecated Python 3.10 is minimum version as of v1.0.12 (requires>=3.10).
fix Upgrade Python to 3.10 or later.
gotcha API keys must be passed explicitly in code; reading from `VAST_API_KEY` environment variable is not automatic.
fix Pass `api_key` argument to VastClient or set `VAST_API_KEY` and use `os.environ.get`.

Search for RTX 4090 instances and launch one for 1 hour.

import vast
from vast import VastClient

# Initialize client with API key
client = VastClient(api_key=os.environ.get('VAST_API_KEY', ''))

# Search for available instances
instances = client.search_offers('nvidia-rtx-4090')
for inst in instances[:3]:
    print(inst['id'], inst['price']['dph'])

# Create instance
instance = client.create_instance(offer_id=instances[0]['id'], duration_hours=1)
print(f"Created instance {instance['id']}")