# Pydantic Logfire

> Observability for Python apps and LLM calls, built on OpenTelemetry by the Pydantic team

- Category: Evaluation & Production Ops / Observability & LLMOps
- Language: Python
- Licence: MIT
- Repository: https://github.com/pydantic/logfire
- Website: https://pydantic.dev/logfire
- Canonical page: https://ai-tldr.dev/tools/pydantic-logfire/

## In short

Pydantic Logfire is an observability platform from the team behind Pydantic Validation. It sits in the Observability & LLMOps category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed MIT. To get started: install the SDK.

## Overview

Pydantic Logfire is an observability platform from the team behind Pydantic Validation. Its open-source SDK instruments your Python application and sends traces, metrics, and logs to a dashboard where you can see how your code runs, including the LLM calls, agent runs, and tool invocations in an AI app.

It is built as an opinionated wrapper around OpenTelemetry, so it works with existing OTel tooling and instrumentation for many common Python packages. You query the collected data using standard SQL, which means BI tools and ordinary database libraries can read it too.

It fits the LLM observability category by giving developers a single place to inspect request latency, token use, and the flow of data through Pydantic models, while staying useful for general Python services like FastAPI apps and database queries.

## What it does

- Built on OpenTelemetry with full support for traces, metrics, and logs, so you can reuse existing OTel instrumentation
- Query your telemetry with standard SQL, usable from BI tools and database libraries
- Manual tracing API with spans and structured log calls (logfire.info, logfire.span, logfire.debug)
- One-line integrations for popular packages, including instrument_fastapi for FastAPI apps
- Pydantic integration that shows the data flowing through your validation models plus built-in validation analytics
- Open-source SDKs for Python, TypeScript, and Rust that can export to any OTel-compatible backend

## Getting started

Install the SDK, authenticate the CLI, then add either manual tracing or a one-line integration to your app.

1. Install the SDK

   Install the logfire package from PyPI.

```bash
pip install logfire
```

2. Authenticate

   Run the auth command to connect the SDK to your Logfire account.

```bash
logfire auth
```

3. Add manual tracing

   Call configure() once, then log messages and wrap work in spans.

```python
import logfire

logfire.configure()
logfire.info('Hello, {name}!', name='world')

with logfire.span('Asking the user their {question}', question='age'):
    user_input = input('How old are you? ')
```

4. Or integrate a framework

   Skip manual calls and instrument a supported package, such as FastAPI, with one line.

```python
from fastapi import FastAPI
import logfire

app = FastAPI()

logfire.configure()
logfire.instrument_fastapi(app)
```

## When to use it

- Trace LLM calls and agent runs in a Python AI app to inspect latency, token use, and tool invocations
- Instrument a FastAPI service to see request spans, database queries, and errors in one dashboard
- Debug Pydantic models by watching the data that flows through them and reviewing validation analytics
- Send OpenTelemetry traces, metrics, and logs to Logfire or any OTel-compatible backend and query them with SQL
