Last updated: 2026-04-20
OpenRouter Integration
Route OpenRouter API calls through SpendLil.
SpendLil proxies OpenRouter's API. Swap openrouter.ai/api for openrouter.gateway.spendlil.ai and add X-SpendLil-Key. OpenRouter is OpenAI-compatible — use the OpenAI SDK with the OpenRouter gateway.
URL Pattern
diff Before → After
- POST https://openrouter.ai/api/v1/chat/completions
+ POST https://openrouter.gateway.spendlil.ai/v1/chat/completions OpenAI SDK (Python)
python Use the OpenAI SDK with the OpenRouter gateway
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ['OPENROUTER_API_KEY'],
base_url='https://openrouter.gateway.spendlil.ai/v1',
default_headers={'X-SpendLil-Key': os.environ['SPENDLIL_KEY']},
)
response = client.chat.completions.create(
model='anthropic/claude-sonnet-4-5',
messages=[{'role': 'user', 'content': 'Hello'}],
)
print(response.choices[0].message.content) cURL
bash Direct HTTP request
curl https://openrouter.gateway.spendlil.ai/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "X-SpendLil-Key: $SPENDLIL_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-5",
"messages": [{"role": "user", "content": "Hello"}]
}' One gateway, many models
OpenRouter routes to hundreds of models under a single OpenAI-compatible API. SpendLil tracks each model's usage and cost individually, letting you see exactly which OpenRouter-backed models are costing what.