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

# LangChain

> Audit LangChain chains, agents, and tools

<Note>
  **Prefer zero setup?** Use `plog run` or `import provenlog.auto` instead. See [Auto-Instrumentation](/integrations/auto-instrumentation).
</Note>

## Setup

```python theme={null}
from provenlog.integrations.langchain import Trail

trail = Trail(agent_id="my-langchain-agent")
chain.invoke(input, config={"callbacks": [trail]})
```

## What gets captured

| Event           | Action Type    | Details                        |
| --------------- | -------------- | ------------------------------ |
| LLM call        | `LLM_CALL`     | Model name, prompt, parameters |
| LLM response    | `LLM_RESPONSE` | Generated text, token usage    |
| Tool call       | `TOOL_CALL`    | Tool name, input arguments     |
| Tool result     | `TOOL_RESULT`  | Tool output, duration          |
| Agent action    | `CUSTOM`       | Agent decisions, routing       |
| Retriever query | `TOOL_CALL`    | Retriever name, query          |

## Usage with different chain types

```python theme={null}
# Simple chain
chain = prompt | llm | parser
chain.invoke(input, config={"callbacks": [trail]})

# Agent with tools
agent = create_react_agent(llm, tools)
agent_executor = AgentExecutor(agent=agent, tools=tools)
agent_executor.invoke(input, config={"callbacks": [trail]})

# Retrieval chain
chain = retriever | prompt | llm
chain.invoke(input, config={"callbacks": [trail]})
```

## Configuration

```python theme={null}
# Simple — uses default embedded mode
trail = Trail(agent_id="my-agent")

# With explicit client for custom configuration
from provenlog import ProvenLogClient

client = ProvenLogClient("http://localhost:7600", agent_id="my-agent")
trail = Trail(client=client, agent_id="my-agent")
```
