Getting started with Pydantic Logfire
Logfire is Pydantic’s end-to-end AI engineering platform. It shows you what your agents, services, applications, and hosts are actually doing: every LLM call, request, and query, and how long each one took. Built on OpenTelemetry (OTel), the open standard for traces, metrics, and logs, it spans your whole stack, from AI agents to the databases and servers behind them.
New here? Create a free account, then pick a starting point below, or follow a guided path for your role.
Set up Pydantic Logfire in this project so it sends traces to Logfire. Follow the guide at https://pydantic.dev/docs/logfire/get-started/first-trace/.
1. Install the Logfire SDK for this project's language and initialize it at startup the way the guide describes for that language (for Python and JavaScript that is logfire.configure(); other languages may use OpenTelemetry), then instrument its web framework plus any LLM and HTTP clients. Don't refactor unrelated code.
2. Authenticate. If a `LOGFIRE_TOKEN` environment variable is already set, use it as-is. Otherwise, for a local Python project, install Logfire with the project's dependency manager (for example `uv add logfire`, `poetry add logfire`, or `pip install logfire`), then run `logfire auth` (or `uvx logfire auth`): this opens a browser where you sign in or create a free Logfire account (no credit card required) and a project, then links this machine. For another language, a non-interactive shell, or a deployment, ask me for a write token (the credential that lets an app send data to Logfire) from Project > Settings > Write tokens and set it as the `LOGFIRE_TOKEN` environment variable. Keep any token out of your replies: `logfire auth` saves credentials to `~/.logfire` in your home directory (outside the repo), and if you create or receive a token, put it in a gitignored `.env` rather than printing it; never commit it.
3. Run the app so it sends a trace, then give me the Logfire Live view link on its own line and in bold so I can open it and confirm the trace arrived.
4. Once the trace is arriving, offer a few next steps and do the ones I want: run `logfire inspect` to find other dependencies Logfire can instrument and add the relevant ones; set up the Logfire MCP (Model Context Protocol) server so you can query my Logfire data going forward (https://pydantic.dev/docs/logfire/guides/mcp-server/, it logs in through the browser); or set up alerts or evals.
-
Install the SDK and watch a trace arrive in the Live view, in about 5 minutes.
-
Monitor hosts, Kubernetes, and cloud infrastructure alongside your application.
-
Understand agent observability
See how one trace connects an agent’s model calls, tools, and the services behind them.
-
See traces and logs stream in, and drill into any span to read its full detail.
-
Slice your data with the SQL you already know, not a proprietary query language.
-
Chart what matters and get notified in Slack when it changes.
-
Run evaluations, manage prompts, and route models through the AI gateway.
-
Browse the metrics you’re sending and break any of them down by dimension, no SQL required.
-
FastAPI, Django, SQLAlchemy, HTTPX, and 40+ more, each with one line of setup.
Core concepts explains spans, traces, and logs, and how to read them in Logfire. Read why Logfire exists.