Shadai uses API keys for secure authentication. This guide will help you set up your credentials.Getting Your API Key#
1.
Log in to your Shadai web application
2.
Navigate to API Keys page (accessible from your sidebar)
4.
Give your key a descriptive name
5.
Copy your API key immediately (you'll only see it once!)
Configuration Methods#
Method 1: Environment Variables (Recommended)#
Create a .env file in your project root:Method 2: Direct Initialization#
Pass the API key directly (not recommended for production):Method 3: Context Manager with API Key#
Environment Variables Reference#
| Variable | Description | Default | Required |
|---|
SHADAI_API_KEY | Your API key | - | ✅ |
SHADAI_BASE_URL | API base URL | http://localhost | ❌ |
SHADAI_TIMEOUT | Request timeout (seconds) | 30 | ❌ |
Security Best Practices#
✅ Do This#
Store API keys in .env files
Use different keys for dev/staging/production
Use environment-specific secrets management (AWS Secrets Manager, etc.)
❌ Don't Do This#
Hard-code API keys in source code
Commit API keys to version control
Share API keys via email or chat
Use the same key across all environments
Store keys in plain text files
Example .gitignore#
# Environment variables
.env
.env.local
.env.*.local
# API keys
*_api_key*
secrets/
Testing Authentication#
Verify your authentication is working:✅ Authentication successful! Status: ok
Error Handling#
Invalid API Key#
Missing API Key#
Multiple Accounts#
Working with multiple Shadai accounts:Custom Base URL#
For self-hosted or enterprise deployments:Next Steps#
✅ Authentication configured! Let's run your first query. Modified at 2025-10-17 17:48:00