Vast.ai Python SDK & CLI
Provides both the CLI and SDK for managing Vast.ai GPU cloud resources, plus a serverless client for endpoint inference.
Install
Linux, macOS, or WSL — install the CLI with no Python required:
curl -fsSL https://vast.ai/install.sh | bash
Update anytime with vastai update.
Windows, or using the Python SDK — install from PyPI instead:
pip install vastai
Quickstart
-
Get your API key from https://cloud.vast.ai/manage-keys/
-
Set your API key:
vastai set api-key YOUR_API_KEY
- Test a search:
vastai search offers --limit 3
You should see a short list of available GPU offers.
CLI Usage
The vastai command provides full access to the Vast.ai platform from your terminal:
vastai search offers 'gpu_name=RTX_4090 num_gpus>=4'
vastai create instance 12345 --image pytorch/pytorch --disk 32 --ssh --direct
vastai show instances
vastai stop instance 12345
vastai destroy instance 12345
Run vastai --help for a full list of commands. You can also use --help on any subcommand:
vastai search offers --help
vastai create instance --help
SDK Usage
from vastai import VastAI
vast = VastAI() # uses VAST_API_KEY env var, or pass api_key="..."
vast.search_offers(query='gpu_name=RTX_4090 num_gpus>=4')
vast.show_instances()
vast.start_instance(id=12345)
vast.stop_instance(id=12345)
Use help(vast.search_offers) to view documentation for any method.
Using the Serverless Client
- Create the client
from vastai import Serverless
serverless = Serverless() # or, Serverless("YOUR_API_KEY")
- Get an endpoint
endpoint = await serverless.get_endpoint("my-endpoint")
- Make a request
request_body = {
"model": "Qwen/Qwen3-8B",
"prompt" : "Who are you?",
"max_tokens" : 100,
"temperature" : 0.7
}
response = await serverless.request("/v1/completions", request_body)
- Read the response
text = response["response"]["choices"][0]["text"]
print(text)
Find more examples in the examples/ directory.
AI Agents
Vast.ai has a skill for AI coding agents (Claude Code, Cursor, Windsurf, Codex, etc.):
npx skills add vast-ai/vast-cli
This installs the Vast.ai skill so your agent can search offers, create instances, and manage GPU workflows directly. See CLI SKILL.md or SDK SKILL.md for the full reference.
Contributing
This repository is open source. If you find a bug, please open an issue. PRs are welcome.
Metadata
Release files for vastai 1.8.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vastai-1.8.3.tar.gz | 280.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vastai-1.8.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 601.8 kB
Release files / vastai-1.8.3.tar.gz
| Download URL | vastai-1.8.3.tar.gz |
|---|---|
| Size | 280.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb4911f7ddb5036363affbeec6fe2faa5b11eae0b5810b34646a5b3482605778
|
|
BLAKE2b-256 checksum How to use checksums |
5dc68d634b93fe4458dcbbc131c8cf495861bb2235bb15f9ed9a6083db2a9f2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.14 Linux/6.17.0-1022-azure
|
Release files / vastai-1.8.3-py3-none-any.whl
| Download URL | vastai-1.8.3-py3-none-any.whl |
|---|---|
| Size | 321.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c50b291dd92feecc4e0a7eb57b365afe6f9ab719c4d6b4f681d0af367757010
|
|
BLAKE2b-256 checksum How to use checksums |
a76d14bf280dcb82066bd9706cad034b975dc727774face2fb24ce9a2d40912d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.14 Linux/6.17.0-1022-azure
|