> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/openlit/openlit/llms.txt
> Use this file to discover all available pages before exploring further.

# AI framework integrations

> Trace agent execution, tool calls, chains, and memory operations across LangChain, LlamaIndex, CrewAI, and 15+ more AI frameworks

OpenLIT instruments AI orchestration frameworks to give you end-to-end visibility into agentic workflows. Each span captures the framework operation type, inputs, outputs, and timing — so you can trace how a user request flows through chains, agents, and tool calls.

## How framework tracing works

When you call `openlit.init()`, OpenLIT patches the framework's internal execution methods. For each operation — a chain run, an agent step, a tool call, a retrieval — OpenLIT creates an OpenTelemetry span.

Setting `detailed_tracing=True` (the default) captures per-step traces for maximum observability. Set it to `False` to reduce span volume in high-throughput scenarios.

```python theme={null}
import openlit

# Detailed tracing enabled by default
openlit.init(otlp_endpoint="http://127.0.0.1:4318")

# Reduce span volume by disabling per-step traces
openlit.init(
    otlp_endpoint="http://127.0.0.1:4318",
    detailed_tracing=False
)
```

## Get started

<Steps>
  <Step title="Install OpenLIT">
    ```shell theme={null}
    pip install openlit
    ```
  </Step>

  <Step title="Install your framework">
    Install the framework package your application uses:

    ```shell theme={null}
    # LangChain
    pip install langchain

    # CrewAI
    pip install crewai

    # LlamaIndex
    pip install llama-index
    ```
  </Step>

  <Step title="Initialize OpenLIT">
    Call `openlit.init()` before any framework code runs.

    <CodeGroup>
      ```python LangChain example theme={null}
      import openlit
      from langchain_openai import ChatOpenAI
      from langchain_core.prompts import ChatPromptTemplate

      openlit.init(otlp_endpoint="http://127.0.0.1:4318")

      llm = ChatOpenAI(model="gpt-4o")
      prompt = ChatPromptTemplate.from_template("Tell me about {topic}")
      chain = prompt | llm

      result = chain.invoke({"topic": "observability"})
      print(result.content)
      ```

      ```python CrewAI example theme={null}
      import openlit
      from crewai import Agent, Task, Crew

      openlit.init(otlp_endpoint="http://127.0.0.1:4318")

      researcher = Agent(
          role="Researcher",
          goal="Research AI observability best practices",
          backstory="You are an expert in AI systems monitoring."
      )

      task = Task(
          description="Summarize the key benefits of AI observability",
          agent=researcher
      )

      crew = Crew(agents=[researcher], tasks=[task])
      result = crew.kickoff()
      print(result)
      ```
    </CodeGroup>
  </Step>
</Steps>

## Supported frameworks

| Framework         | Python                | TypeScript | Instrumentor key |
| ----------------- | --------------------- | ---------- | ---------------- |
| LangChain         | ✅ `langchain-core`    | ✅          | `langchain`      |
| LangGraph         | ✅ `langgraph`         | —          | `langgraph`      |
| LlamaIndex        | ✅ `llama-index`       | ✅          | `llama_index`    |
| CrewAI            | ✅ `crewai`            | —          | `crewai`         |
| OpenAI Agents SDK | ✅ `openai-agents`     | —          | `openai-agents`  |
| Pydantic AI       | ✅ `pydantic-ai`       | —          | `pydantic_ai`    |
| AG2 / AutoGen     | ✅ `ag2` / `pyautogen` | —          | `ag2`            |
| Haystack          | ✅ `haystack`          | —          | `haystack`       |
| Mem0              | ✅ `mem0ai`            | —          | `mem0`           |
| Browser Use       | ✅ `browser-use`       | —          | `browser-use`    |
| Letta             | ✅ `letta-client`      | —          | `letta`          |
| Crawl4AI          | ✅ `crawl4ai`          | —          | `crawl4ai`       |
| Firecrawl         | ✅ `firecrawl`         | —          | `firecrawl`      |
| Dynamiq           | ✅ `dynamiq`           | —          | `dynamiq`        |
| ControlFlow       | ✅ `controlflow`       | —          | `controlflow`    |
| SwarmZero         | ✅ `swarmzero`         | —          | `swarmzero`      |
| DSPy              | ✅ `dspy`              | —          | `dspy`           |
| Agno (Phidata)    | ✅ `agno`              | —          | `agno`           |
| GuardrailsAI      | ✅ `guardrails-ai`     | —          | `guardrails`     |

## Span attributes captured

Framework spans include attributes specific to the operation type:

| Attribute                    | Description                                                     |
| ---------------------------- | --------------------------------------------------------------- |
| `gen_ai.system`              | Framework name (e.g., `langchain`)                              |
| `gen_ai.operation.name`      | Operation type (e.g., `chain`, `agent`, `tool`)                 |
| `gen_ai.request.model`       | Underlying LLM model used                                       |
| `gen_ai.usage.input_tokens`  | Tokens consumed by the operation                                |
| `gen_ai.usage.output_tokens` | Tokens generated by the operation                               |
| `db.cost`                    | Estimated cost in USD                                           |
| `gen_ai.prompt`              | Input to the operation (when `capture_message_content=True`)    |
| `gen_ai.completion`          | Output from the operation (when `capture_message_content=True`) |

<Tip>
  Enable `detailed_tracing=True` (the default) to capture individual chain steps and agent iterations. This creates richer traces at the cost of additional span volume.
</Tip>

***

<CardGroup cols={3}>
  <Card title="LLM provider integrations" href="/sdk/integrations/llm-providers" icon="microchip-ai">
    Trace individual LLM calls with token counts, cost, and latency
  </Card>

  <Card title="Vector database integrations" href="/sdk/integrations/vector-databases" icon="database">
    Trace vector search, upsert, and index operations
  </Card>

  <Card title="Destinations" href="/sdk/destinations/overview" icon="link">
    Send telemetry to Datadog, Grafana, New Relic, and other observability stacks
  </Card>
</CardGroup>
