Last updated: 2026-04-12
Proxy Endpoints
API reference for SpendLil's proxy gateway.
The proxy is SpendLil's core service. Each AI provider has its own gateway subdomain.
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 |
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). |
| X-Provider-Key | Yes | Your provider API key (e.g., Bearer sk-...). Reconstructed as Authorization before forwarding. |
| Content-Type | Yes | application/json (standard for AI APIs). |
Why X-Provider-Key instead of Authorization?
AWS API Gateway intercepts the standard Authorization header. SpendLil uses X-Provider-Key to pass your provider key through, then reconstructs it as Authorization before forwarding to the upstream provider.
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
curl https://openai.gateway.spendlil.ai/health
curl https://anthropic.gateway.spendlil.ai/health
curl https://google.gateway.spendlil.ai/health
curl https://mistral.gateway.spendlil.ai/health Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | MISSING_SPENDLIL_KEY | X-SpendLil-Key header not provided |
| 400 | MISSING_AUTH | X-Provider-Key header not provided |
| 400 | INVALID_AUTH | X-Provider-Key header is empty or malformed |
| 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 |