API Key Authentication

Adaptive uses API key authentication with Bearer tokens. You’ll need to include your API key in the Authorization header for all requests.

Getting Your API Key

  1. Sign up at llmadaptive.uk
  2. Create a new project in your dashboard
  3. Navigate to API Keys section
  4. Generate a new API key
Keep your API key secure and never expose it in client-side code or public repositories.

Using Your API Key

In Headers

Include your API key in the X-Stainless-API-Key header:
curl https://llmadaptive.uk/api/v1/chat/completions \
  -H "X-Stainless-API-Key: your-adaptive-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

With OpenAI SDK

import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: "your-adaptive-api-key",
  baseURL: "https://llmadaptive.uk/api/v1",
});

Environment Variables

Store your API key in environment variables:
# .env
ADAPTIVE_API_KEY=your-adaptive-api-key
const openai = new OpenAI({
  apiKey: process.env.ADAPTIVE_API_KEY,
  baseURL: "https://llmadaptive.uk/api/v1",
});

API Key Permissions

API keys provide access to:
  • Chat completions endpoint
  • Model listing endpoint
  • Usage analytics (for your account)

Rate Limits

Rate limits are applied per API key:
  • Free Tier: 100 requests per minute
  • Pro Tier: 1,000 requests per minute
  • Enterprise: Custom limits

Error Responses

Invalid API Key

{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

Rate Limit Exceeded

{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}

Best Practices

Secure Storage

Store API keys in environment variables, never in code

Key Rotation

Regularly rotate your API keys for security

Monitoring

Monitor usage in your dashboard to track costs

Error Handling

Implement proper error handling for auth failures