DEPRECATED — use 'pip install vastai' instead. This package is a compatibility wrapper that installs vastai.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vastai_sdk-1.0.4.tar.gz.
File metadata
- Download URL: vastai_sdk-1.0.4.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.13 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da0956d3e2ce3591ec5866ee51f70256937f32804fd7b801ce1ca0b80732cd55
|
|
| MD5 |
127fd4f7bf0c21f91f65cb62c2970719
|
|
| BLAKE2b-256 |
ebb5439ee44c408ce15e90ef0da6ccdbb333b0217783d1d0c33e705ee5a06096
|
File details
Details for the file vastai_sdk-1.0.4-py3-none-any.whl.
File metadata
- Download URL: vastai_sdk-1.0.4-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.13 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b7c3394c63535777861ac72bb42c1a9e3723a0a3788ca4546022343fd7eb9b6
|
|
| MD5 |
ac2c5c4d5ac55a1a16275d9f795716d9
|
|
| BLAKE2b-256 |
d20a1ffdd9c36646bfa9ed727ec4834a30f719826a3375a602584871e3c07e54
|