{"id":5740,"library":"vastai-sdk","title":"Vast.ai Python SDK","description":"The official Python SDK for Vast.ai, providing programmatic access to GPU cloud resources. Users install the `vastai-sdk` package, which then exposes the `VastAI` client class through the `vastai` module. This SDK allows for searching, launching, and managing GPU instances, mirroring much of the functionality of the Vast.ai CLI. The current version is 0.6.0, with active development.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/vast-ai/vast-sdk","tags":["vast.ai","gpu","cloud","sdk","api","machine-learning"],"install":[{"cmd":"pip install vastai-sdk","lang":"bash","label":"Install Vast.ai SDK"}],"dependencies":[{"reason":"The 'vastai-sdk' package installs and relies on the 'vastai' module (the CLI client) for its core functionality, exposing classes like 'VastAI' from it.","package":"vastai"}],"imports":[{"note":"Despite installing 'vastai-sdk', the main client class 'VastAI' is imported from the 'vastai' module.","wrong":"from vastai_sdk import VastAI","symbol":"VastAI","correct":"from vastai import VastAI"}],"quickstart":{"code":"import os\nfrom vastai import VastAI\n\n# Ensure VAST_API_KEY is set in your environment\n# or pass it directly: vast = VastAI(api_key=\"YOUR_API_KEY\")\napi_key = os.environ.get('VAST_API_KEY', '')\nif not api_key:\n    print(\"Error: VAST_API_KEY environment variable not set.\")\n    print(\"Please visit https://cloud.vast.ai/cli/ to get your API key.\")\nelse:\n    vast = VastAI(api_key=api_key)\n    try:\n        offers = vast.search_offers(query='num_gpus >= 1 gpu_name = RTX_3090', limit=1)\n        if offers:\n            print(f\"Found an offer: {offers.get('gpu_name')} at {offers.get('dph_total')}$/hr\")\n        else:\n            print(\"No matching offers found.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"Initialize the VastAI client using an API key from an environment variable or direct parameter, then search for available GPU offers."},"warnings":[{"fix":"Always install `vastai-sdk` for the Python SDK. The `from vastai import VastAI` import pattern is correct.","message":"The PyPI page for `vastai-sdk` contains a misleading message stating 'DEPRECATED — use 'pip install vastai' instead.' However, `vastai-sdk` is the active, official SDK package, and `pip install vastai-sdk` is the correct way to get the SDK client, which then imports from the `vastai` module. This causes confusion between the SDK package and the underlying CLI module.","severity":"gotcha","affected_versions":"All versions of vastai-sdk (including 0.6.0) and vastai"},{"fix":"Use `from vastai import VastAI` after installing `pip install vastai-sdk`.","message":"The `vastai-sdk` package (the SDK) exposes its client class `VastAI` via the `vastai` module, not `vastai_sdk`. Users accustomed to standard Python package import conventions might attempt `from vastai_sdk import VastAI`, which will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to `https://github.com/vast-ai/vast-sdk` for SDK-specific information and contributions.","message":"The GitHub repository provided in the prompt's live metadata (`https://github.com/vast-ai/vast-cli`) is for the `vastai` CLI client. The actual source repository for `vastai-sdk` is `https://github.com/vast-ai/vast-sdk`. This can lead to users consulting the wrong documentation or contributing to the incorrect project.","severity":"breaking","affected_versions":"N/A (metadata error)"},{"fix":"Always check PyPI (pypi.org/project/vastai-sdk) for the most up-to-date version information.","message":"The version provided in the prompt's live metadata (1.0.1) does not match the latest version on PyPI for `vastai-sdk`, which is 0.6.0 as of April 2, 2026. This discrepancy might indicate outdated information or confusion with another package.","severity":"gotcha","affected_versions":"N/A (metadata error)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}