Set Your API Key
Create a key from the Keys page, then pass it when initializing the client:api_key, the SDK reads from ~/.config/vastai/vast_api_key (the same file the CLI uses). You can also use an environment variable:
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 method you’re calling.
Create an API Key
You can create new keys from the SDK:View and Delete Keys
List all API keys on your account:Using a Scoped Key
Once you have a scoped key, initialize a separate SDK client with it:Key Expiration
API keys do not expire by default. You can revoke a key at any time from the Keys page or withvast.delete_api_key().