Overview & Quickstart
You can install the latest stable PyPI release with:
Alternatively you can get the very latest version directly from github:
This repository contains the open source python command line interface for vast.ai. This CLI has all of the main functionality of the vast.ai website GUI and uses the same underlying REST API. Most of the functionality is self-contained in the single script file vast.py, although the invoice generating commands require installing an additional second script called vast_pdf.py.
In order to authenticate most commands you will need to first login to the vast.ai website and get your api-key. Go to https://vast.ai/console/cli/. Copy the command under the heading "Login / Set API Key" and run it. The command will be something like:
vastai set api-key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
where the xxxx... is your unique api-key (a long hexadecimal number). Note that if the script is named "vast" in this command on the website and your installed script is named "vast.py" you will need to change the name of the script in the command you run. The set api-key command saves your api-key in a hidden file in your home directory. Do not share your api-key with anyone as it authenticates your other vast commands to your account.
For the most up to date help, use 'vast.py --help'. You can then get a list of the available commands. Each command also typically has help documentation:
To see how the API works you can use it to find machines for rent.
There are many parameters that can be used to filter the results. The search command supports all of the filters and sort options that the website GUI uses. To find GPU instances with compute capability 8.0 or higher:
To find instances with a reliability score >= 0.99 and at least 4 gpus, ordering by num of gpus descending:
The output of this command at the time of this writing is
You create instances using the create instance command referencing a isntance type ID returned from search offers. So to create an instance of type 2459368 (using an ID from the search above for 4x 3090 machine 4637) with the vastai/tensorflow image and 32 GB of disk storage: