>>
Use Case · LLM Spend Monitoring

Monitor your OpenAI API spend in real time.

Trough proxies your OpenAI API calls and tracks what each endpoint costs. See daily spend, catch runaway usage early, and set alerts before the monthly bill arrives. Works with any HTTP API, not just OpenAI.

Install Trough Free Trough overview

Three commands to start tracking.

curl -fsSL https://stockyard.dev/trough/install.sh | sh
TROUGH_ADMIN_KEY=secret trough

# Register OpenAI as an upstream
curl -s -X POST http://localhost:8790/api/upstreams \
  -d '{"name":"openai","base_url":"https://api.openai.com"}'

# Add cost rule for completions (adjust for your model/pricing)
curl -s -X POST http://localhost:8790/api/upstreams/{id}/rules \
  -d '{"path_pattern":"/v1/chat/completions","cost_cents":2}'

Then route your app through http://localhost:8790/proxy/{id}/ instead of calling OpenAI directly. Headers, body, and auth pass through unchanged — the only difference is Trough logs each request and applies your cost rule.

What you see

Spend by day, by endpoint, by model.

Once traffic flows through Trough, you get daily cost summaries, per-endpoint breakdowns, and a request log with cost per call. Check it via the dashboard at /ui or the API:

curl -s http://localhost:8790/api/spend \
  -H 'Authorization: Bearer secret' | jq .

# {"total_cents":4821,"total_cents_month":4821,
#  "by_day":[{"date":"2026-03-31","requests":247,"cost_cents":494},...],
#  "by_endpoint":[{"path":"/v1/chat/completions","requests":247,"cost_cents":494}]}

Export to CSV for finance teams: GET /api/export.csv. Pro adds 90-day history, spend alerts, and anomaly detection when a route spends more than 2x its 7-day average.

Note on LLM cost tracking: Trough tracks at the request level, not at the token level. For per-token cost tracking across 16 providers with model-aware pricing, Stockyard includes that built in alongside request tracing, cost routing, and prompt management.

Monitor any API you're paying for.

Trough isn't OpenAI-specific. The same setup works for Anthropic, Twilio, SendGrid, Stripe, AWS, or any internal HTTP service you want to cost-track. Register multiple upstreams, define cost rules per route, and get a unified spend view across all your APIs.

If you're spending money on APIs and don't know where it's going, Trough gives you that visibility in under 5 minutes — free for one service, $2.99/mo for unlimited services.

Related

Trough: API cost monitor  ·  Guide: find expensive API routes  ·  Stockyard: LLM cost tracking with token-level granularity

See what you're spending on OpenAI before the bill arrives.

Single binary. Free to start. Works with any HTTP API.

Install Trough See pricing