Last updated: 2026-04-20
Proxy Endpoints
API reference for SpendLil's proxy gateway.
The proxy is SpendLil's core service. Each AI provider has its own gateway subdomain. Your standard provider auth header passes through unchanged — just swap the base URL and add X-SpendLil-Key.
Gateway Subdomains
| Provider | Gateway URL | Upstream |
|---|---|---|
| OpenAI | https://openai.gateway.spendlil.ai | api.openai.com |
| Anthropic | https://anthropic.gateway.spendlil.ai | api.anthropic.com |
| https://google.gateway.spendlil.ai | generativelanguage.googleapis.com | |
| Mistral | https://mistral.gateway.spendlil.ai | api.mistral.ai |
| Groq | https://groq.gateway.spendlil.ai | api.groq.com |
| DeepSeek | https://deepseek.gateway.spendlil.ai | api.deepseek.com |
| xAI (Grok) | https://xai.gateway.spendlil.ai | api.x.ai |
| Together | https://together.gateway.spendlil.ai | api.together.xyz |
| Fireworks | https://fireworks.gateway.spendlil.ai | api.fireworks.ai |
| Perplexity | https://perplexity.gateway.spendlil.ai | api.perplexity.ai |
| OpenRouter | https://openrouter.gateway.spendlil.ai | openrouter.ai/api |
| Cohere | https://cohere.gateway.spendlil.ai | api.cohere.com |
The path after the domain is forwarded as-is to the upstream provider. For example, openai.gateway.spendlil.ai/v1/chat/completions forwards to api.openai.com/v1/chat/completions.
Proxy Request
ANY
/{path+} Forward any request to the AI provider determined by the gateway subdomain.
Required Headers
| Header | Required | Description |
|---|---|---|
| X-SpendLil-Key | Yes | Your SpendLil account key (e.g., sl_abc123). |
| Authorization | Provider-dependent | Bearer <key> — OpenAI, Mistral, Cohere, Groq, DeepSeek, xAI, Together, Fireworks, Perplexity, OpenRouter. Also accepted by Anthropic. |
| x-api-key | Provider-dependent | Anthropic native auth. |
| x-goog-api-key | Provider-dependent | Google Gemini. |
| X-SpendLil-Tag | No | Optional label for filtering spend by workload (max 64 chars). |
| Content-Type | Yes | application/json (standard for AI APIs). |
Provider SDKs work unchanged
Point your existing SDK's baseURL at the SpendLil gateway and add X-SpendLil-Key to defaultHeaders. No code rewrite needed.
Response Headers
| Header | Value | Description |
|---|---|---|
| X-SpendLil-Route | governed | Request was successfully tracked. |
| X-SpendLil-Route | bypassed | Request was forwarded but tracking failed (temporary). |
| X-SpendLil-Request-Id | uuid | Unique identifier for this proxied request. |
Health Check
GET
/health Returns proxy health status. Available on each gateway subdomain.
bash Check all gateways
for p in openai anthropic google mistral groq deepseek xai together fireworks perplexity cohere openrouter; do
echo -n "$p: "
curl -s https://$p.gateway.spendlil.ai/health | jq -r .status
done Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | MISSING_SPENDLIL_KEY | X-SpendLil-Key header not provided |
| 400 | MISSING_AUTH | No provider auth header (Authorization / x-api-key / x-goog-api-key) |
| 400 | UNKNOWN_PROVIDER | Gateway subdomain does not match a supported provider |
| 401 | INVALID_SPENDLIL_KEY | SpendLil account not found for this key |
| 403 | ACCOUNT_INACTIVE | SpendLil account is suspended or cancelled |
| 502 | PROVIDER_ERROR | Could not connect to the AI provider |