Skip to main content

Vast.ai Python SDK & CLI

PyPI version

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

  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.

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.

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.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vastai 1.11.0
File Size Uploaded Provenance Actions
vastai-1.11.0.tar.gz 284.0 kB Without provenance Details for vastai-1.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vastai 1.11.0
File Interpreter ABI Platform Actions
vastai-1.11.0-py3-none-any.whl Python 3 none any Details for vastai-1.11.0-py3-none-any.whl

Total release size: 609.4 kB

Release files / vastai-1.11.0.tar.gz

Download URL vastai-1.11.0.tar.gz
Size 284.0 kB
Tags Source
SHA-256 checksum
How to use checksums
90955933a981e102e2fd32285ec70e2cc0d38de1b8b7bcc23a78d0fed4459286
BLAKE2b-256 checksum
How to use checksums
aaa3e2bc36696ab1a84868b0bee934033464b0f7b22c59e4a4f76fb57f2a45d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.12.16 Linux/7.0.0-1019-azure

Release files / vastai-1.11.0-py3-none-any.whl

Download URL vastai-1.11.0-py3-none-any.whl
Size 325.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
678adde97b0747f8019b00bb8e4956915ea7220bf582d53c86e6c0083ae33197
BLAKE2b-256 checksum
How to use checksums
4c345154ba8f511d9c73de4fbffe24c5ba769a63fc3fa7331c0591a7560611bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.12.16 Linux/7.0.0-1019-azure

Security for vastai 1.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.11.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page