Skip to main content

Vast.ai Python SDK

This package is deprecated. It has been merged into vast-ai/vast-cli. pip install vastai now installs both the SDK and CLI in a single package. pip install vastai-sdk still works and installs the same package. For issues and PRs, go to vast-ai/vast-cli.

Install

pip install vastai-sdk

Quickstart

  1. Get your API key from https://cloud.vast.ai/manage-keys/

  2. 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

  1. Create the client
from vastai import Serverless
serverless = Serverless() # or, Serverless("YOUR_API_KEY")
  1. Get an endpoint
endpoint = await serverless.get_endpoint("my-endpoint")
  1. 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)
  1. 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.

Metadata

Release files for vastai-sdk 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vastai-sdk 1.9.0
File Size Uploaded Provenance Actions
vastai_sdk-1.9.0.tar.gz 1.8 kB Without provenance Details for vastai_sdk-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vastai-sdk 1.9.0
File Interpreter ABI Platform Actions
vastai_sdk-1.9.0-py3-none-any.whl Python 3 none any Details for vastai_sdk-1.9.0-py3-none-any.whl

Total release size: 3.9 kB

Release files / vastai_sdk-1.9.0.tar.gz

Download URL vastai_sdk-1.9.0.tar.gz
Size 1.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b8c944f9c10036f206c95ae710e1876c210013198f190116d6e55f239cf8ed3f
BLAKE2b-256 checksum
How to use checksums
01ecb1c38f5f5d65c1a3dcfcde80c920fb2efee0a3b852d1d885ded1eafbbdf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.12.15 Linux/7.0.0-1017-azure

Release files / vastai_sdk-1.9.0-py3-none-any.whl

Download URL vastai_sdk-1.9.0-py3-none-any.whl
Size 2.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d4e0e26e15b2525711bc69aedab7fe077a7f0d580d361322fd5db8ca7c30cd5
BLAKE2b-256 checksum
How to use checksums
d0d4561717d5c737deaa0ecbe938bb6662a1519b35afba463e4b026f003e75bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.12.15 Linux/7.0.0-1017-azure

Security for vastai-sdk 1.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.9.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page