Last updated: 2026-04-12

Quick Start

Get SpendLil tracking your AI spend in under 2 minutes.

SpendLil sits between your app and your AI provider. You keep your existing API keys, your existing code, your existing provider. You just swap the base URL for the provider-specific SpendLil gateway and add two headers.

Step 1: Create an Account

Sign up at app.spendlil.ai. You'll receive your SpendLil account key — a string starting with sl_ — which identifies your account.

text Your SpendLil key
sl_abc123def456

Step 2: Change Your Base URL

Each AI provider has its own SpendLil gateway subdomain. Swap your provider's base URL for the corresponding gateway. The path after the domain stays identical.

ProviderDirect URLSpendLil Gateway
OpenAIapi.openai.comopenai.gateway.spendlil.ai
Anthropicapi.anthropic.comanthropic.gateway.spendlil.ai
Googlegenerativelanguage.googleapis.comgoogle.gateway.spendlil.ai
Mistralapi.mistral.aimistral.gateway.spendlil.ai
diff Before → After
- POST https://api.openai.com/v1/chat/completions
+ POST https://openai.gateway.spendlil.ai/v1/chat/completions

- POST https://api.anthropic.com/v1/messages
+ POST https://anthropic.gateway.spendlil.ai/v1/messages

Step 3: Add the Headers

Add two headers: X-SpendLil-Key to identify your account, and X-Provider-Key to pass your provider API key. SpendLil uses X-Provider-Key instead of Authorization to avoid API Gateway intercepting the header.

HeaderValuePurpose
X-SpendLil-Keysl_abc123def456Identifies your SpendLil account
X-Provider-KeyBearer sk-your-openai-keyYour provider API key — passed through to the provider
bash cURL example (OpenAI)
curl https://openai.gateway.spendlil.ai/v1/chat/completions \
  -H "X-SpendLil-Key: sl_abc123def456" \
  -H "X-Provider-Key: Bearer sk-your-openai-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Step 4: Check Your Dashboard

That's it. Your first request auto-discovers your API key and starts tracking spend immediately. Open your dashboard at app.spendlil.ai to see costs by key, provider, and model in real time.

💡 Zero config required

You don't need to create agents, register API keys, or configure anything in the dashboard. SpendLil discovers your keys automatically from the first request.

What Happens Under the Hood

  1. Your account is validated via the X-SpendLil-Key header
  2. The provider is determined from the gateway subdomain (openai.gateway, anthropic.gateway, etc.)
  3. Your provider API key (from X-Provider-Key) is hashed (SHA-256) for identification — never stored
  4. If it's a new key, a record is created automatically
  5. The request is forwarded to the AI provider with X-Provider-Key reconstructed as Authorization
  6. Token usage is extracted from the provider's response
  7. Cost is calculated and logged
  8. The provider's response is returned to you with X-SpendLil-Route: governed and X-SpendLil-Request-Id headers
Your AI never goes down because of SpendLil

If SpendLil has any issues, you can fall back to calling your provider directly — just swap the URL back and use your normal Authorization header.

Language Examples

const response = await fetch(
  'https://openai.gateway.spendlil.ai/v1/chat/completions',
  {
    method: 'POST',
    headers: {
      'X-SpendLil-Key': process.env.SPENDLIL_KEY,
      'X-Provider-Key': `Bearer ${process.env.OPENAI_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'gpt-4o',
      messages: [{ role: 'user', content: 'Hello' }],
    }),
  }
);

const data = await response.json();
console.log(data.choices[0].message.content);
import os
import requests

response = requests.post(
    "https://openai.gateway.spendlil.ai/v1/chat/completions",
    headers={
        "X-SpendLil-Key": os.environ["SPENDLIL_KEY"],
        "X-Provider-Key": f"Bearer {os.environ['OPENAI_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "gpt-4o",
        "messages": [{"role": "user", "content": "Hello"}],
    },
)

data = response.json()
print(data["choices"][0]["message"]["content"])
curl https://openai.gateway.spendlil.ai/v1/chat/completions \
  -H "X-SpendLil-Key: $SPENDLIL_KEY" \
  -H "X-Provider-Key: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'

Next Steps

  • Read the provider-specific guide for OpenAI, Anthropic, Google Gemini, or Mistral
  • Learn how auto-discovery works
  • Set up spend alerts and budgets
  • Understand the resilience model