This repository contains the open source command line interface for Vast.ai. This CLI replicates much of the functionality available in the Vast.ai website GUI by using the same underlying REST API. Most of the functionality is contained within the single script file vast.py, while additional features (such as PDF invoice generation) are provided by the supplementary script vast_pdf.py.
Our Python SDK is maintained through a separate repository vast-ai/vast-sdk.
- Quickstart
- Usage
- Install
- Commands
- List of Commands and Associated Help Message
- Self-Test a Machine (Single Machine)
- Host Machine Testing with
vast_machine_tester.py - Usage Examples
- Tab-Completion
It is recommended that you create a dedicated subdirectory to store this script and its related files. For example, you might create a directory named vid (short for "Vast Install Directory"):
mkdir vid
cd vidOnce inside your directory, download the vast.py script:
wget https://raw.githubusercontent.com/vast-ai/vast-python/master/vast.py
chmod +x vast.pyVerify that the script is working by running:
./vast.py --helpYou should see a list of available commands. Next, log in to the Vast.ai website and obtain your API key from https://vast.ai/console/cli/. Copy the provided command under "Login / Set API Key" and run it. The command will look similar to:
./vast.py set api-key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThis command saves your API key in a hidden file in your home directory. Keep your API key secure.
You can test a search command with:
./vast.py search offers --limit 3This should display a short list of machine offers.
We also now support Poetry as our dependency manager! If you're having trouble installing external packages, through requirements.txt, we recommend to use Poetry which manages this all for you.
In order to get started -
# Install poetry if you don't have it already.
curl -sSL https://install.python-poetry.org | python3 -
# Install project dependencies
poetry install
# Run vast.py
python vast.py
The Vast.ai CLI provides a variety of commands for interacting with the Vast.ai platform. For example, you can search for available machines by running:
./vast.py search offersTo refine your search, consult the extensive help by running:
./vast.py search offers --helpYou can filter results based on numerous parameters, similar to the website GUI.
For example, to find Turing GPU instances (with compute capability 7.0 or higher):
./vast.py search offers 'compute_cap > 700'Or to find instances with a reliability score ≥ 0.99 and at least 4 GPUs (ordered by GPU count descending):
./vast.py search offers 'reliability > 0.99 num_gpus>=4' -o 'num_gpus-'If you followed the Quickstart instructions, you have already installed the main CLI script (vast.py).
For generating PDF invoices, you will need the vast_pdf.py script (found in this repository) and the third-party library Borb. To install Borb, run:
pip3 install borbThe Vast.ai CLI is primarily contained within the vast.py script. Commands follow a simple "verb-object" pattern. For example, to run the command "show machines", you would type:
./vast.py show machinesFor a full list of commands and help messages, run:
./vast.py --helpThis will display available commands including, but not limited to:
helpcreate instancedestroy instancesearch offersself-test machineshow instances... and many others.
Hosts can perform a self-test on a single machine to verify that it meets the necessary requirements and passes reliability and stress tests.
./vast.py self-test machine <machine_id> [--ignore-requirements]machine_id: The numeric ID of the machine to test.--ignore-requirements(optional): Continues tests even if system requirements are not met. If omitted, the self-test stops at the first requirement failure.
Examples:
# Standard self-test, respecting requirements:
./vast.py self-test machine 12345
# Self-test ignoring system requirements:
./vast.py self-test machine 12345 --ignore-requirementsOutput:
- Requirements Check:
The script verifies whether the machine meets all necessary requirements. If any requirements are not met, it will report the failures. - Instance Creation:
A temporary test instance is launched. - Test Execution:
A series of tests are performed (system checks, GPU tests, stress tests, etc.). - Summary:
The results are displayed, indicating whether the machine passed or failed along with any error messages.
The temporary test instance is automatically destroyed after testing.
./vast.py self-test machine 54321If the machine fails to meet requirements, the output will indicate the failure reasons and the test will stop.
./vast.py self-test machine 54321 --ignore-requirementsThis command will display the failing requirements but continue with the self-test.
python3 vast_machine_tester.py --host_id 123456 --ignore-requirementsThis command will run self-tests on multiple machines from the specified host and output the results to passed_machines.txt and failed_machines.txt.
python3 vast_machine_tester.py --host_id 123456 --sample-pct 30This command tests approximately 30% of the machines, randomly sampled from the total list.
The vast.py script supports tab-completion in both Bash and Zsh shells if the argcomplete package is installed. To enable tab-completion:
- Install
argcomplete:pip3 install argcomplete
- Enable global tab-completion by running:
Alternatively, for a single session, run:
activate-global-python-argcomplete
eval "$(register-python-argcomplete vast.py)"
Note: Rapid invocations via tab-completion might trigger API rate limits. If you experience issues, please report them in the project's GitHub issues.
This documentation should help you get started with the Vast.ai CLI tools and understand the available commands and usage patterns. For more detailed information, refer to the inline help provided by each command.