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.

Release files for vastai 1.5.5

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.5.5
File Size Uploaded
vastai-1.5.5.tar.gz 264.8 kB Details

Built distribution (wheel)

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

Total release size: 566.9 kB

Release files / vastai-1.5.5.tar.gz

Download URL vastai-1.5.5.tar.gz
Size 264.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cd1f7b50dff7277a2119b2240a752a2ab785d818ae33815771c2a210dff78d4e
BLAKE2b-256 checksum
How to use checksums
4c215e1e50ed67c5de6b0e44ea68f83922c49751d4fb1f18c4945a01ee56abb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1022-azure

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

Download URL vastai-1.5.5-py3-none-any.whl
Size 302.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbc80ead74256f03f09dd575ee0d16d95d21326a9c70feba186a99862ad2ccf4
BLAKE2b-256 checksum
How to use checksums
d861964e3d610a07567bc1f70408501936fd6ad02c15735a53565faf57c27dc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

1.7.0

2 release files

1.6.0

2 release files

1.5.6

2 release files

This release

1.5.5 This release

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.13

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

1 release file

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

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