Authentication
CLI authentication configuration
Authentication
The VAI CLI supports multiple authentication methods and profiles.
Device Flow (Default)
The device flow is the recommended way to authenticate:
vai auth loginThis will:
- Display a URL and code
- Open your browser automatically
- Wait for you to authorize
- Store the token securely
Manual Browser
If automatic browser opening fails:
vai auth login --no-browserCheck Status
View your current authentication status:
vai auth statusExample output:
Auth Status
┌─────────┬──────────────────────────────────────┐
│ Profile │ default │
│ Status │ Authenticated │
│ User │ user@example.com │
│ Name │ John Doe │
│ Storage │ ~/.config/vai/credentials/default │
└─────────┴──────────────────────────────────────┘Logout
Remove stored credentials:
vai auth logoutGet Token
Print the current token (useful for scripting):
# Print token to stdout
vai auth token
# Use with curl
curl -H "Authorization: Bearer $(vai auth token)" \
https://vai-dev.virtuousai.com/api/v1/connectionsProfiles
Profiles allow you to manage multiple environments (dev, staging, prod).
List Profiles
vai auth profile listCreate Profile
Profiles are created automatically when you login:
vai auth login --profile stagingSwitch Profile
# Set default profile
vai auth profile select staging
# Or use environment variable
export VAI_PROFILE=stagingCheck Current Profile
vai auth profile currentConfiguration File
Profiles are configured in ~/.config/vai/config.toml:
default_profile = "default"
[profiles.default]
api_url = "https://vai-dev.virtuousai.com"
[profiles.staging]
api_url = "https://staging.virtuousai.com"
[profiles.local]
api_url = "http://localhost:8000"API Tokens
For CI/CD or automation, use API tokens instead of device flow:
# Set token via environment
export VAI_API_TOKEN=your-api-token
vai connections list
# Or create a Personal Access Token
vai tokens create --name "CI/CD Token"Troubleshooting
Token Expired
vai auth loginWrong Profile
# Check current profile
vai auth profile current
# Switch profile
vai auth profile select correct-profileStorage Issues
# Check storage location
vai auth status
# Clear and re-authenticate
vai auth logout
vai auth login