Authentication
// Setup via CLI
Run the interactive setup:
bashcopy
elith initThis creates ~/.elith/config.toml with your provider configuration.
// Manual Setup
Create or edit ~/.elith/config.toml:
[providers.claude]
api_key = "sk-ant-api03-..."
model = "claude-3-5-sonnet-20241022"
enabled = true
[providers.lmstudio]
base_url = "http://localhost:1234/v1"
model = "local-model"
enabled = false
[providers.openrouter]
api_key = "sk-or-..."
model = "anthropic/claude-3.5-sonnet"
enabled = false
// Provider-Specific Setup
Claude (Anthropic)
- Go to https://console.anthropic.com/
- Navigate to API Keys
- Create a new key
- Add to config:
[providers.claude]
api_key = "sk-ant-api03-..."
model = "claude-3-5-sonnet-20241022"
enabled = true
Available models:
claude-3-5-sonnet-20241022(recommended)claude-3-opus-20240229claude-3-sonnet-20240229claude-3-haiku-20240307
OpenRouter
- Go to https://openrouter.ai/keys
- Create an API key
- Add to config:
[providers.openrouter]
api_key = "sk-or-..."
model = "anthropic/claude-3.5-sonnet"
enabled = true
Available models:
anthropic/claude-3.5-sonnetanthropic/claude-3-opusopenai/gpt-4-turbogoogle/gemini-pro-1.5
LM Studio (Local)
- Download and install LM Studio
- Load a model (e.g., CodeLlama, DeepSeek Coder)
- Start the local server (default:
http://localhost:1234) - Add to config:
[providers.lmstudio]
base_url = "http://localhost:1234/v1"
model = "local-model" # Use the model name from LM Studio
enabled = true
No API key required for local models.
// Environment Variables
You can also use environment variables instead of config file:
# Claude
export ANTHROPIC_API_KEY="sk-ant-api03-..."
export ANTHROPIC_MODEL="claude-3-5-sonnet-20241022"
# OpenRouter
export OPENROUTER_API_KEY="sk-or-..."
# Google (if using Gemini via OpenRouter)
export GOOGLE_API_KEY="AIza..."
Environment variables take precedence over config file.
// Key Rotation
To rotate your API key:
- Update
~/.elith/config.tomlwith new key - Restart backend:
bashcopy
elith service restartOr use environment variables for one-time use:
ANTHROPIC_API_KEY=new-key elith explain src/app.ts
// Verification
Test your authentication:
bashcopy
elith explain README.mdIf authentication fails, you'll see:
[error] Authentication failed: Invalid API key
[error] Check your configuration in ~/.elith/config.toml
// Multiple Providers
You can configure multiple providers and switch between them:
[providers.claude]
api_key = "sk-ant-..."
model = "claude-3-5-sonnet-20241022"
enabled = true # Currently active
[providers.openrouter]
api_key = "sk-or-..."
model = "anthropic/claude-3.5-sonnet"
enabled = false # Disabled
[providers.lmstudio]
base_url = "http://localhost:1234/v1"
model = "local-model"
enabled = false # Disabled
Only one provider can be enabled at a time. To switch:
- Set
enabled = falsefor current provider - Set
enabled = truefor new provider - Restart backend:
elith service restart
// Security Best Practices
- Never commit API keys to version control
- Use environment variables in CI/CD
- Rotate keys regularly (every 90 days)
- Use separate keys for development and production
- Monitor usage via provider dashboards
// Troubleshooting
"Invalid API key" error
- Check key format (should start with
sk-ant-for Claude,sk-or-for OpenRouter) - Verify key is active in provider dashboard
- Check for extra spaces or newlines in config
"Provider not found" error
- Ensure provider is enabled in config
- Restart backend:
elith service restart - Check config file syntax:
cat ~/.elith/config.toml
"Connection refused" error (LM Studio)
- Ensure LM Studio server is running
- Check base_url matches LM Studio port
- Verify model is loaded in LM Studio
// Next Steps
- Configuration — Customize Elith
- Quickstart — Run your first task
- API Reference — CLI commands