Registry / devops / vastai-sdk

vastai-sdk

JSON →
library1.5.6pypypi✓ verified 23d ago

The official Python SDK for Vast.ai, providing programmatic access to GPU cloud resources. Users install the `vastai-sdk` package, which then exposes the `VastAI` client class through the `vastai` module. This SDK allows for searching, launching, and managing GPU instances, mirroring much of the functionality of the Vast.ai CLI. The current version is 0.6.0, with active development.

pip install vastai-sdk
INSTALL
IMPORT
SIG · VASTAI-SDK
V
vastai-sdk
devopspythonv1.5.6
Install
11.8s avg
Import
1891ms
Disk
179MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 12.7s
py 3.11
✓ —
✓ 11.2s
py 3.12
✓ —
✓ 9.9s
py 3.13
✓ —
✓ 10s
py 3.9
✕ build_error
✓ 15s
179MB installed
● package 179MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

VastAI
from vastai import VastAI
from vastai_sdk import VastAI
Despite installing 'vastai-sdk', the main client class 'VastAI' is imported from the 'vastai' module.

Initialize the VastAI client using an API key from an environment variable or direct parameter, then search for available GPU offers.

import os from vastai import VastAI # Ensure VAST_API_KEY is set in your environment # or pass it directly: vast = VastAI(api_key="YOUR_API_KEY") api_key = os.environ.get('VAST_API_KEY', '') if not api_key: print("Error: VAST_API_KEY environment variable not set.") print("Please visit https://cloud.vast.ai/cli/ to get your API key.") else: vast = VastAI(api_key=api_key) try: offers = vast.search_offers(query='num_gpus >= 1 gpu_name = RTX_3090', limit=1) if offers: print(f"Found an offer: {offers.get('gpu_name')} at {offers.get('dph_total')}$/hr") else: print("No matching offers found.") except Exception as e: print(f"An error occurred: {e}")
vastai --version
Debug
Known issues
gotchaThe PyPI page for `vastai-sdk` contains a misleading message stating 'DEPRECATED — use 'pip install vastai' instead.' However, `vastai-sdk` is the active, official SDK package, and `pip install vastai-sdk` is the correct way to get the SDK client, which then imports from the `vastai` module. This causes confusion between the SDK package and the underlying CLI module.
fix
Always install `vastai-sdk` for the Python SDK. The `from vastai import VastAI` import pattern is correct.
affects: All versions of vastai-sdk (including 0.6.0) and vastai
gotchaThe `vastai-sdk` package (the SDK) exposes its client class `VastAI` via the `vastai` module, not `vastai_sdk`. Users accustomed to standard Python package import conventions might attempt `from vastai_sdk import VastAI`, which will fail.
fix
Use `from vastai import VastAI` after installing `pip install vastai-sdk`.
affects: All versions
breakingThe GitHub repository provided in the prompt's live metadata (`https://github.com/vast-ai/vast-cli`) is for the `vastai` CLI client. The actual source repository for `vastai-sdk` is `https://github.com/vast-ai/vast-sdk`. This can lead to users consulting the wrong documentation or contributing to the incorrect project.
fix
Refer to `https://github.com/vast-ai/vast-sdk` for SDK-specific information and contributions.
affects: N/A (metadata error)
gotchaThe version provided in the prompt's live metadata (1.0.1) does not match the latest version on PyPI for `vastai-sdk`, which is 0.6.0 as of April 2, 2026. This discrepancy might indicate outdated information or confusion with another package.
fix
Always check PyPI (pypi.org/project/vastai-sdk) for the most up-to-date version information.
affects: N/A (metadata error)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'vastai'
The vastai-sdk package has not been installed in the current Python environment or is not accessible.
fix
pip install vastai-sdk
SyntaxError: invalid syntax
Python module names cannot contain hyphens; the package `vastai-sdk` provides the module `vastai`.
fix
import vastai
vastai.errors.APIError: 401 Unauthorized: Invalid API Key
The provided Vast.ai API key is missing, incorrect, expired, or lacks the necessary permissions.
fix
client = vastai.VastAI(api_key="YOUR_VALID_API_KEY")
AttributeError: module 'vastai' has no attribute 'Client'
The main client class in the `vastai` module is named `VastAI`, not `Client`.
fix
client = vastai.VastAI(api_key="...")
Upgrade
Version history
1.5.6latest on PyPI · released Aug 26, 2026
Audit
Dependencies
vastairequiredThe 'vastai-sdk' package installs and relies on the 'vastai' module (the CLI client) for its core functionality, exposing classes like 'VastAI' from it.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
vastai-sdk — pip install vastai-sdk · libregistry