Authentication Methods
Bearer Token
The most common authentication method is using a Bearer token in the Authorization header:API Key Header (Anthropic Format)
For Anthropic-compatible endpoints, you can also use thex-api-key header:
Getting Your API Key
1
Dashboard Method
The recommended method for obtaining an API key is through the MegaLLM dashboard:
- Visit megallm.io/dashboard
- Navigate to API Keys section
- Click “Create New API Key”
- Copy the key (starts with
sk-mega-) and store it securely
2
CLI Tool
If you have the MegaLLM CLI installed:Follow the interactive prompts to set up your API key.
Security Best Practices
Environment Variables
- Linux/Mac
- Windows
- Docker
Using SDKs
OpenAI SDK
Anthropic SDK
LangChain Integration
Troubleshooting
Common Authentication Errors
| Error Code | Message | Solution |
|---|---|---|
| 401 | Unauthorized | Check if your API key is valid and not expired |
| 403 | Forbidden | Verify API key has required access |
| 429 | Rate Limited | Wait and retry or contact support |
Debugging Authentication
Enable debug mode to see detailed authentication information:Need Help? Check our FAQ or contact support if you’re experiencing authentication issues.

