Skip to main content

Vast.ai Python SDK & CLI

PyPI version

The official Vast.ai Python package — 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

This installs vastai into an isolated managed runtime under ~/.local/share/vastai, decoupled from any system or project Python. Update anytime with vastai update, or pin/roll back with vastai update --version X.

Windows, or using the Python SDK — install from PyPI instead:

pip install vastai

Note: pip install vastai-sdk also works and installs the same package. Both package names are supported for backward compatibility.

Quickstart

  1. Get your API key from https://cloud.vast.ai/manage-keys/

  2. Set your API key:

vastai set api-key YOUR_API_KEY
  1. 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.

Migrating from vastai-sdk? The old import still works: from vastai_sdk import VastAI

Using the Serverless Client

  1. Create the client
from vastai import Serverless
serverless = Serverless() # or, Serverless("YOUR_API_KEY")
  1. Get an endpoint
endpoint = await serverless.get_endpoint("my-endpoint")
  1. 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)
  1. Read the response
text = response["response"]["choices"][0]["text"]
print(text)

Find more examples in the examples/ directory.

Tab Completion

Tab completion is supported in Bash and Zsh via argcomplete (installed automatically). To enable it:

activate-global-python-argcomplete

Or for a single session:

eval "$(register-python-argcomplete vastai)"

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vastai-1.5.4.tar.gz (262.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vastai-1.5.4-py3-none-any.whl (300.2 kB view details)

Uploaded Python 3

File details

Details for the file vastai-1.5.4.tar.gz.

File metadata

  • Download URL: vastai-1.5.4.tar.gz
  • Upload date:
  • Size: 262.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

File hashes

Hashes for vastai-1.5.4.tar.gz
Algorithm Hash digest
SHA256 0ef8919779c4972f6c6b91948ad09d27e441645dfb9a1c2bd2c987c69b116213
MD5 5807f104b24a6a7f630f880e987e4eef
BLAKE2b-256 62800e25430baffa330e09d8be58eb40ab04e795aab9e95b30c68540be7ee8e3

See more details on using hashes here.

File details

Details for the file vastai-1.5.4-py3-none-any.whl.

File metadata

  • Download URL: vastai-1.5.4-py3-none-any.whl
  • Upload date:
  • Size: 300.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

File hashes

Hashes for vastai-1.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3ff8d9c54eb037d527478e71c6107434cd59ed57648ee745bbf6b1dfe27ce4b7
MD5 b513328e22693cc531f8523edc887cb8
BLAKE2b-256 51cca31e3357e5466c2f2938fe72c84f5c72298f89d15dacb11db5b947bf7fc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page