Skip to main content

SDK for Vast.ai GPU Cloud Service

Project description

Vast.ai Python SDK

PyPI version

The official Vast.ai SDK pip package.

Install

pip install vastai-sdk

Examples

NOTE: Ensure your Vast.ai API key is set in your working environment as VAST_API_KEY. Alternatively, you may pass the API key in as a parameter to either client.

Using the VastAI CLI client

  1. Create the client
from vastai import VastAI
vastai = VastAI() # or, VastAI("YOUR_API_KEY")
  1. Run commands
vastai.search_offers()
  1. Get help
help(v.create_instances)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vastai-1.0.0.dev1.tar.gz (122.6 kB view details)

Uploaded Source

Built Distribution

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

vastai-1.0.0.dev1-py3-none-any.whl (145.3 kB view details)

Uploaded Python 3

File details

Details for the file vastai-1.0.0.dev1.tar.gz.

File metadata

  • Download URL: vastai-1.0.0.dev1.tar.gz
  • Upload date:
  • Size: 122.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.14.0-1020-oem

File hashes

Hashes for vastai-1.0.0.dev1.tar.gz
Algorithm Hash digest
SHA256 6303f8d05862055a9b1631bfffe2f1a9c4ef9fb3f59fa0f6366850be7f8885ad
MD5 6c325ae279eb0f1f9f176817357fe712
BLAKE2b-256 26d6d19342252d4d58ec4a7470707f8e88a4d0ae8aa0475d54ad8e75cadeebb4

See more details on using hashes here.

File details

Details for the file vastai-1.0.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: vastai-1.0.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 145.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.14.0-1020-oem

File hashes

Hashes for vastai-1.0.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1598f849998f95b7c36134d7dbd775abd4989833c45b2dbf7ee0c650b735c1a
MD5 205a02e777bbc1c464bd1c74a3db8317
BLAKE2b-256 c45617653f19ae4124ffaaafc2cdc39b22ad823716f438f680babb168903043b

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