Vast.ai Python SDK
This package is deprecated. It has been merged into vast-ai/vast-cli.
pip install vastainow installs both the SDK and CLI in a single package.pip install vastai-sdkstill works and installs the same package. For issues and PRs, go to vast-ai/vast-cli.
Install
pip install vastai-sdk
Quickstart
-
Get your API key from https://cloud.vast.ai/manage-keys/
-
Set your API key:
from vastai_sdk import VastAI
vast = VastAI(api_key="YOUR_API_KEY")
Or set the VAST_API_KEY environment variable and just use:
vast = VastAI()
SDK Usage
Both of these work identically:
from vastai_sdk import VastAI
from vastai import VastAI
Both of these also work identically:
from vastai import Serverless
from vastai_sdk.serverless.client.client import Serverless
vast = VastAI()
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
- Create the client
from vastai import Serverless
serverless = Serverless() # or, Serverless("YOUR_API_KEY")
- Get an endpoint
endpoint = await serverless.get_endpoint("my-endpoint")
- 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)
- Read the response
text = response["response"]["choices"][0]["text"]
print(text)
Find more examples in the examples/ directory.
Contributing
This repo is deprecated. For issues, PRs, and documentation, go to vast-ai/vast-cli.
Release files for vastai-sdk 1.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vastai_sdk-1.6.0.tar.gz | 1.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vastai_sdk-1.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.9 kB
Release files / vastai_sdk-1.6.0.tar.gz
| Download URL | vastai_sdk-1.6.0.tar.gz |
|---|---|
| Size | 1.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f811f219afb5d4787a6f689b783a3bb8c3b9375a973501be29c311206332e31
|
|
BLAKE2b-256 checksum How to use checksums |
e7a6c5495eb46fd4439cea07e61b90ef688f82ecd7f42a6c2aeed244e5f07688
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.2 CPython/3.12.14 Linux/6.17.0-1022-azure
|
Release files / vastai_sdk-1.6.0-py3-none-any.whl
| Download URL | vastai_sdk-1.6.0-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5700c6c49b75fd22b084ec1408952a9ef7c959d40dcf70324088e80e8d65cb6f
|
|
BLAKE2b-256 checksum How to use checksums |
4dd552a28312181f32b2b817f00eeb94ae5d15e6c2bb648339026378131e2a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.2 CPython/3.12.14 Linux/6.17.0-1022-azure
|