Lightweight cost-tracking proxy for AISpendGuard. Track LLM spend with zero code changes — just swap your base URL.
- Point your OpenAI/Anthropic SDK to the proxy URL instead of the provider
- The proxy forwards requests transparently to the real provider
- Usage metadata (model, tokens, latency) is extracted from responses
- Usage events are sent to AISpendGuard for cost tracking
Privacy: The proxy never reads, logs, or stores request/response content. Only metadata is extracted.
# Python — OpenAI SDK
from openai import OpenAI
client = OpenAI(
base_url="https://proxy.aispendguard.com/v1",
default_headers={
"X-ASG-Key": "asg_your_api_key",
"X-ASG-Feature": "chat",
"X-ASG-Task-Type": "completion",
"X-ASG-Route": "/api/chat",
},
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)| Header | Required | Description |
|---|---|---|
X-ASG-Key |
Yes | AISpendGuard workspace API key |
X-ASG-Feature |
No | Feature tag for cost attribution |
X-ASG-Task-Type |
No | Task type tag |
X-ASG-Route |
No | Route tag |
X-ASG-Provider |
No | Override provider detection |
X-ASG-Base-URL |
No | Custom provider URL (allowlisted domains only) |
docker build -t asg-proxy .
docker run -p 8787:8787 -e ASG_INGEST_URL=https://aispendguard.com/api/ingest asg-proxynpm install
npm run dev # Start with tsx (hot reload)
npm test # Run tests
npm run build # Compile TypeScriptMIT