LiveKit docs › Models › LLM › Additional models › LangChain

---

# LangChain integration guide

> How to use LangGraph workflows and LangChain agents with LiveKit.

Available in:
- [ ] Node.js
- [x] Python

## Overview

This plugin allows you to use LangGraph and other graph-based LangChain agents as an LLM provider for your voice agents.

### Installation

Install the LiveKit LangChain plugin from PyPI:

```shell
uv add "livekit-agents[langchain]~=1.5"

```

### Usage

To use LangGraph workflows within an `AgentSession`, wrap them with the `LLMAdapter`. For example, you can use this LLM in the [Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md).

```python
from langgraph.graph import StateGraph
from livekit.agents import AgentSession, Agent
from livekit.plugins import langchain

# Define your LangGraph workflow
def create_workflow():
    workflow = StateGraph(...)
    # Add your nodes and edges
    return workflow.compile()

# Use the workflow as an LLM
session = AgentSession(
    llm=langchain.LLMAdapter(
        graph=create_workflow()
    ),
    # ... stt, tts, vad, turn_handling, etc.
)

```

The `LLMAdapter` automatically converts the LiveKit chat context to [LangChain messages](https://python.langchain.com/docs/concepts/messages/#langchain-messages). The mapping is as follows:

- `system` and `developer` messages to `SystemMessage`
- `user` messages to `HumanMessage`
- `assistant` messages to `AIMessage`

### Parameters

This section describes the available parameters for the `LLMAdapter`. See the [plugin reference](https://docs.livekit.io/reference/python/livekit/plugins/langchain/index.html.md#livekit.plugins.langchain.LLMAdapter) for a complete list of all available parameters.

- **`graph`** _(PregelProtocol)_: The LangGraph workflow to use as an LLM. Must be a locally compiled graph. To learn more, see [Graph Definitions](https://langchain-ai.github.io/langgraph/reference/graphs/).

- **`config`** _(RunnableConfig | None)_ (optional) - Default: `None`: Configuration options for the LangGraph workflow execution. This can include runtime configuration, callbacks, and other LangGraph-specific options. To learn more, see [RunnableConfig](https://python.langchain.com/docs/concepts/runnables/#runnableconfig).

## Supported LangChain agent types

The LiveKit LangChain plugin supports [LangGraph](https://langchain-ai.github.io/langgraph/reference/graphs/) and other graph-based LangChain agents:

- [Agents](https://docs.langchain.com/oss/python/langchain/agents) built with `create_agent`.
- [Deep agents](https://docs.langchain.com/oss/python/deepagents/overview) built with `create_deep_agent`.

All of these return a `CompiledStateGraph` (Pregel-compatible), which the `LLMAdapter` accepts directly.

To add voice to an existing LangChain agent, pass the compiled graph to `LLMAdapter` and use it as the `Agent`'s LLM: `llm=langchain.LLMAdapter(graph=your_compiled_graph)`.

The plugin does not support non-graph patterns such as plain LCEL chains (`prompt | llm`) or bare chat models.

For complete examples including LangGraph, LangChain agents, and deep agents, see the [recipes page](https://docs.livekit.io/reference/recipes.md?tag=langchain).

## Latency

This plugin uses LangGraph's streaming mode to minimize time-to-first-token as much as possible, but take care when porting LangChain workflows that were not originally designed for voice use cases. For more information on handling long-running operations and providing a better user experience, see the [user feedback documentation](https://docs.livekit.io/agents/logic/external-data.md#user-feedback).

## Additional resources

The following resources provide more information about using LangChain with LiveKit Agents.

- **[Python package](https://pypi.org/project/livekit-plugins-langchain/)**: The `livekit-plugins-langchain` package on PyPI.

- **[Plugin reference](https://docs.livekit.io/reference/python/livekit/plugins/langchain/index.html.md#livekit.plugins.langchain.LLMAdapter)**: Reference for the LangChain LLM adapter.

- **[GitHub repo](https://github.com/livekit/agents/tree/main/livekit-plugins/livekit-plugins-langchain)**: View the source or contribute to the LiveKit LangChain plugin.

- **[LangChain docs](https://python.langchain.com/docs/)**: LangChain documentation and tutorials.

- **[LangGraph docs](https://python.langchain.com/docs/langgraph)**: LangGraph documentation for building stateful workflows.

- **[Example apps](https://docs.livekit.io/reference/recipes.md?tag=langchain)**: Examples showing LangChain integration with LiveKit.

---

This document was rendered at 2026-06-07T11:35:39.568Z.
For the latest version of this document, see [https://docs.livekit.io/agents/models/llm/langchain.md](https://docs.livekit.io/agents/models/llm/langchain.md).

To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).