| name | vastai-install-auth |
| description | Install and configure Vast.ai CLI and REST API authentication.
Use when setting up a new Vast.ai integration, configuring API keys,
or initializing Vast.ai GPU cloud access in your project.
Trigger with phrases like "install vastai", "setup vastai",
"vastai auth", "configure vastai API key", "vastai gpu setup".
|
| allowed-tools | Read, Write, Edit, Bash(pip:*), Bash(vastai:*), Bash(curl:*), Grep |
| version | 1.11.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","vast-ai","api","authentication"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Vast.ai Install & Auth
Overview
Set up the Vast.ai CLI and REST API access for renting GPU compute instances. Vast.ai is a marketplace where individual hosts and data centers list GPU machines at prices significantly below hyperscaler providers.
Prerequisites
Instructions
Step 1: Install the CLI
set -euo pipefail
pip install vastai
vastai --version
Step 2: Get Your API Key
- Log in at https://cloud.vast.ai
- Navigate to Account > API Keys (or visit https://cloud.vast.ai/cli/)
- Copy your API key (a long hexadecimal string)
Step 3: Configure Authentication
vastai set api-key YOUR_API_KEY_HERE
vastai show user
For programmatic use, set the environment variable:
export VASTAI_API_KEY="your-api-key-here"
echo 'VASTAI_API_KEY=your-api-key' >> .env
Step 4: Verify with REST API
curl -s -H "Authorization: Bearer $VASTAI_API_KEY" \
"https://cloud.vast.ai/api/v0/users/current" | jq '{id, username, balance}'
Step 5: Python Client Setup
import os
import requests
from typing import Optional, Dict, Any, List
:
BASE_URL =
():
.api_key = api_key os.environ.get()
.api_key:
key_file = os.path.expanduser()
os.path.exists(key_file):
.api_key = (key_file).read().strip()
.api_key:
ValueError()
.session = requests.Session()
.session.headers.update({
: ,
: ,
})
() -> [, ]:
url =
resp = .session.request(method, url, **kwargs)
resp.raise_for_status()
resp.json()
() -> []:
._request(, , params={: (query)})
() -> :
body = {: , : image, : disk_gb,
: onstart, : env {}}
._request(, , json=body)
() -> []:
._request(, )[]
() -> :
._request(, )
__name__ == :
client = VastClient()
user = client._request(, )
()
()