llmtee and cost gateways: measuring what an agent really spends, with the numbers

Your coding agent sends a request, gets a response, re-reads it, fixes it, tries again. Every round burns tokens, and every token has a price. At month's end the API invoice lands and you answer "was that all expected?" — while staring at a number you cannot explain. It is the exact problem a fuel gauge solves for a car: without the needle, you drive blind and discover your consumption when it is too late.
llmtee is the fuel gauge for your LLM calls: a self-hosted proxy that logs every request with tokens, cost, latency and time to first token, and that can say "stop" when a key goes over its budget.
The invisible cost of agents
Agents multiply consumption. A human interaction with a model is a sequence of tokens in and out; a tool-use agent is a loop: it reads the context, calls a tool, re-reads the result, decides the next step. The context grows every round and the prefill recomputes it all. Not coincidentally, the Gartner report we analyzed these past days estimates that most agentic cost goes into repeated tokens rather than useful work — the local vs API cost comparison matters even more when the counterpart is not a person but a loop.
The practical point: until you know what each key, each model, each session costs, you cannot make decisions. You cannot move boring tasks to a cheaper model, you cannot tell which tool burns more than expected, you cannot answer "how much will this experiment cost?" without a number.
How llmtee works
llmtee is a single Go binary with a SQLite file (or PostgreSQL, if you prefer) that sits between your client and the provider. Like the Unix tee, it passes each response through unchanged and keeps a copy. You point your client's base URL at the proxy — http://localhost:8080/openai/v1 for OpenAI, /anthropic for Anthropic, /u/<name>/v1 for any OpenAI-compatible upstream, including Ollama, vLLM and OpenRouter — and no code changes: official SDKs, Claude Code, Codex and automation tools work as they are.
For every request the proxy logs:
- input and output tokens (taken from the provider's response: if the response carries no usage, the row is marked "usage unknown" — llmtee never estimates),
- cost, computed with LiteLLM's price table embedded at build time and refreshed weekly,
- latency and time to first token,
- key, model, upstream, timestamp.
Prices stay as they were at request time: a later price change does not rewrite history. Local models and hosted APIs show up in the same dashboard, so the "this task on Ollama or on the API" comparison is made on real numbers, not impressions.
Setup in ten minutes
From the official repository, the Docker quickstart is:
docker run -d --name llmtee -p 8080:8080 -v llmtee-data:/data \
-e LLMTEE_ADMIN_PASSWORD=change-me ghcr.io/garritfra/llmtee
Without Docker, download the binary from the releases (Linux, macOS and Windows, amd64 and arm64) and run it with the same environment variable. Then point your client:
export OPENAI_BASE_URL=http://localhost:8080/openai/v1
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
The first request now appears in the web UI at http://localhost:8080, with its tokens and cost. If it does not work, check two things: that OPENAI_BASE_URL points at the proxy and not the provider, and that the provider key is still in the client (llmtee forwards it unchanged).
The budget is the part that changes things. An llmtee key replaces the provider key on the client side — teammates and agents never see it — and can carry a daily and a monthly cap:
llmtee keys create coding-agent --budget-day 5 --budget-month 60
When a key reaches its limit, llmtee answers with HTTP 429 in the provider's error format and does not forward the request. One honest detail: the cost of a request is known only when the response arrives, so the request that crosses the limit completes, and a key can overshoot its budget by that single call. A cap is not a perfect switch, but it is the difference between "done" and "surprise".
The numbers: latency and budget in practice
Putting a proxy in the request path has a cost. The numbers declared in the project, on an Apple M4 Pro at 200 requests per second against a fake upstream: +0.14 ms at p50, +0.02 ms at p99, about 33 MB of memory. Reproducible with make loadtest. The tradeoff is worth keeping in mind: llmtee sits in the path, so if it goes down your LLM calls fail — monitor /healthz and keep the provider's direct base URL at hand.
On the budget side, the reasoning is done with your numbers. The example is illustrative: an agent using 1 million input tokens and 200k output tokens a day, on a model at $3 per million input and $12 per million output (indicative prices: the real values are in the dashboard, where llmtee reads them from the LiteLLM table), spends about 3 + 2.4 = 5.4 dollars a day, or 162 dollars a month. Set a daily cap at 5 dollars and the week in which the agent goes into a loop is no longer the week you discover the invoice: the 429 arrives on day one, the evening before the damage.
The data goes out where you want it: web UI, CSV export, Prometheus metrics at /metrics, or an MCP server with the get_spend, list_requests and get_request tools — an agent can read its own spending.
llmtee versus the other cost gateways
The README's table compares the four paths you can take:
| llmtee | Helicone (self-hosted) | Langfuse | LiteLLM Proxy | |
|---|---|---|---|---|
| Integration | base URL | base URL | SDK / OpenTelemetry | base URL |
| Services to run | 1 binary (+optional Postgres) | several containers | web, worker, Postgres, ClickHouse, Redis, S3 | proxy + Postgres |
| Hard budgets per key | yes | rate-limit policies | no | yes |
| Status | active | maintenance since March 2026 | active | active |
| Scope | logging, cost, budgets | logging, analytics | tracing, evals, prompts | gateway: routing, fallbacks, 100+ providers |
The choice is a matter of perimeter: llmtee is deliberately a measurement and containment tool — no evals, playground, caching, load balancing, fallbacks, SSO or multi-tenancy. If you need routing and fallbacks, the gateway is LiteLLM Proxy; if you need tracing and evals, Langfuse. If you only need to understand what you spend and put a cap on it, the single binary is the minimum that does the job. For protecting secrets when the agent uses them, the topic is different and we covered it here: Secret Guard and local LLM gateways.
The limits, stated plainly
llmtee is 0.x software: configuration may change between minor versions. The native Gemini, Azure OpenAI and AWS Bedrock APIs are not supported yet (their OpenAI-compatible endpoints are). It does not model batch, flex or priority pricing: cost is only as good as the price table. Body logging is on by default with 30-day retention — handy for inspecting the prompt behind each cost, but bodies can contain sensitive data: you can switch it off globally (LLMTEE_LOG_BODIES=false), per upstream, or per request with the Llmtee-Omit-* headers. Provider keys never touch the database — only SHA-256 hashes — and there is no telemetry.
Sources
- llmtee — repository and README: https://github.com/garritfra/llmtee
- LiteLLM price table used by the proxy: https://docs.litellm.ai/docs/simple_proxy
In summary
llmtee is a self-hosted proxy, one Go binary with a SQLite file, that logs the tokens, cost, latency and TTFT of every LLM call — local and API in the same dashboard. Daily and monthly per-key budgets return a 429 instead of a surprise; the declared added latency is under a quarter of a millisecond at p50. It is not a gateway: no routing, fallbacks or evals, by design. If your agents are spending tokens in silence, the first move is not to change models: it is to install the fuel gauge.
Article generated with AI
In these reading paths
Enjoyed this article?
Subscribe to the newsletter for new tutorials and guides.

