服务端 UI 与后端闭源,自托管需购买企业许可;logfire.configure() 不会引导登录,需先跑 auth 和 init 保存写 token;uvx 命令依赖 uv,未安装 uv 需先装
logfire
pydanticMIT活跃维护面向生产环境 LLM 与 Agent 系统的可观测平台,基于 OpenTelemetry 采集日志、指标和调用链,支持评估与调试。
AI observability platform for production LLM and agent systems.
pip install logfire
uvx logfire-cli auth
uvx logfire-cli initREADME 未说明,纯 Python SDK 无 GPU 要求
Pydantic 团队出品的 Python 可观测性 SDK,基于 OpenTelemetry 追踪 LLM 与 Agent 系统
面向生产环境 LLM 与 Agent 系统的可观测平台,基于 OpenTelemetry 采集日志、指标和调用链,支持评估与调试。
核心能力
- 用 logfire.span 和 logfire.info 手动埋点追踪
- 一行 instrument_fastapi 自动插桩 FastAPI 等流行包
- 基于 OpenTelemetry 封装,可导出到任意 OTel 后端
- 用标准 SQL 查询追踪数据,兼容现有 BI 工具
- 内置 Pydantic 模型校验数据分析
容易踩的坑
- v5.5.0最新正式版2026-11-07 · 2026-11-07 00:10 UTC
- Drop all incoming context when distributed tracing is disabled by @dmontagu in #2679
- Carry variable overrides and targeting context into thread pools by @dmontagu in #2680
- Name the setting when LOGFIRE_TRACE_SAMPLE_RATE is not a number by @chrikrah in #2685
- Record audio responses and legacy function calls from OpenAI chat completions by @pcbeingused333 in #2636
- Avoid duplicate console output from Loguru by @imp-joshi in #2690
- Save a read token on Windows, where os.fchmod does not exist by @PRINCE2-AI in #2696
- Record the explanation of an Anthropic refusal as output text by @pcbeingused333 in #2638
- Record custom tool calls from the OpenAI Responses API by @michaelkillgta in #2694
- Scrub AWS security tokens (x-amz-security-token, aws_security_token) by default by @hsusul in #2692
- Let a span status set by the exception callback stand by @pedro-teixeira in #2707
- Record legacy function calls in OpenAI chat completion input messages by @chrikrah in #2711
- Return
Logfireinstance fromlogfire-apiconfigure()when SDK is not installed by @PatrickRibbsaeter in #2716 - fix(datasets): serialize dictionary-valued case fields by @shuaiyafei in #2713
- Convert Anthropic SDK content blocks sent back as input messages by @jaeminbird in #2718
- Keep streamed LLM responses iterable when recording them fails by @jaeminbird in #2721
- Skip empty items in comma-separated Pydantic plugin include/exclude settings by @Fahmid-Arman in #2720
- Fall back to OpenTelemetry instrumentors in logfire run by @mekanbaymyradov in #2609
- Breaking Change: Require project credentials before SDK configuration by @strawgate in #2683
- Connect agent sandboxes over gRPC with pydantic-monty 1.5.0 by @dmontagu in #2737
- Make SpanLevel compare equal to 'warning' by @Fahmid-Arman in #2732
- Don't crash the console exporter on attributes that format to an empty string by @Fahmid-Arman in #2731
- Add configure(fleet=...) to manage the SDK from Logfire Fleet by @strawgate in #2736
- Add actionable Agent Sandboxes error hints by @dmontagu in #2739
- Send telemetry with the API key when no write token is configured by @dmontagu in #2743
New Contributors
- @pierrebrunelle made their first contribution in #2644
- @PRINCE2-AI made their first contribution in #2696
- @michaelkillgta made their first contribution in #2694
- @hsusul made their first contribution in #2692
- @pedro-teixeira made their first contribution in #2707
- @PatrickRibbsaeter made their first contribution in #2716
- @shuaiyafei mad
- v5.4.02026-10-26 · 2026-10-26 15:07 UTC
查看更新说明
logfire.agent_sandboxes()by @samuelcolvin in #2658 and #2672- fix(sdk): serialize all pathlib.Path variants as plain strings by @RichardoMrMu in #2669
- Format an empty set as set() in the console exporter by @chrikrah in #2671
- Keep binary attributes out of the secret scrubber by @Eapp1e in #2668
- Keep recording exceptions whose
__str__raises by @Eapp1e in #2667 - Print generator attributes as their repr in the console exporter by @CyberNativeAI in #2657
- Record OpenAI cache write tokens on spans by @pcbeingused333 in #2637
- Keep non-string messages from breaking exporters by @oxura in #2655
- Count only top-level CTE names in SQL summaries by @gokay-ai in #2652
- Log dataclass types as their repr, not their default field values by @chrikrah in #2649
- Record max_completion_tokens as the requested max tokens on OpenAI chat spans by @pcbeingused333 in #2646
- Record custom tool calls from OpenAI chat completions by @pcbeingused333 in #2647
- Convert Anthropic document and file-backed image input blocks to semconv parts by @pcbeingused333 in #2645
- Harden remote strings in log messages by @dmontagu in #2654
- Remove the duplicated tool call from message content by @RachelWanggg in #2442
- Record errors raised during LLM stream consumption by @deepanshupal in #2491
- fix(formatter): treat unbalanced braces as a formatting failure by @Eapp1e in #2675
- v5.3.02026-10-23 · 2026-10-23 10:37 UTC
查看更新说明
- Automatically instrument FastAPI with logfire run by @alexmojaki in #2606
- Automatically instrument Starlette apps with logfire run by @alexmojaki in #2596
- Automatically instrument Flask apps with logfire run by @alexmojaki in #2594
- Raise when SQLAlchemy instrumentation is skipped by @maaz-bin-hassan in #2602
- Add
pending_spansoption by @adriangb in #2580 - Honor exception callback levels when setting span status by @alexmojaki in #2592
- Scrub passphrase, signing_key and hmac_key by default by @sridhar-3009 in #2593
- Scrub OAuth-style token names (access_token, refresh_token, id_token, bearer_token) by default by @sridhar-3009 in #2551
- Treat
logfire.tagspassed through structlog as log tags by @Thanatos9404 in #2598 - Treat
logfire.tagspassed through logging and loguru as log tags by @Thanatos9404 in #2550 - Suppress native FastAPI telemetry by @alexmojaki in #2629
- Require certifi 2026.10.19 to distrust compromised eMudhra chains by @alexmojaki in #2640
- Format range attributes in the console exporter by @fhgffy in #2534
- Format bytearray attributes in the console exporter by @sebxt in #2591
- Fix DataFrame labels below pandas display limits by @fallintoplace in #2509
- Handle zero-dimensional NumPy arrays in console formatting by @dailyun in #2621
- Clarify CLI account switching and logout scope by @alexmojaki in #2552
- Include the dataset in
url_from_evallinks when the report has one by @jirikuncar in #2566 - Keep the parent context for spans started while instrumentation is suppressed by @adtyavrdhn in #2570
- Record response id and finish reasons for streamed OpenAI and Anthropic calls by @flcrom in #2545
- Record the response model for streamed OpenAI and Anthropic calls by @darshjoshi in #2558
- Record OpenAI refusals in gen_ai.output.messages by @pcbeingused333 in #2582
- Record streamed OpenAI Responses that end as incomplete or failed by @SergeevDmitry in #2565
- Record response id and finish reason on Claude Agent SDK chat spans by @pcbeingused333 in #2620
- Record cache token usage on Anthropic spans by @pcbeingused333 in #2616
- Record cached prompt tokens on OpenAI spans by @pcbeingused333 in #2617
- Record why a Claude Agent SDK run ended in error by @pcbeingused333 in #2622
- Record finish reasons for OpenAI Responses API calls by @pcbeingused333 in #2619
- Record response id and finish reasons on OpenAI Agents Responses spans by @pcbeingused333 in #2632
- Record Responses API refusals as text in gen_ai.output.messages by @pcbeingused333 in [#2618](https://github
- v5.2.02026-10-13 · 2026-10-13 17:26 UTC
查看更新说明
- Support OpenTelemetry 1.45 by @alexmojaki in #2536
- Allow console attributes without verbose output by @rudrakshkarpe in #2488
- Add
compressionoption and zstd experimental support by @Viicos in #2535 - Update FastAPI instrumentation to prevent duplicate telemetry by @alexmojaki in #2524
- Update Anthropic instrumentation by @alexmojaki in #2521
- Keep span message in sync with the name after
update_nameby @darshjoshi in #2514 - Expose RFC 9457 problem details on query client errors by @adriangb in #2511
- Read stable HTTP semconv attributes when building HTTP span messages by @samuelcolvin in #2516
- Update Google GenAI instrumentation by @alexmojaki in #2523
- Convert span attribute ints below the int64 minimum to strings by @JoeyTan21 in #2502
- Respect repr=False when logging attrs fields by @harbinresearcher in #2518
- Default the CLI base URL to LOGFIRE_BASE_URL by @jgjoe in #2260
- Create subprocess with no console windows on windows by @marcelotrevisani in #2507
- Fix when logfire tries to access a file that has no permission by @marcelotrevisani in #2464
- fix: do not treat non-retryable DiskRetryer responses as success by @alexmojaki in #2529
- fix explicit context for logfire metrics by @alexmojaki in #2532
- Fix OTLP byte POST retries through Session.request by @SAY-5 in #2503
(These are the same changes as in v6.0.0b8, but backported to the v5 line.)
- v6.0.0b8pre-release2026-10-10 · 2026-10-10 01:01 UTC
查看更新说明
- Support OpenTelemetry 1.45 by @alexmojaki in #2536
- Allow console attributes without verbose output by @rudrakshkarpe in #2488
- Add
compressionoption and zstd experimental support by @Viicos in #2535 - Update FastAPI instrumentation to prevent duplicate telemetry by @alexmojaki in #2524
- Update Anthropic instrumentation by @alexmojaki in #2521
- Keep span message in sync with the name after
update_nameby @darshjoshi in #2514 - Expose RFC 9457 problem details on query client errors by @adriangb in #2511
- Read stable HTTP semconv attributes when building HTTP span messages by @samuelcolvin in #2516
- Update Google GenAI instrumentation by @alexmojaki in #2523
- Convert span attribute ints below the int64 minimum to strings by @JoeyTan21 in #2502
- Respect repr=False when logging attrs fields by @harbinresearcher in #2518
- Default the CLI base URL to LOGFIRE_BASE_URL by @jgjoe in #2260
- Create subprocess with no console windows on windows by @marcelotrevisani in #2507
- Fix when logfire tries to access a file that has no permission by @marcelotrevisani in #2464
- fix: do not treat non-retryable DiskRetryer responses as success by @alexmojaki in #2529
- fix explicit context for logfire metrics by @alexmojaki in #2532
- Fix OTLP byte POST retries through Session.request by @SAY-5 in #2503
- Handle project setup for accounts without organizations by @strawgate in #2469
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Pydantic Logfire: Know more. Build faster.
From the team behind Pydantic Validation, Pydantic Logfire is an observability platform built on the same belief as our open-source library: that the most powerful tools can be easy to use.
What sets Logfire apart:
- Simple and Powerful: Logfire's dashboard is simple relative to the power it provides, ensuring your entire engineering team will actually use it.
- Python-centric Insights: From rich display of Python objects, to event-loop telemetry, to profiling Python code and database queries, Logfire gives you unparalleled visibility into your Python application's behavior.
- SQL: Query your data using standard SQL: all the control and (for many) nothing new to learn. Using SQL also means you can query your data with existing BI tools and database querying libraries.
- OpenTelemetry: Logfire is an opinionated wrapper around OpenTelemetry, allowing you to leverage existing tooling, infrastructure, and instrumentation for many common Python packages, and enabling support for virtually any language. We offer full support for all OpenTelemetry signals (traces, metrics and logs).
- Pydantic Integration: Understand the data flowing through your Pydantic Validation models and get built-in analytics on validations.
See the documentation for more information.
Evaluating observability tools? See what Logfire does for LLM apps and agents, evals in production, and how it compares to alternatives.
Feel free to report issues and ask any questions about Logfire in this repository!
This repo contains the Python SDK for logfire and documentation; the server application for recording and displaying data is closed source.
Using Logfire
This is a very brief overview of how to use Logfire, the documentation has much more detail.
Install
pip install logfire
This installs both the Python SDK and the Logfire CLI. To install only the SDK, use
pip install logfire-sdk; the import remains import logfire.
Connect your project
uvx logfire-cli auth
uvx logfire-cli init
Run these commands from your application's directory. uvx is part of
uv. Authentication signs you in; init selects or
creates a project and saves its write token locally for the SDK. Existing project
credentials continue to work. logfire.configure() does not prompt for setup.
Manual tracing
Here's a simple manual tracing (aka logging) example:
from datetime import date
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 [YYYY-mm-dd]? ')
dob = date.fromisoformat(user_input)
logfire.debug('{dob=} {age=!r}', dob=dob, age=date.today() - dob)
Integration
Or you can also avoid manual instrumentation and instead integrate with lots of popular packages, here's an example of integrating with FastAPI:
from fastapi import FastAPI
from pydantic import BaseModel
import logfire
app = FastAPI()
logfire.configure()
logfire.instrument_fastapi(app)
# next, instrument your database connector, http library etc. and add the logging handler
class User(BaseModel):
name: str
country_code: str
@app.post('/')
async def add_user(user: User):
# we would store the user here
return {'message': f'{user.name} added'}
Logfire gives you a view into how your code is running like this:

Contributing
We'd love anyone interested to contribute to the Logfire SDK and documentation, see the contributing guide.
Reporting a Security Vulnerability
See our security policy.
Logfire Open-Source and Closed-Source Boundaries
The Logfire SDKs (we also have them for TypeScript and Rust) are open source, and you can use them to export data to any OTel-compatible backend.
The Logfire platform (the UI and backend) is closed source. You can self-host it by purchasing an enterprise license.