Skip to main content
Logfire for AI

LLM observability, down to the query that made it slow

Every agent run, model call and tool call recorded as one trace, alongside the HTTP requests and database queries around them, and queried with SQL. Free for 10 million spans a month.

Python
import logfire

logfire.configure()
logfire.instrument_pydantic_ai()
logfire.instrument_asyncpg()
Definition

What is LLM observability?

LLM observability is the practice of recording what an AI application actually did in production, and being able to ask questions about it afterwards. Traditional monitoring tells you a request returned 200 in 900ms. LLM observability tells you the agent called the wrong tool twice, retried, spent 14,000 tokens and produced an answer nobody checked.

The unit that matters is the run, not the call. A single run is usually a tree: several model calls, tool invocations, retrieval steps, and sometimes handoffs between agents across more than one service. Recording that tree with the causal chain intact is what separates an answerable question from a pile of individual requests.

The difference

Problems in AI applications hide in the seams

An LLM-only tool shows you the model call. It does not show you the SELECT that made retrieval slow, the API timeout inside a tool call, or the vector search that quietly returned nothing. Those are where production AI actually breaks, and they are not LLM problems, they are application problems that happen to be adjacent to a model.

Logfire is a full OpenTelemetry backend that also understands agent runs. One request through FastAPI, Postgres, a vector search and a model call is one trace. When an agent stalls because a downstream service is degraded, the connection is visible rather than inferred across two products.

Setup

One line per library

Python
import logfire
from pydantic_ai import Agent

logfire.configure()
logfire.instrument_pydantic_ai()
logfire.instrument_httpx()
logfire.instrument_asyncpg()

agent = Agent('openai:gpt-5-mini')
result = agent.run_sync('Why did checkout slow down?')

Each instrument_* call is one line, and they compose: instrumenting the agent framework, the HTTP client and the database driver is what produces a single trace rather than three disconnected ones. Other frameworks work the same way through the OpenTelemetry GenAI conventions and OpenInference. Full details are in the integrations guide.

What you get

Every run, end to end

Eight agent cards, one per detected framework, each with its own purpose, model and volume: Crew Planner on CrewAI breaks a goal into tasks for a crew, gpt-4o, 1.3K runs at $4.2 and 3.1 seconds; Supervisor Graph on LangGraph routes each turn to a specialist node, claude-sonnet-4, 8.5K runs at $31.8; Code Agent on smolagents writes and executes Python, gpt-4o-mini, 412 runs at $0.94; Agno Assistant answers product questions from the docs index; Group Chat on AutoGen runs a multi-agent debate, 96 runs averaging 18.9 seconds; Volt Responder on VoltAgent drafts support email replies on claude-opus-4.1; Genkit Flow summarizes documents; and Incident Responder on Traceloop triages a page. Last-active times range from 7 hours to 14 days.
Agents are discovered from your traces, and the framework they were built with is detected rather than declared. CrewAI, LangGraph, smolagents, Agno, AutoGen, VoltAgent, Genkit and Traceloop here, alongside native OpenTelemetry GenAI. Runs, cost and latency per agent, without registering anything.

The run, not the request

An agent run is a tree: model calls, tool invocations, retrieval steps and handoffs to other agents. Logfire records it as one trace with that structure intact, so you can see which tool was called, what it returned, and which step actually cost the time. Agents are detected from the OpenTelemetry GenAI conventions and from OpenInference, so this works across frameworks rather than only with Pydantic AI.

Tokens and cost per model, per provider

Every model call carries its token counts and its cost, so you can see spend by model, by provider and by agent, alongside latency, error rate, output tokens per second, cache reads and tool-call rate. Cost is read from the span rather than estimated afterwards, and it is queryable like any other attribute, so 'which agent spent the most last week' is a query rather than a spreadsheet.

The conversation, rendered

Open supported model spans and read the exchange as a conversation: system, user, assistant and tool messages in order, with tool names, arguments, payloads and token badges. Pydantic AI and selected native OpenTelemetry GenAI integrations provide the richest view. The fields shown depend on what the instrumentation emits; OpenInference and other bridges may omit message, tool or cost details.

Prompts you can change without a deploy

Keep prompts out of your code with versioned, labeled templates the SDK fetches at runtime. Roll a new prompt out to a percentage of traffic, target it at a subset of users, and roll it back without shipping. Every resolution is recorded, so you can tell which version produced which run.

Evals in the same place as the traces

Turn a production trace into a test case, run experiments from code with pydantic-evals, and compare a candidate against a baseline case by case. Evaluation results are emitted as OpenTelemetry events and are queryable alongside production traces.

OpenTelemetry-native, so nothing is trapped

Logfire speaks OpenTelemetry natively. Instrument with our SDK or with plain OTel, send from any language that has an OTel SDK, and export the same data elsewhere whenever you want. Your instrumentation is an asset you own rather than something rented from a vendor.

At a glance

Ninety-six agents, one screen

A list is fine for eight agents and useless for a hundred. The honeycomb puts the whole fleet on one screen, one cell per agent, colored by the metric you are worried about and grouped by the dimension you suspect, here error rate, grouped by model.

The agent honeycomb, 96 visible agents colored green through red by error rate and grouped by model. claude-opus-4.1 holds 10 agents, claude-sonnet-4 holds 29, gemini-2.5-flash 16, gemini-2.5-pro 18 and gpt-5-mini 23. Most cells are pale green under 2 percent, with scattered deep-red cells at 30.8, 29.5, 28.3, 27.2 and 26 percent.
Grouping by model is the version that pays: the red cells are not spread evenly, so 'which model is failing my agents' is answered by looking rather than by querying. Change the grouping to provider, or the color to cost or latency, and it answers a different question.
Models and providers

What you are spending it on, and whether it is up

Every model your application called, discovered from the same spans, no list to maintain, and no surprise when someone ships a new one.

The models inventory. Cards for gpt-4o on OpenAI with 24.8k calls at a 1 percent exception rate, 820 millisecond average latency and $184 cost; a Bedrock inference-profile ARN for claude-sonnet-4 with 12.1k calls, a 5 percent exception rate and $96.70 across 11,900 of 12,100 priced calls; and gemini-2.5-pro on Google with 6.3k calls, no latency because none were timed, and no pricing data. Each card also carries speed, input, output and cache-read tokens, a truncation rate and a tool-call rate.
Calls, exceptions, latency, tokens and cost per model, derived from your traces, with the gaps left visible rather than filled in. Gemini reports no pricing data and no latency, because none of those 6,300 calls were priced or timed, which is a different statement from zero.

The same view rolls up by provider, and this is where it stops being an inventory and starts being an SLO. Set a target on a provider and it reports against it, so "is OpenAI having a bad day" is a number you already have rather than a status page you go and read.

The providers table. OpenAI with 5 models, 31,200 calls, 1.2 percent exceptions, 940 millisecond average latency peaking at 8.2 seconds, 24.1M input and 4.6M output tokens, $268 cost, and reliability chips showing availability at 97 percent in red against target and success rate at 100 percent in green. Anthropic with 2 models, 12,100 calls and $96.70, and Google with 1 model, 6,300 calls and a 9 percent exception rate, both offering a Set reliability targets button.
OpenAI is missing its availability target, 97% against 99%, and the chip is red before anyone opens a dashboard. Providers with no target yet get a one-click way to set one, so the SLO lives next to the spend rather than in a separate tool.
Query

The SQL your agent already knows

SQL
select
  attributes->>'gen_ai.request.model' as model,
  count(*) as calls,
  avg(duration) as avg_seconds
from records
where attributes->>'gen_ai.request.model' is not null
  and start_timestamp > now() - interval '7 days'
group by model
order by avg_seconds desc;

Observability has produced a remarkable number of query languages: PromQL, LogQL, TraceQL, NRQL, SPL, ES|QL, KQL. The fragmentation is enough of a problem that the CNCF has an initiative to standardize them. Logfire uses SQL in PostgreSQL syntax, so there is nothing new to learn, and your traces, metrics and logs all answer to the same queries.

It is also the SQL a coding agent already knows. Point Claude Code, Cursor or Codex at the Logfire MCP server and ask why runs got slower last Tuesday: it writes the query, because the query is ordinary SQL rather than a dialect it has seen a handful of examples of.

The store

FusionFire

Every AI-native vendor has a name for the thing underneath by now. Braintrust has Brainstore, Langfuse runs on ClickHouse. Ours is FusionFire, and it is the part of Logfire we are most pleased with.

It is built on Apache DataFusion, a columnar, streaming, vectorized engine that uses Apache Arrow as its in-memory format, and shaped around what AI observability actually asks of a database. Agent runs are wide: a single span can carry a whole conversation, its tool payloads, its token counts and its cost. Then you want to group by a model name or a customer id that nobody indexed in advance, across an enormous number of them.

The reason to say the name out loud is that ours is the one you can point ordinary SQL at. A purpose-built store usually arrives with a bespoke API, because the store is the product and the API is how you are kept close to it. Fast and familiar are not in tension here.

We are not going to publish a benchmark you cannot re-run yourself. But it is genuinely interesting engineering and we like talking about it, so ask us about it. In the meantime, here is somebody else's number rather than ours:

We migrated from LangSmith to Logfire and the time it took to query our agent traces went down by 96.2%.
Andrew Pignanelli, Founder and CEO, General Intelligence Company Read the case study
In production

Teams running agents on Logfire

Having it built primarily off a first-class observability platform is the big thing that sold me as we're not running just LLM agents. We want to see observability on your API endpoints and all that other stuff too.
Bryan Godwin, Evergreen.ai Read the case study
Decision guide

Is Logfire right for you?

Choose Logfire if

  • Your AI feature is part of a larger application, and you want one trace across both
  • You want to know why a run was slow, including when the cause was a database query
  • You want token and cost tracking per model, provider and agent, queryable with SQL
  • You use more than one agent framework, or expect to change framework
  • You want evals and production traces in the same system rather than two

Choose an LLM-only tool if

  • Your product is only a model call, with no backend worth tracing
  • You need a workflow feature specific to one vendor's evaluation product
  • You want your evaluation suite hosted and run for you, rather than from your own CI
FAQ

Common questions

How is agent observability different from LLM observability?

LLM observability covers a single model call: the prompt, the response, tokens and cost. Agent observability covers a whole run, which is usually a tree: several model calls, tool invocations, retrieval steps and handoffs between agents, often across more than one service. The unit you care about is the run, not the call, so the trace has to keep the causal chain intact rather than showing you a list of individual requests.

Can I see my database queries and my LLM calls in one trace?

Yes, and this is the main reason to use Logfire rather than an LLM-only tool. Logfire is a full OpenTelemetry backend, so a request that hits FastAPI, queries Postgres, runs a vector search and then calls a model produces one trace containing all of it. When an agent run is slow because the retrieval query was slow, you see it in the same waterfall rather than inferring it across two products.

Which agent frameworks does Logfire support?

Logfire detects agents from the OpenTelemetry GenAI semantic conventions and from OpenInference, so it works across frameworks rather than only with our own. Pydantic AI, LangGraph, OpenAI Agents SDK, CrewAI, smolagents, Agno, Google ADK, Strands, Semantic Kernel, Mastra and the Vercel AI SDK all arrive as structured runs. The integrations documentation carries a support matrix showing exactly which signals reach us from each one, which is worth reading before you commit to a framework.

Does Logfire support OpenTelemetry?

Logfire is built on OpenTelemetry rather than wrapping it. Any language with an OTel SDK can send data, standard OTel instrumentation works unchanged, and you can export the same telemetry to another backend. There is no proprietary agent and no proprietary wire format, so your instrumentation stays portable.

Will tracing my agents add latency?

Spans are batched and exported asynchronously on a background thread, so instrumentation does not sit in the request path. For high-volume services you can sample: head sampling decides before work happens, tail sampling decides after, so you can keep every failed or slow agent run while sampling the routine ones.

How much does it cost to trace an AI application?

Personal includes 10 million spans, logs and metrics per month and pauses ingestion at the limit. On Team and Growth, usage beyond the included 10 million records costs $2 per million. Logfire does not add a separate per-score fee for evaluation results.

See what your agents are actually doing

Get started with 10 million free spans, logs, and metrics per month. No credit card required.