Docs

LangChain OpenAI-compatible Python integration

Use LangChain OpenAI integrations with abliteration.ai. Configure ChatOpenAI with base_url, api_key, abliterated-model, and the OpenAI-compatible chat completions endpoint.

Updated 2026-08-04

LangChain can call any OpenAI-compatible endpoint. Configure ChatOpenAI from langchain_openai with the abliteration.ai base URL and your API key.

Your chains, tools, agents, retrievers, and prompts stay the same. Only the LangChain OpenAI provider configuration changes.

This is useful for enterprise research pipelines that need less-restricted model behavior for AI red teaming, synthetic eval data, trust and safety classifier work, and ML behavior analysis.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="abliterated-model",
    base_url="https://api.abliteration.ai/v1",
    api_key="YOUR_ABLIT_KEY",
)

response = llm.invoke("Give me a one-sentence summary of Stonehenge.")
print(response.content)

LangChain OpenAI settings

Production governance

For red-team, cybersecurity, trust and safety, synthetic data, or regulated research workflows, keep LangChain orchestration separate from policy enforcement.

FAQ

Frequently asked questions.

How do I fix a 401 Unauthorized error from abliteration.ai?

Check that your API key is set and sent as a Bearer token.

How do I fix a 404 Not Found error from abliteration.ai?

Make sure the base URL ends with /v1 and you call /chat/completions.

How do I fix a 400 Bad Request error from abliteration.ai?

Verify the model id and that messages are an array of { role, content } objects.

How do I fix a 429 Rate limit error from abliteration.ai?

Back off and retry. Use the Retry-After header for pacing.