LLM and agent observability
What to record for every agent run, what to alert on, and how the tools compare.
LLM observability is recording what your model-powered code does in production so you can answer three questions: did it work, why not, and what did it cost. For agents, which make many model and tool calls per task, that means tracing each run as a tree of steps rather than logging single requests.
What to record for every agent run
- The run tree. Agents, steps, tool calls, retrievers and handoffs as nested spans, with timing.
- Every model call. Provider, model, tokens and other units, latency, status and, if you allow it, the prompt and response.
- Where it came from. The function, file and line that made each call, and the release it shipped in.
- The outcome. Succeeded or failed, the error, and whether a retry finished the work.
- Quality. A score for each finished run: rules such as latency or tool errors, and rubric checks for things like faithfulness or tool choice.
- Cost. Priced per component (cached input, reasoning, audio, characters, searches), split by agent, feature, customer and model.
Monitoring: what to alert on
- Failure rate by agent or workflow, and new error types after a release.
- Spend spikes: a feature or customer costing far more than usual.
- Budgets: a hard limit per agent, feature, customer or provider, with a kill switch.
- Quality drops: pass rates on your checks falling over time.
- Latency on the slowest step, not only the whole run.
Proxy or SDK?
A gateway sits in the request path and sees every call that goes through it. That suits routing and central key management, but adds a hop and only sees what is routed through it. An SDK observes calls inside your process, so it also sees the code and the agent step that made each one, and nothing changes in your request path. CostKey is SDK-based: no proxy.
LLM observability tools compared
| Tool | Self-host | Focus |
|---|---|---|
| CostKey | Free, one command | Agent runs, failures, code-level attribution, cost and budgets across 45+ providers |
| Langfuse | Free | Tracing, prompt management, datasets and evaluations |
| LangSmith | Enterprise plan | Tracing and evaluation, LangChain first |
| Helicone | Yes | Gateway with request logging |
| Arize Phoenix | Yes | Tracing and evaluation on OpenTelemetry |
| Braintrust | Enterprise | Evaluations and experiments |
Getting started
Pick your framework: OpenAI Agents SDK, LangGraph, Vercel AI SDK, CrewAI, Claude Agent SDK or others. Plain provider SDKs work with no integration at all.
Questions
What is the difference between LLM observability and LLM monitoring?
Monitoring tells you something is wrong: alerts on failures, spend and quality. Observability lets you find out why, by tracing each run down to the step and the code.
What is agent observability?
LLM observability for agents: tracing a whole run as a tree of agents, steps and tool calls, because one task can make dozens of model calls.
Do I need OpenTelemetry?
No. CostKey's SDKs capture calls directly. If your stack already emits OpenTelemetry spans, the bridge turns them into CostKey spans.
Try it on your own machines
One command starts Postgres, the server and the console with Docker.
curl -fsSL https://costkey.dev/install.sh | sh