Last updated: 2026-04-20

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 SDK code, your existing provider. You just swap the base URL for the provider-specific SpendLil gateway and add one header.

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
Groqapi.groq.comgroq.gateway.spendlil.ai
DeepSeekapi.deepseek.comdeepseek.gateway.spendlil.ai
xAI (Grok)api.x.aixai.gateway.spendlil.ai
Togetherapi.together.xyztogether.gateway.spendlil.ai
Fireworksapi.fireworks.aifireworks.gateway.spendlil.ai
Perplexityapi.perplexity.aiperplexity.gateway.spendlil.ai
OpenRouteropenrouter.ai/apiopenrouter.gateway.spendlil.ai
Cohereapi.cohere.comcohere.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 X-SpendLil-Key

Add one new header: X-SpendLil-Key, set to your account key. Keep your existing provider auth header (Authorization: Bearer, x-api-key, or x-goog-api-key) exactly as it is — SpendLil passes it through unchanged. The official provider SDKs all work without modification.

HeaderValuePurpose
X-SpendLil-Keysl_abc123def456Identifies your SpendLil account (required)
AuthorizationBearer sk-your-keyYour provider API key — OpenAI, Mistral, Groq, DeepSeek, xAI, Together, Fireworks, Perplexity, OpenRouter, Cohere
x-api-keysk-ant-your-keyAnthropic native auth (Authorization: Bearer also accepted)
x-goog-api-keyAIza-your-keyGoogle Gemini
X-SpendLil-TagchatbotOptional label for filtering spend by workload (max 64 chars)
bash cURL example (OpenAI)
curl https://openai.gateway.spendlil.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-openai-key" \
  -H "X-SpendLil-Key: sl_abc123def456" \
  -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, groq.gateway, etc.)
  3. Your provider API 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 your auth header intact
  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 to the real provider. Your existing auth header is already correct; nothing else needs to change.

Language Examples

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: 'https://openai.gateway.spendlil.ai/v1',
  defaultHeaders: {
    'X-SpendLil-Key': process.env.SPENDLIL_KEY,
  },
});

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello' }],
});
console.log(response.choices[0].message.content);
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ['OPENAI_API_KEY'],
    base_url='https://openai.gateway.spendlil.ai/v1',
    default_headers={'X-SpendLil-Key': os.environ['SPENDLIL_KEY']},
)

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

Next Steps

  • Read the provider-specific guide for the AI service you use
  • Learn how auto-discovery works
  • Set up spend alerts and budgets
  • Understand the resilience model