Skip to main content

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

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

vastai_sdk-1.1.3.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vastai_sdk-1.1.3-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file vastai_sdk-1.1.3.tar.gz.

File metadata

  • Download URL: vastai_sdk-1.1.3.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for vastai_sdk-1.1.3.tar.gz
Algorithm Hash digest
SHA256 cbf613557de586e81445c33fe45cb118df19f6b9287f059bd02e7bddcbeb46d7
MD5 9aa7ec3d52391872e364be299e0e9675
BLAKE2b-256 a4b31289b6a642fba8310f3369dbb0fe6b8e7ee200efa7f069148fdd9b2b9be7

See more details on using hashes here.

File details

Details for the file vastai_sdk-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: vastai_sdk-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 2.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for vastai_sdk-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 de4557504e1900a9209c7901fc54d1f0d09a731795957b0d1b72efde1ec0624c
MD5 326654b1a358db261caecca5698d61c1
BLAKE2b-256 2965078bbcf64251ef37f72f9f5d0cdb4ce9fae731251f0db4e1e0389a0a3bb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page