Python SDK

Quick Start

Get started with the Infralo Python SDK to trace and monitor your agentic workflows.

The Infralo Python SDK provides automatic and manual tracing for LLM applications and agentic frameworks. It tracks latency, prompts, outputs, costs, and parent-child execution hierarchies.

How It Works: Gateway vs. SDK

Infralo uses a hybrid approach to provide end-to-end observability with minimal overhead:

  • Automatic Gateway Tracing (LLMs & Runtime Modules): All LLM requests, completions, token usage, latency, and proxy-level modules (such as PII redaction or safety guards) are tracked automatically at the network layer when you configure the Infralo gateway as your client's base_url. No SDK code is required for this.
  • Python SDK (Tool Calls & Local Logic): Since tools (e.g. database queries, custom API calls) run locally within your Python runtime, they are invisible to the gateway. The Infralo Python SDK bridges this gap by instrumenting local tool executions, input/output payloads, and exceptions, linking them back to the active parent LLM trace.

Installation

Install the core SDK using pip or your favorite dependency manager:

pip install infralo

Installation Extras

Infralo offers optional extras for popular agent frameworks. Installing these will pull in the necessary framework-specific dependencies:

FrameworkExtraCommand
Agno (formerly Phidata)[agno]pip install infralo[agno]
LangGraph / LangChain[langgraph]pip install infralo[langgraph]
CrewAI[crewai]pip install infralo[crewai]
Google ADK[google-adk]pip install infralo[google-adk]

Configuration

You can configure the SDK using environment variables or by passing options directly to the client at initialization.

Environment Variables

Set the following environment variables in your deployment or .env file:

# Your Infralo API key (required)
INFRALO_API_KEY="vk_your_api_key_here"

# The Infralo gateway endpoint (optional, defaults to https://api.infralo.com)
INFRALO_ENDPOINT="http://localhost:8000"

Initialization

Initialize the Infralo client in your application:

from infralo import Infralo

infralo = Infralo(
    api_key="vk_your_api_key_here",    # Or loads from INFRALO_API_KEY
    endpoint="http://localhost:8000",   # Or loads from INFRALO_ENDPOINT
    flush_interval=1.0                  # Flush interval in seconds for background export
)

The client starts a background daemon thread that manages a thread-safe queue to export spans asynchronously. This ensures that tracing never blocks or adds latency to your user-facing request flows.

On this page