Skip to main content

langchain-oathbreaker

A LangChain chat model for Oathbreaker AI, a prepaid model API that serves abliterated GLM, DeepSeek and Kimi models through an OpenAI-style Chat Completions endpoint, with streaming, tool calling and reasoning.

pip install -U langchain-oathbreaker
export OATHBREAKER_API_KEY="your-api-key"
from langchain_oathbreaker import ChatOathbreaker

model = ChatOathbreaker(model="oathbreaker-glm-5.3", max_tokens=2048)
print(model.invoke("Reply with exactly: Oathbreaker connected.").content)

Create an account, add prepaid credit and create a key in your dashboard. Every request is billed per token at the rates on the pricing page.

Why not ChatOpenAI with a base URL

ChatOpenAI(base_url="https://oathbreaker.ai/v1", ...) works for a plain call. The API accepts a fixed list of request fields and refuses a request that carries any other, and LangChain adds such fields in ordinary use. This class sends what the API accepts.

Situation ChatOpenAI with a base URL ChatOathbreaker
A message has a name, as every message from a named LangGraph agent does Refused: unsupported field: name The name is left out
A chain or agent passes stop Refused: unsupported field: stop The answer is cut at the stop sequence (see below)
seed, frequency_penalty, presence_penalty or user is set Refused Left out, with a warning where it could matter
bind_tools(..., strict=True), or an agent that asks for a response format beside tools Refused: strict tools are not supported Tools are sent without strict
The model's reasoning text Dropped Kept in additional_kwargs["reasoning_content"] and sent back with tool calls, as the API asks
OPENAI_API_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID or OPENAI_CUSTOM_HEADERS is set The organization, project and custom headers are sent to Oathbreaker. A missing Oathbreaker key falls back to the OpenAI key Only OATHBREAKER_API_KEY is read, and nothing from the OpenAI settings is sent
A request fails Repeated twice by default Sent once (max_retries=0). A timeout does not show that nothing was charged
get_num_tokens_from_messages, used by trim_messages Raises NotImplementedError Returns an estimate
The request is too long for the model A generic bad-request error ContextOverflowError, which LangChain's summarization middleware recovers from
A streamed answer reaches its output limit in the middle of a tool call LangChain fills in the end of the arguments, and an agent runs the tool with what arrived IncompleteToolCallError, and the tool is not run

Models

Model Context window Max output
oathbreaker-glm-5.3 131,072 tokens 32,768
oathbreaker-glm-5.3-flash 131,072 tokens 32,768
oathbreaker-deepseek-v4.1-flash 65,536 tokens 32,768
oathbreaker-deepseek-v4.1-flash-fast 65,536 tokens 32,768
oathbreaker-kimi-k3.1-pro 524,288 tokens 24,576

These are the values GET https://oathbreaker.ai/v1/models reports, which needs no key. Input and requested output share the window, and the output budget includes reasoning. The class passes these limits to LangChain as the model's profile. A model added after this release works too; LangChain then assumes nothing about its limits.

Streaming

for chunk in model.stream("Explain abliteration in two sentences."):
    print(chunk.text, end="", flush=True)

The last chunk carries usage_metadata for the whole request. ainvoke, astream and batch work as on any LangChain chat model. The API runs at most 10 generations at once per account and starts at most 60 a minute, so give batch a limit: model.batch(prompts, config={"max_concurrency": 5}).

Tool calling

from langchain_core.tools import tool


@tool
def get_weather(city: str) -> str:
    """Get the current weather in a city."""
    return f"It is 21 degrees and sunny in {city}."


model_with_tools = model.bind_tools([get_weather])
message = model_with_tools.invoke("What is the weather in Lisbon?")
print(message.tool_calls)

The API returns tool calls and does not run your tools. It does not enforce tool schemas either, so check the arguments before you act on them; a LangChain tool validates its own. Hosted tools such as web search are not offered.

An answer that reaches its output limit while the model is still writing a tool call raises IncompleteToolCallError, streamed or not, and the call is not passed on. The API reference says never to run an incomplete tool call. Raise max_tokens, or lower reasoning_effort, because reasoning counts towards the same limit.

Agents work the same way (pip install langchain):

from langchain.agents import create_agent

agent = create_agent(model, tools=[get_weather])
state = agent.invoke({"messages": [{"role": "user", "content": "What is the weather in Lisbon?"}]})
print(state["messages"][-1].content)

Structured output

from pydantic import BaseModel, Field


class Capital(BaseModel):
    """The capital of a country."""

    country: str = Field(description="The country asked about")
    capital: str = Field(description="Its capital city")


structured = model.with_structured_output(Capital)
print(structured.invoke("What is the capital of Portugal?"))

By default the schema is bound as a tool that the model must call, and Pydantic checks the result. method="json_schema" sends the schema as response_format instead, and method="json_mode" asks for a JSON object. With those two the API passes the request on to the model and does not check the answer, so a reply that does not fit the schema raises a parsing error; pass include_raw=True to get the error back instead.

Reasoning

Every model reasons before it answers, and reasoning cannot be turned off. Set how much with reasoning_effort: "low", "high" or "max".

model = ChatOathbreaker(model="oathbreaker-glm-5.3", max_tokens=8192, reasoning_effort="high")
message = model.invoke("How many prime numbers are there below 100?")
print(message.additional_kwargs["reasoning_content"])
print(message.content)

Reasoning and the answer share max_tokens. If reasoning uses the budget up, response_metadata["finish_reason"] is "length" and the content can be empty, so set max_tokens with room for both. The API uses 8,192 when you set none. Reasoning tokens are billed as output and reported in usage_metadata["output_token_details"]["reasoning"].

Stop sequences

The API has no stop sequences. When stop is passed, on the model or on a call, this class cuts the answer at the first stop sequence after it arrives, for streamed answers too. The model does not stop early: it writes its whole answer, and the account pays for all of it. max_tokens limits how much that can be. Agents that use tool calling need no stop sequences.

What happens to settings the API does not take

Setting What this class does
name on a message, user, metadata, store, service_tier Left out
seed, frequency_penalty, presence_penalty, logit_bias and any other field the API does not list Left out, with an OathbreakerWarning
strict=True on tools Tools are sent without strict, with an OathbreakerWarning if you asked for it yourself
stop Applied to the answer after it arrives, with an OathbreakerWarning about the cost
n above 1, logprobs, the old functions format, images, audio and files in messages UnsupportedByOathbreaker, raised before anything is sent
reasoning={"effort": ...} Sent as reasoning_effort
use_responses_api=True ValueError when the model is created. This class uses Chat Completions

Python shows each warning once. To silence them, or to make them errors while you test:

import warnings
from langchain_oathbreaker import OathbreakerWarning

warnings.simplefilter("ignore", OathbreakerWarning)  # or "error"

Settings

Setting Default Notes
model required One of the models above
api_key OATHBREAKER_API_KEY Creating the model without a key raises ValueError
base_url OATHBREAKER_BASE_URL, then https://oathbreaker.ai/v1 The host is oathbreaker.ai, with no api. subdomain
max_tokens none; the API uses 8,192 Covers reasoning and the answer. A value above the model's maximum is lowered to it
reasoning_effort none; the API chooses "low", "high" or "max"
temperature, top_p none 0 to 2, and 0 to 1
timeout 650 Seconds. A generation can run for up to ten minutes
max_retries 0 Check usage before you repeat a request that timed out
http_client, http_async_client none For a proxy, pass openai.DefaultHttpxClient(proxy=...) and openai.DefaultAsyncHttpxClient(proxy=...)

Errors are the OpenAI SDK's: openai.AuthenticationError for a wrong key, openai.RateLimitError for a rate limit, and openai.APIStatusError with status_code == 402 when the account has no credit. The API's own message and request_id are in the error.

Not offered

  • Embeddings. Oathbreaker serves chat models only. For retrieval, take the embedding model from another provider.
  • Images, audio and files. The models read and write text.
  • The Responses API through this class. Oathbreaker has a Responses endpoint for Codex; this class always uses Chat Completions.

Tests

uv sync --group test
uv run pytest

The unit tests run against a local stand-in for the API (tests/unit_tests/mock_api.py) that refuses what the API reference says the API refuses. They never leave your computer, and they say nothing about model quality or speed.

uv run pytest tests/integration_tests/test_model_list.py
OATHBREAKER_API_KEY="your-api-key" uv run pytest tests/integration_tests

The first command compares the model table with the live model list; it needs no key and costs nothing. The second sends real requests, including LangChain's standard integration tests, and spends credit.

Checked with langchain-core 1.8.5, langchain-openai 1.8.5, langchain 1.5.2 and openai 3.61.0 on Python 3.12.

License

MIT. Oathbreaker AI is operated by Formacha LLC. Oathbreaker operates the API and billing, not the development of the underlying models.

Metadata

Release files for langchain-oathbreaker 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-oathbreaker 0.1.0
File Size Uploaded Provenance Actions
langchain_oathbreaker-0.1.0.tar.gz 40.7 kB With provenance Details for langchain_oathbreaker-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-oathbreaker 0.1.0
File Interpreter ABI Platform Actions
langchain_oathbreaker-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_oathbreaker-0.1.0-py3-none-any.whl

Total release size: 64.5 kB

Release files / langchain_oathbreaker-0.1.0.tar.gz

Download URL langchain_oathbreaker-0.1.0.tar.gz
Size 40.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26604ad0ed63d3be6446d1570f457d1cbc56047f75598059b6dcd6595be793f0
BLAKE2b-256 checksum
How to use checksums
51fc939a8b860a0a43a9abff81411b15ee8c4bfff02e89dba51393e01eb860ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / langchain_oathbreaker-0.1.0-py3-none-any.whl

Download URL langchain_oathbreaker-0.1.0-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
839bf0aebf758e63254ab93e132d0e3e1a782e32759f04ff0f66c6c5f66b41da
BLAKE2b-256 checksum
How to use checksums
f954be8bb31ba648b8c37d38a25ac7606fd065fd2c0d45afef3f8137a6b82ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for langchain-oathbreaker 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_oathbreaker-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page