Guides

Authentication

Learn how to authenticate your API requests using API keys.

API Keys

The CatLove AI API uses API keys for authentication. You can create and manage your API keys from the Dashboard.

Keep your API key secure

Your API key grants access to your account and usage quota. Never share your API key in client-side code, public repositories, or with unauthorized users.

Using Your API Key

Include your API key in the Authorization header of your API requests:

Authorization: Bearer sk-your-api-key

Example Requests

Here are examples of authenticated requests in different languages:

curl https://api.catlove.cc/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Environment Variables

We recommend storing your API key in environment variables rather than hardcoding it in your source code:

# .env file
CATLOVE_API_KEY=sk-your-api-key

# In your code
import os
api_key = os.environ.get("CATLOVE_API_KEY")

API Key Permissions

When creating an API key, you can configure the following settings:

  • Name - A descriptive name to identify the key
  • Budget Limit - Maximum spend limit for the key
  • Expiration - Optional expiration date for the key
  • Model Access - Restrict access to specific models

Key Rotation

For security best practices, we recommend rotating your API keys periodically. You can have multiple active keys to facilitate seamless rotation:

  1. Create a new API key in the dashboard
  2. Update your application to use the new key
  3. Verify the new key is working correctly
  4. Delete the old API key

OpenAI SDK Compatible

Our API is fully compatible with the OpenAI SDK. Simply change the base_url to use CatLove AI with existing OpenAI code.