API Authentication
Learn about authentication methods and best practices for the BrilliantAI API.
Authentication Methods
API Key Authentication
All requests must include your API key in the Authorization header:
Authorization: Bearer your-api-key
Getting Your API Key
- Sign up at brilliantai.co
- Navigate to API Keys in your dashboard
- Generate a new API key
- Store it securely
API Key Best Practices
Security
# DON'T: Hardcode API keys
api_key = "sk-..." # Bad practice
# DO: Use environment variables
import os
api_key = os.getenv("BRILLIANTAI_API_KEY")
Key Rotation
- Rotate keys regularly
- Use different keys for development/production
- Revoke compromised keys immediately
Rate Limits
Plan | Requests/Minute | Burst Limit |
---|---|---|
Free | 10 | 20 |
Pro | 60 | 100 |
Enterprise | Custom | Custom |
Rate Limit Headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1523456789
Error Handling
Common Errors
{
"error": {
"code": "invalid_api_key",
"message": "Invalid API key provided"
}
}
Error Codes
invalid_api_key
: Invalid API keyexpired_api_key
: API key has expiredinsufficient_quota
: Usage quota exceededrate_limit_exceeded
: Too many requests
Client Libraries
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.brilliantai.co",
api_key=os.getenv("BRILLIANTAI_API_KEY")
)
Node.js
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://api.brilliantai.co",
apiKey: process.env.BRILLIANTAI_API_KEY
});
Next Steps
- Explore Chat API
- Learn about Embeddings API
- Try our example applications