Agent skill

Vastai SDK

by vast-ai in vast-ai/vast-cli

Vast.ai Python SDK — high-level API for GPU instances, volumes, serverless endpoints, and billing.

MITAuto-check passedBackend & APIs

Install Vastai SDK

skills CLI
$ npx skills add vast-ai/vast-cli --skill vastai-sdk -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install vast-ai/vast-cli vastai-sdk --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/vast-ai/vast-cli.git skills-src && mkdir -p .claude/skills && cp -r skills-src/vastai_sdk .claude/skills/vastai-sdk && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
vastai-sdk
GitHub stars
223
Token cost
~2k tokens
SKILL.md length
252 words
Files
2
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Vast.ai Python SDK — high-level API for GPU instances, volumes, serverless endpoints, and billing.

  • Tasks that involve Serverless
  • SKILL.md covers Installation, Authentication, Backward Compatibility and VastAI Class (High-Level SDK), plus 4 more sections
  • Runs Python scripts from its folder; calls pip

What it does

Vastai SDK is an agent skill from vast-ai/vast-cli. Vast.ai Python SDK — high-level API for GPU instances, volumes, serverless endpoints, and billing.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `__init__.py`). Compatibility notes: Python 3.9+

It sits in Backend & APIs, covering Serverless. It works with Python. The repository describes itself as: Vast.ai python and cli api client. The licence is MIT.

When your agent uses it

  • Tasks that involve Serverless

Example prompts

  • “/vastai-sdk”

Requirements

  • Python 3
  • A credential in YOUR_API_KEY
  • Compatibility (from SKILL.md): Python 3.9+
  • Pre-approved tools (allowed-tools): Python(vastai:*)

What it can do on your machine

Read from SKILL.md and the folder at commit 8d0d31c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Python(vastai:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • console.vast.ai
    • vast.ai

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Python 3.9+

    From compatibility in the SKILL.md frontmatter.

Context cost

Vastai SDK loads about 2k tokens when it runs. Until then it costs about 27 tokens; SKILL.md has 252 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~27
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from vast-ai/vast-cli at commit 8d0d31c, republished under its MIT licence (© vast-ai). 252 words, ~1,984 tokens.

Download SKILL.mdSave it as .claude/skills/vastai-sdk/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
vastai-sdk
description
Vast.ai Python SDK — high-level API for GPU instances, volumes, serverless endpoints, and billing.
allowed-tools
Python(vastai:*)
compatibility
Python 3.9+
metadata.author
vast-ai

Vast.ai Python SDK (vastai / vastai_sdk)

The vastai package provides a Python SDK for managing GPU instances, volumes, serverless endpoints, and billing on Vast.ai. The vastai_sdk package is a backward-compatibility shim that re-exports vastai.

Installation

bash
pip install vastai

For serverless and async support:

bash
pip install "vastai[serverless]"

Authentication

The SDK reads the API key from ~/.vast_api_key by default. You can also pass it explicitly:

python
from vastai import VastAI
vast = VastAI()                        # reads ~/.vast_api_key
vast = VastAI(api_key="YOUR_API_KEY")  # explicit key

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

Backward Compatibility

The old vastai_sdk import still works:

python
from vastai_sdk import VastAI  # equivalent to: from vastai import VastAI

VastAI Class (High-Level SDK)

python
from vastai import VastAI
vast = VastAI(api_key=None, server_url=None, retry=3, raw=False, quiet=False)
Instance Management
python
# List all your instances
instances = vast.show_instances()

# Get a single instance
instance = vast.show_instance(id=12345)

# Search GPU offers
offers = vast.search_offers(query='gpu_name=RTX_4090 num_gpus>=4 reliability>0.99')

# Create an instance from an offer
result = vast.create_instance(id=<offer_id>, image="pytorch/pytorch:latest", disk=50)

# ...as a jupyter instance on a direct connection
result = vast.create_instance(id=<offer_id>, image="pytorch/pytorch:latest", disk=50,
                              jupyter=True, direct=True, jupyter_lab=True)

# Lifecycle
vast.start_instance(id=12345)
vast.stop_instance(id=12345)
vast.reboot_instance(id=12345)
vast.destroy_instance(id=12345)

# Label an instance
vast.label_instance(id=12345, label="my-training-run")

# Get SSH connection string
ssh_url = vast.ssh_url(id=12345)   # returns "ssh -p PORT user@host"
scp_url = vast.scp_url(id=12345)   # returns scp-compatible URL
Interruptible (spot) rentals

Interruptible (spot) instances are priced below on-demand instances, but can be interrupted at any time by another user with a lower bid. Note: vast.search_offers(type='bid', ...) exposes min_bid, but vast.create_instance(...) defaults to on-demand at dph_total unless you pass bid_price=<floor>. Always pass bid_price after a type='bid' search, otherwise the instance will be rented as an on-demand instance/price instead of as an interruptible.

When outbid, the instance moves to stopped (not destroyed) and storage charges continue. Resume by raising the bid via vast.change_bid(id=..., price=...).

python
# Search GPU offers (use help(vast.search_offers) for full query syntax)
offers = vast.search_offers(query='gpu_name=RTX_3090 num_gpus>=2')

# Search volume offers
volumes = vast.search_volumes(query='...')

# Search network volumes
net_vols = vast.search_network_volumes()

# Search templates
templates = vast.search_templates()

# Search invoices
invoices = vast.search_invoices()
Data Transfer
python
# copy() takes vast URLs: "[C.|V.]id:path", "cloud_service[.id]:path", or "local:path"
vast.copy("local:./data/", "C.12345:/workspace/data/")   # Local → instance
vast.copy("C.12345:/workspace/results/", "local:./out/") # Instance → local
vast.copy("12345:/workspace/", "67890:/workspace/")      # Instance → instance (legacy format)
vast.copy("s3.101:/data/", "C.12345:/workspace/")        # Cloud service → instance
vast.copy("V.1234:/file", "C.5678:/workspace/")          # Volume → instance
vast.copy("V.1234:/file", "s3.101:/workspace/")          # Volume → cloud service

vast.cancel_copy(dst_id=12345)                           # Cancel an in-progress copy

# Cloud sync via a saved cloud connection (see the UI settings page for connection IDs)
vast.cloud_copy(src="./data", dst="s3://bucket/path", instance=12345,
                connection=<conn_id>, transfer="Instance To Cloud")
vast.cancel_sync(dst_id=12345)

Volume copy is currently only supported for copying to other volumes, instances, or cloud services, not local. Do not use /root or / as a destination directory — it breaks ssh permissions on the instance and future copies fail. See https://vast.ai/docs/gpu-instances/data-movement#constraints.

Serverless Deployments
python
# List all deployments
deployments = vast.show_deployments()

# Get a deployment
deployment = vast.show_deployment(id=42)

# Delete a deployment
vast.delete_deployment(id=42)
Machine Management (Hosting)
python
machines = vast.show_machines()
machine = vast.show_machine(id=10)
vast.list_machine(id=10, price_gpu=0.30)
vast.unlist_machine(id=10)
SSH Keys
python
keys = vast.show_ssh_keys()
vast.create_ssh_key(ssh_key="ssh-rsa AAAA...")
vast.delete_ssh_key(id=5)
Team Management
python
members = vast.show_members()
vast.invite_member(email="user@example.com", role="developer")
vast.remove_member(id=7)

SyncClient (Low-Level Sync)

SyncClient provides typed, synchronous access to GPU offers and instances.

python
from vastai import SyncClient

client = SyncClient(api_key="YOUR_API_KEY")  # or reads ~/.vast_api_key

# Search offers with structured filters
offers = client.search(
    num_gpus=2,
    gpu_name="RTX_4090",
    min_reliability=0.99,
    max_dph_total=2.0,
)

# Create an instance (SyncClient takes an InstanceConfig, not loose kwargs)
from vastai.data.instance import InstanceConfig

instance = client.create_instance(
    offer_id=<id>,
    config=InstanceConfig(image="pytorch/pytorch:latest", disk=50),
)

# List your instances
instances = client.show_instances()  # returns list[SyncInstance]

# Destroy an instance
client.destroy_instance(instance_or_id=12345)

AsyncClient (Low-Level Async)

AsyncClient provides async access to GPU offers and instances. Use as an async context manager.

python
import asyncio
from vastai import AsyncClient
from vastai.data.instance import InstanceConfig

async def main():
    async with AsyncClient(api_key="YOUR_API_KEY") as client:
        # Search offers
        offers = await client.search(num_gpus=1, gpu_name="A100")

        # Create instance
        instance = await client.create_instance(
            offer_id=<id>, config=InstanceConfig(image="ubuntu:22.04"))

        # List instances
        instances = await client.show_instances()  # returns list[AsyncInstance]

        # Destroy instance
        await client.destroy_instance(instance_or_id=instance.id)

asyncio.run(main())

Serverless Client

For inference endpoints (requires pip install "vastai[serverless]"):

python
import asyncio
from vastai import Serverless

async def main():
    serverless = Serverless()  # reads ~/.vast_api_key

    # Get an endpoint
    endpoint = await serverless.get_endpoint("my-endpoint")

    # Make a request
    response = await serverless.request("/v1/completions", {
        "model": "Qwen/Qwen3-8B",
        "prompt": "Who are you?",
        "max_tokens": 100,
        "temperature": 0.7,
    })

    text = response["response"]["choices"][0]["text"]
    print(text)

asyncio.run(main())

Common Patterns

python
# Find cheapest 4x RTX 4090 and launch a job
from vastai import VastAI
vast = VastAI()

offers = vast.search_offers(query='gpu_name=RTX_4090 num_gpus=4 reliability>0.99')
cheapest = min(offers, key=lambda o: o['dph_total'])
result = vast.create_instance(id=cheapest['id'], image="pytorch/pytorch:latest", disk=100)
print(f"Launched instance: {result['new_contract']}")

# Use help() to explore method signatures
help(vast.search_offers)
help(vast.create_instance)

© vast-ai, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in vastai_sdk of vast-ai/vast-cli.

  • SKILL.md
  • __init__.py

Open the folder on GitHubat commit 8d0d31c

Compare with similar skills

Vastai SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Vastai SDK compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Vastai SDK this skillvast-ai/vast-cli223—~2kAutomated safety check: PassMIT
AWS Serverless Edazxkane/aws-skills3674 repos~3.2kAutomated safety check: PassMIT
Adobe App Builder Action Scaffolderadobe/skills197—~3.1kAutomated safety check: PassApache-2.0
Cookbook Computedatabricks-solutions/databricks-apps-cookbook183—~790Automated safety check: PassCustom licence
Modaldavila7/claude-code-templates33k7 repos~2.6kAutomated safety check: PassMIT
ModalK-Dense-AI/scientific-agent-skills48k1 repos~4.5kAutomated safety check: NotesApache-2.0

Similar skills

  • AWS Serverless Eda

    zxkane/aws-skills

    AWS serverless and event-driven architecture expert based on Well-Architected Framework.

    367 GitHub starsUsed in 4 repos~3.2k tokens
    Backend & APIsAuto-check passed
  • Scaffolds, implements, deploys and debugs Adobe Runtime actions in App Builder projects, with templates for webhooks, events, database CRUD, sequences and Asset Compute workers.

    197 GitHub stars~3.1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Cookbook Compute

    databricks-solutions/databricks-apps-cookbook

    Connect Databricks Apps to shared clusters or serverless compute using Databricks Connect.

    183 GitHub stars~790 tokensUpdated 6 days ago
    Backend & APIsAuto-check passed
  • Modal

    davila7/claude-code-templates

    Run Python code in the cloud with serverless containers, GPUs, and autoscaling.

    33k GitHub starsUsed in 7 repos~2.6k tokens
    Backend & APIsAuto-check passed
  • Modal

    K-Dense-AI/scientific-agent-skills

    Modal is a serverless cloud platform for running Python on demand, including on-demand GPUs.

    48k GitHub starsUsed in 1 repo~4.5k tokens
    Backend & APIsAuto-check: notes
  • Edgeone Makers Cloud Functions

    TencentEdgeOne/edgeone-makers-tools

    EdgeOne Makers Cloud Functions — Node.js, Go, and Python runtimes.

    1.9k GitHub starsUsed in 1 repo~237 tokens
    Backend & APIsAuto-check passed

Works with

Categories

Questions about Vastai SDK

What does Vastai SDK do?

Vast.ai Python SDK — high-level API for GPU instances, volumes, serverless endpoints, and billing. Vastai SDK is an agent skill from vast-ai/vast-cli.ai Python SDK — high-level API for GPU instances, volumes, serverless endpoints, and billing.

When should I use Vastai SDK?

Vastai SDK fits situations like: tasks that involve Serverless.

How do I install Vastai SDK in Claude Code?

Run `npx skills add vast-ai/vast-cli --skill vastai-sdk -a claude-code`. Or copy the skill folder (vastai_sdk in vast-ai/vast-cli) into .claude/skills/vastai-sdk in your project. Claude Code loads it when a task matches its description.

How do I install Vastai SDK in Codex?

Run `npx skills add vast-ai/vast-cli --skill vastai-sdk -a codex`. Or copy the skill folder (vastai_sdk in vast-ai/vast-cli) into .agents/skills/vastai-sdk in your project. Codex loads it when a task matches its description.

Can I use Vastai SDK in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add vast-ai/vast-cli --skill vastai-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/vastai-sdk, .gemini/skills/vastai-sdk, .github/skills/vastai-sdk and .opencode/skills/vastai-sdk in your project.

What does Vastai SDK need to run?

Going by SKILL.md and its folder, Vastai SDK needs Python for the scripts in its folder and the command-line tools its instructions call (pip). Our summary lists: Python 3; A credential in YOUR_API_KEY. Its frontmatter pre-approves these tools: Python(vastai:*). Compatibility (from SKILL.md): Python 3.9+.

Does Vastai SDK access the network?

SKILL.md names 2 domains. As links in the text: console.vast.ai and vast.ai. This is read from the text; nothing was executed.

Is Vastai SDK safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Vastai SDK use?

Vastai SDK is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Vastai SDK use?

About 2k tokens (SKILL.md is roughly 7.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Vastai SDK?

Skills that share tags, products or a category with Vastai SDK: AWS Serverless Eda (zxkane/aws-skills, 367 stars), Adobe App Builder Action Scaffolder (adobe/skills, 197 stars), Cookbook Compute (databricks-solutions/databricks-apps-cookbook, 183 stars) and Modal (davila7/claude-code-templates, 33k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Vastai SDK?

vast-ai (a GitHub organization) maintains it in vast-ai/vast-cli, which has 223 GitHub stars. The repository was last updated on October 9, 2026.

Source: vast-ai/vast-cli on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.