Logfire

raw JSON →
4.30.0 verified Tue May 12 auth: no python install: verified quickstart: stale

Observability platform from Pydantic — structured logging, tracing, and metrics built on OpenTelemetry. Current version is 4.30.0. Must call logfire.configure() before any instrumentation or spans. Requires LOGFIRE_TOKEN env var for cloud backend. The old pydantic-logfire package is a deprecated stub — use logfire directly. Pricing changed January 2026.

pip install logfire
error ModuleNotFoundError: No module named 'opentelemetry'
cause The 'logfire' library relies on OpenTelemetry components, and this error indicates that the necessary 'opentelemetry-sdk' package or its dependencies are not installed in the environment.
fix
Install the OpenTelemetry SDK: pip install opentelemetry-sdk or ensure a fresh logfire installation handles all its dependencies correctly.
error ValueError: LOGFIRE_TOKEN environment variable must be provided.
cause The Logfire SDK requires an authentication token to connect to the Logfire platform, which can be provided via the `LOGFIRE_TOKEN` environment variable or directly in `logfire.configure()`.
fix
Set the LOGFIRE_TOKEN environment variable (e.g., export LOGFIRE_TOKEN='your_token_here') or pass the token explicitly when configuring Logfire: logfire.configure(token='your_token_here').
error ModuleNotFoundError: No module named 'pydantic_logfire'
cause Developers might mistakenly try to import from the deprecated `pydantic-logfire` package instead of the current `logfire` package.
fix
Ensure you have installed the logfire package (not pydantic-logfire) and update your import statements to import logfire.
error ModuleNotFoundError: No module named 'pytest'
cause In some older versions of `logfire` (e.g., 0.50), `pytest` was an unexpected transitive dependency, particularly if `logfire.testing` was imported indirectly.
fix
Install pytest (pip install pytest) or upgrade logfire to a newer version where this dependency issue may have been resolved, especially if you are not directly using logfire.testing.
breaking logfire.configure() must be called before any spans, logs, or instrument_*() calls. Omitting it causes all telemetry to be silently dropped — no error is raised.
fix Call logfire.configure() at application startup, before importing or initializing any instrumented libraries. For FastAPI: call it before app = FastAPI().
breaking instrument_httpx() parameters changed: capture_request_json_body, capture_request_text_body, capture_request_form_data, and capture_response_json_body were removed and replaced by capture_request_body and capture_response_body.
fix Replace: logfire.instrument_httpx(capture_request_json_body=True) with logfire.instrument_httpx(capture_request_body=True, capture_response_body=True)
breaking install_auto_tracing() requires explicit modules parameter — there is no default. Calling it without modules raises TypeError.
fix Always specify modules: logfire.install_auto_tracing(modules=['myapp', 'myapp.services'])
gotcha pydantic-logfire on PyPI is a deprecated stub package that just depends on logfire. Use pip install logfire directly.
fix pip install logfire. Remove pydantic-logfire from requirements. import logfire not from pydantic_logfire import ...
gotcha Logfire pricing changed January 2026. Free Personal plan now limited to 1 seat and 3 projects. Teams exceeding these limits needed to upgrade by February 1, 2026 or be auto-upgraded.
fix Check current plan at logfire.pydantic.dev. Team plan ($49/mo) for 5 seats/5 projects. Growth plan ($249/mo) for unlimited.
breaking logfire.configure() raises LogfireConfigError if LOGFIRE_TOKEN is missing or invalid, or `logfire auth` has not been run, preventing cloud export and application startup. It does not silently default to local console output.
fix Set LOGFIRE_TOKEN environment variable in production, or run `logfire auth` to authenticate. Verify export is working: logfire.configure() logs the dashboard URL if the token is valid.
pip install logfire[fastapi]
pip install logfire[httpx,requests,sqlalchemy,asyncpg]
pip install pydantic-logfire
python os / libc variant status wheel install import disk
3.10 alpine (musl) logfire - - 1.56s 45.7M
3.10 alpine (musl) fastapi - - 1.59s 46.2M
3.10 alpine (musl) httpx,requests,sqlalchemy,asyncpg - - 1.60s 46.2M
3.10 alpine (musl) pydantic-logfire - - - -
3.10 slim (glibc) logfire - - 1.04s 47M
3.10 slim (glibc) fastapi - - 1.03s 47M
3.10 slim (glibc) httpx,requests,sqlalchemy,asyncpg - - 1.06s 47M
3.10 slim (glibc) pydantic-logfire - - - -
3.11 alpine (musl) logfire - - 2.26s 50.3M
3.11 alpine (musl) fastapi - - 2.35s 50.9M
3.11 alpine (musl) httpx,requests,sqlalchemy,asyncpg - - 2.38s 50.9M
3.11 alpine (musl) pydantic-logfire - - - -
3.11 slim (glibc) logfire - - 1.45s 51M
3.11 slim (glibc) fastapi - - 1.46s 52M
3.11 slim (glibc) httpx,requests,sqlalchemy,asyncpg - - 1.54s 52M
3.11 slim (glibc) pydantic-logfire - - - -
3.12 alpine (musl) logfire - - 2.21s 41.6M
3.12 alpine (musl) fastapi - - 2.24s 42.2M
3.12 alpine (musl) httpx,requests,sqlalchemy,asyncpg - - 2.35s 42.2M
3.12 alpine (musl) pydantic-logfire - - - -
3.12 slim (glibc) logfire - - 1.75s 43M
3.12 slim (glibc) fastapi - - 1.84s 43M
3.12 slim (glibc) httpx,requests,sqlalchemy,asyncpg - - 1.83s 43M
3.12 slim (glibc) pydantic-logfire - - - -
3.13 alpine (musl) logfire - - 2.09s 41.3M
3.13 alpine (musl) fastapi - - 2.15s 41.9M
3.13 alpine (musl) httpx,requests,sqlalchemy,asyncpg - - 2.31s 41.9M
3.13 alpine (musl) pydantic-logfire - - - -
3.13 slim (glibc) logfire - - 1.71s 42M
3.13 slim (glibc) fastapi - - 1.70s 43M
3.13 slim (glibc) httpx,requests,sqlalchemy,asyncpg - - 1.75s 43M
3.13 slim (glibc) pydantic-logfire - - - -
3.9 alpine (musl) logfire - - 1.42s 44.7M
3.9 alpine (musl) fastapi - - 1.50s 45.2M
3.9 alpine (musl) httpx,requests,sqlalchemy,asyncpg - - 1.42s 45.2M
3.9 alpine (musl) pydantic-logfire - - - -
3.9 slim (glibc) logfire - - 1.17s 46M
3.9 slim (glibc) fastapi - - 1.14s 46M
3.9 slim (glibc) httpx,requests,sqlalchemy,asyncpg - - 1.21s 46M
3.9 slim (glibc) pydantic-logfire - - - -

Always call logfire.configure() first. LOGFIRE_TOKEN from env. Free tier: 1 seat, 3 projects.

import logfire
import os

# Set env var: export LOGFIRE_TOKEN='your-token'
# Or pass directly (not recommended for production):
logfire.configure(
    token=os.environ.get('LOGFIRE_TOKEN'),
    service_name='my-service',
    environment='production'
)

# Structured log with attributes
logfire.info('Processing request', user_id=42, endpoint='/api/data')
logfire.warning('Rate limit approaching', limit=100, current=95)
logfire.error('Database error', error_type='ConnectionTimeout', db='postgres')

# Span (traces an operation)
with logfire.span('Fetch user data {user_id}', user_id=42):
    # Code here is traced
    data = fetch_user(42)
    logfire.info('Fetched {record_count} records', record_count=len(data))

# FastAPI integration
from fastapi import FastAPI
app = FastAPI()
logfire.instrument_fastapi(app)  # auto-traces all routes