Skip to content

AISpendGuard/aispendguard-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aispendguard-proxy

Lightweight cost-tracking proxy for AISpendGuard. Track LLM spend with zero code changes — just swap your base URL.

How it works

  1. Point your OpenAI/Anthropic SDK to the proxy URL instead of the provider
  2. The proxy forwards requests transparently to the real provider
  3. Usage metadata (model, tokens, latency) is extracted from responses
  4. Usage events are sent to AISpendGuard for cost tracking

Privacy: The proxy never reads, logs, or stores request/response content. Only metadata is extracted.

Quick start

# 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!"}],
)

Custom headers

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)

Self-hosting

docker build -t asg-proxy .
docker run -p 8787:8787 -e ASG_INGEST_URL=https://aispendguard.com/api/ingest asg-proxy

Development

npm install
npm run dev      # Start with tsx (hot reload)
npm test         # Run tests
npm run build    # Compile TypeScript

License

MIT

About

AISpendGuard lightweight cost-tracking proxy — zero-code LLM spend tracking via base URL swap

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors