Skip to main content
LangChain works with abliteration.ai through the standard ChatOpenAI class.

Install

pip install langchain langchain-openai

Usage

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

for chunk in llm.stream("Write a haiku"):
    print(chunk.content, end="", flush=True)

Tool calling

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 for the underlying API.

LangGraph

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