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.

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.5.0.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.5.0-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vastai_sdk-1.5.0.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-1020-azure

File hashes

Hashes for vastai_sdk-1.5.0.tar.gz
Algorithm Hash digest
SHA256 c64998a236a4ab8c5a62b1248566d063363c3ee6226f1da29cfdb5ff3c0ac545
MD5 a4b026aea4ccd714d0fa8501ebf0552c
BLAKE2b-256 28abb12d591c3ae79850d40f985084598b4d5663f6d9fd01f84dcebff8512ae7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vastai_sdk-1.5.0-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-1020-azure

File hashes

Hashes for vastai_sdk-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cc638c629e88a3b69f6f8ed7b41a9c451ee54fd46df689dae5dad49ff4ef33b
MD5 1a885bb5d1a3b386bc96484caa97df0a
BLAKE2b-256 b3396160deaec94f3b197a777eb6b96e177b121f2c2e932c84c90caff2c49680

See more details on using hashes here.

Release history Release notifications | RSS feed

1.5.5

2 files

1.5.4

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

This release

1.5.0 This release

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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