Skip to main content

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

  1. Sign up at brilliantai.co
  2. Navigate to API Keys in your dashboard
  3. Generate a new API key
  4. 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

PlanRequests/MinuteBurst Limit
Free1020
Pro60100
EnterpriseCustomCustom

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 key
  • expired_api_key: API key has expired
  • insufficient_quota: Usage quota exceeded
  • rate_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