Integrations: instrument the libraries you already use
Instrument the libraries you already use (your web framework, database driver, HTTP client, LLM SDK) and their work shows up in Logfire automatically, as spans (one unit of work: a single operation, with a name, a start, and a duration) nested inside the request that triggered them. You don’t add logging by hand; you turn on the integration once and get the traces (the full journey of one request, made of nested spans) for free.
Most integrations are a single logfire.instrument_<package>() call, made once after logfire.configure(). For example, to instrument FastAPI and HTTPX:
from fastapi import FastAPI
import logfire
app = FastAPI()
logfire.configure()
logfire.instrument_fastapi(app)
logfire.instrument_httpx()
# ... your application code here ...
Some platforms send OpenTelemetry data directly, without installing the Logfire SDK. See the setup guides for no-code platforms and OpenRouter Broadcast.
If a package you are using is not listed in this documentation, please let us know on our Slack!
Logfire has documented integrations with many technologies, including:
- LLM Clients and AI Frameworks: Pydantic AI, OpenAI, Anthropic, OpenRouter, LangChain, LlamaIndex, Mirascope, LiteLLM, Magentic (grouped under AI)
- AI Agent Frameworks (Python, TypeScript, Go, Rust, .NET): CrewAI, AutoGen, Google ADK, smolagents, Strands, Agno, Haystack, Semantic Kernel, Vercel AI SDK, Mastra, Rig, and more. See Agent Frameworks.
- No-code AI and workflow platforms: Dify, Flowise, Goose, Langflow, LobeChat, n8n, and Open WebUI (setup guides)
- Web Frameworks: FastAPI, Django, Flask, Starlette, AIOHTTP, ASGI, WSGI
- Database Clients: Psycopg, SQLAlchemy, Asyncpg, PyMongo, MySQL, SQLite3, Redis, BigQuery, Elasticsearch
- HTTP Clients: HTTPX, HTTPX2, Requests, AIOHTTP
- Task Queues and Schedulers: Airflow, FastStream, Celery
- Logging Libraries: Standard Library Logging, Loguru, Structlog
- Testing: Pytest
- and more, such as Stripe, AWS Lambda, and system metrics.
The below table lists these integrations and any corresponding logfire.instrument_<package>() calls:
| Package | Type | Logfire Instrument Call / Notes |
|---|---|---|
| Pydantic Validation | Data Validation | logfire.instrument_pydantic() |
| Pydantic AI | AI | logfire.instrument_pydantic_ai() |
| AIOHTTP | HTTP Client | logfire.instrument_aiohttp_client(), logfire.instrument_aiohttp_server() |
| Airflow | Task Scheduler | N/A (built in, config needed) |
| Anthropic | AI | logfire.instrument_anthropic() |
| Agno | AI Agent Framework | N/A (OpenInference instrumentor) |
| AutoGen | AI Agent Framework | logfire.instrument_openai() plus native OpenTelemetry |
| CrewAI | AI Agent Framework | N/A (OpenInference instrumentor) |
| Google ADK | AI Agent Framework | N/A (native OpenTelemetry support) |
| Haystack | AI Framework | N/A (native OpenTelemetry via opentelemetry-haystack) |
| Instructor | AI | logfire.instrument_openai() |
| LangGraph | AI Agent Framework | N/A (built-in OpenTelemetry support) |
| Letta | AI Agent Framework | N/A (OpenTelemetry Collector) |
| Semantic Kernel | AI Agent Framework | N/A (native OpenTelemetry support) |
| smolagents | AI Agent Framework | N/A (OpenInference instrumentor) |
| Strands Agents | AI Agent Framework | N/A (native OpenTelemetry support) |
| ASGI | Web Framework Interface | logfire.instrument_asgi() |
| AWS Lambda | Cloud Function | logfire.instrument_aws_lambda() |
| Asyncpg | Database | logfire.instrument_asyncpg() |
| BigQuery | Database | N/A (built in, no config needed) |
| Celery | Task Queue | logfire.instrument_celery() |
| Django | Web Framework | logfire.instrument_django() |
| Elasticsearch | Database | N/A (native OpenTelemetry support in the client) |
| FastAPI | Web Framework | logfire.instrument_fastapi() |
| FastStream | Task Queue | N/A (built in, config needed) |
| Flask | Web Framework | logfire.instrument_flask() |
| HTTPX | HTTP Client | logfire.instrument_httpx() |
| HTTPX2 | HTTP Client | logfire.instrument_httpx() |
| LangChain | AI Framework | N/A (built-in OpenTelemetry support) |
| LlamaIndex | AI Framework | N/A (requires LlamaIndex OpenTelemetry package) |
| LiteLLM | AI Gateway | N/A (requires LiteLLM callback setup) |
| Loguru | Logging | See documentation |
| Magentic | AI Framework | N/A (built-in Logfire support) |
| Mirascope | AI Framework | N/A (use mirascope @with_logfire decorator) |
| MySQL | Database | logfire.instrument_mysql() |
| OpenAI | AI | logfire.instrument_openai() |
| Psycopg | Database | logfire.instrument_psycopg() |
| Pytest | Testing | N/A (built-in plugin, use pytest --logfire) |
| PyMongo | Database | logfire.instrument_pymongo() |
| Redis | Database | logfire.instrument_redis() |
| Requests | HTTP Client | logfire.instrument_requests() |
| SQLAlchemy | Database | logfire.instrument_sqlalchemy() |
| SQLite3 | Database | logfire.instrument_sqlite3() |
| Standard Library Logging | Logging | See documentation |
| Starlette | Web Framework | logfire.instrument_starlette() |
| Stripe | Payment Gateway | N/A (requires other instrumentations) |
| Structlog | Logging | See documentation |
| System Metrics | System Metrics | logfire.instrument_system_metrics() |
| WSGI | Web Framework Interface | logfire.instrument_wsgi() |
If you are using Logfire with a web application, we also recommend reviewing our Web Frameworks documentation.
Since Logfire is OpenTelemetry compatible, it can be used with any OpenTelemetry instrumentation package. You can find the list of all OpenTelemetry instrumentation packages here.
Many of the integrations documented in the previous section are based upon the OpenTelemetry instrumentation packages with first-class support built into Logfire.
If you are a maintainer of a package and would like to create an integration for Logfire, you can do it!
We’ve created a shim package called logfire-api, which can be used to integrate your package with Logfire.
The idea of logfire-api is that it doesn’t have any dependencies. It’s a very small package that matches the API of Logfire.
We created it so that you can create an integration for Logfire without having to install Logfire itself.
You can use logfire-api as a lightweight dependency of your own package.
If logfire is installed, then logfire-api will use it. If not, it will use a no-op implementation.
This way users of your package can decide whether or not they want to install logfire, and you don’t need to
check whether or not it’s installed.
Here’s how you can use logfire-api:
import logfire_api as logfire
logfire.info('Hello, Logfire!')
All the Logfire API methods are available in logfire-api.