Every request to the Vast.ai API requires an API key. The CLI stores your key locally and includes it automatically in every command. This page covers how to set up, verify, and manage API keys through the CLI.Documentation Index
Fetch the complete documentation index at: https://docs.vast.ai/llms.txt
Use this file to discover all available pages before exploring further.
Set Your API Key
After creating a key from the Keys page, store it locally:~/.config/vastai/vast_api_key (or $XDG_CONFIG_HOME/vastai/vast_api_key if that env var is set). All subsequent commands use it automatically.
Environment Variable (CI/CD)
Instead of storing the key in a file, you can set it as an environment variable:If you previously used an older version of the CLI, your key may be at the legacy location
~/.vast_api_key. The CLI migrates it automatically to ~/.config/vastai/vast_api_key on next
run, so no manual action is needed.Verify Your Key
Confirm your key works by fetching your account info:If you get an authentication error, double-check your API key. The most common causes are a typo, an expired key, or a scoped key that lacks the required permission for the command you’re running.
Create an API Key
You can create new keys from the CLI:View and Delete Keys
List all API keys on your account:Key Expiration
API keys do not expire by default. You can revoke a key at any time from the Keys page or withvastai delete api-key.