Skip to main content

API Keys

All API requests require authentication using an API key. Include your key in the Authorization header:
Authorization: Bearer sk-your-api-key

Getting Your API Key

  1. Log in to your LemonData Dashboard
  2. Navigate to API Keys section
  3. Click Create New Key
  4. Give your key a descriptive name
  5. Copy the key immediately - it’s only shown once
Security Best Practices:
  • Never expose API keys in client-side code
  • Don’t commit keys to version control
  • Use environment variables to store keys
  • Rotate keys periodically
  • Delete unused keys

Using API Keys

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("LEMONDATA_API_KEY"),
    base_url="https://api.lemondata.cc/v1"
)

API Key Features

Usage Limits

You can set a usage limit on each API key to control spending:
SettingDescription
No LimitKey uses your account balance without restrictions
Fixed LimitKey stops working after reaching the specified amount

Key Prefix

All LemonData API keys start with sk- prefix. The key format is:
sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Anthropic API Compatibility

For Anthropic-style requests, you can also use the x-api-key header:
curl https://api.lemondata.cc/v1/messages \
  -H "x-api-key: sk-your-api-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-sonnet-20241022",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Error Responses

Status CodeError TypeDescription
401unauthorizedMissing or invalid API key
401invalid_api_keyAPI key format is incorrect
401expired_api_keyAPI key has been revoked or expired
402insufficient_balanceAccount balance is insufficient
402quota_exceededAPI key usage limit reached
Example error response:
{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_api_key",
    "code": "invalid_api_key"
  }
}