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

# LangChain

> Drop-in abliteration.ai with LangChain and LangGraph via the standard ChatOpenAI class.

**To use LangChain with abliteration.ai**, instantiate `ChatOpenAI` with `base_url="https://api.abliteration.ai/v1"` and your `ak_...` key. The same class works for LangGraph.

## Install

```sh theme={"system"}
pip install langchain langchain-openai
```

## Usage

```python theme={"system"}
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="abliterated-model",
    base_url="https://api.abliteration.ai/v1",
    api_key=os.environ["ABLIT_KEY"],
)

print(llm.invoke("Hello").content)
```

## Streaming

```python theme={"system"}
for chunk in llm.stream("Write a haiku"):
    print(chunk.content, end="", flush=True)
```

## Tool calling

```python theme={"system"}
from langchain_core.tools import tool

@tool
def get_weather(city: str) -> str:
    """Get the weather for a city."""
    return f"Sunny in {city}"

llm_with_tools = llm.bind_tools([get_weather])
```

See [tool calling](/capabilities/tool-calling) for the underlying API.

## LangGraph

Pass the same `ChatOpenAI` instance into any LangGraph node. No other configuration needed.
