Run LangChain and LangGraph agents on an uncensored model

Point ChatOpenAI at our base URL in Python or JavaScript, pick an uncensored id, hand the instance to create_agent. Token counts, agent turn prices, the errors.

Steps checked November 2, 2026 · prices as of November 16, 2026

Two constructor arguments, a base URL and a key, move ChatOpenAI off OpenAI and onto an uncensored build, with your existing chains and agents untouched. Pick an id on the models page, build the instance in Python or JavaScript, and create_agent runs its tool loop against it. Prefer to skip the install? The same models answer in the browser at /chat.

What you need

  • Python 3 with pip, or Node 22 or newer with npm.
  • A key from the console. It begins with sk-unr- and draws on a prepaid balance.
  • A model id, copied as the models page prints it. The snippets use glm-5.3-uncensored, glm-5.3-flash-uncensored, deepseek-v4.1-flash-abliterated, the three ids LangChain users send most often here.

No settings panel is involved. ChatOpenAI, from langchain-openai in Python and @langchain/openai in JavaScript, takes the endpoint and the key as constructor arguments: base_url plus api_key on the Python side, apiKey plus configuration.baseURL on the JavaScript side. init_chat_model and initChatModel accept the same pair next to model_provider="openai". Agents built with create_agent (createAgent in JavaScript) take that instance, so the endpoint is set in one place. LangGraph’s create_react_agent is the older name for the same thing.

To try a build before writing a line, open /chat or message the Telegram bot; both give a few free replies a day without an account.

First reply

  1. Install the model package. Add the agent package too if you want a tool loop later:
shell
1pip install -U langchain langchain-openai
shell
1npm install langchain @langchain/openai @langchain/core zod
  1. Export the key into the shell. The scripts below read the variable, so the key never sits in a file you might commit.
shell
1export UNRESTRICTABLE_API_KEY="sk-unr-live-…"
  1. Python: build ChatOpenAI from the id, the key and our base URL. invoke gives back an AIMessage; its usage_metadata is the token count you paid for. stream hands over chunks while the model is still writing.
python
1import os
2from langchain_openai import ChatOpenAI
3
4model = ChatOpenAI(
5 model="glm-5.3-uncensored",
6 api_key=os.environ["UNRESTRICTABLE_API_KEY"],
7 base_url="https://api.unrestrictable.ai/v1",
8 max_tokens=1024,
9 stream_usage=True, # usage on streamed replies too; LangChain switches it off when base_url is given
10)
11
12response = model.invoke("Explain, in three sentences, when a bloom filter beats a hash set.")
13print(response.content)
14print(response.usage_metadata) # {'input_tokens': …, 'output_tokens': …, 'total_tokens': …}
15
16for chunk in model.stream("List the POSIX signals a daemon should handle."):
17 print(chunk.content, end="", flush=True)

When the model id comes from a config file, init_chat_model produces the identical object from a provider name:

python
1from langchain.chat_models import init_chat_model
2
3model = init_chat_model(
4 model="glm-5.3-flash-uncensored",
5 model_provider="openai",
6 base_url="https://api.unrestrictable.ai/v1",
7 api_key=os.environ["UNRESTRICTABLE_API_KEY"],
8)

Both values can also live in the environment. LangChain reads OPENAI_API_KEY when api_key is missing, and OPENAI_API_BASE, then OPENAI_BASE_URL, when base_url is missing. Export the two below and a bare ChatOpenAI(model="…") hits this API. If the same process also calls OpenAI, keep the arguments explicit; otherwise both clients end up on one base URL.

shell
1export OPENAI_API_KEY="sk-unr-live-…"
2export OPENAI_BASE_URL="https://api.unrestrictable.ai/v1"
  1. JavaScript: identical values, except the URL sits inside configuration.baseURL. That configuration object goes straight to the OpenAI SDK client, which is where any other client option belongs as well.
typescript
1import { ChatOpenAI } from "@langchain/openai";
2
3const model = new ChatOpenAI({
4 model: "glm-5.3-uncensored",
5 apiKey: process.env.UNRESTRICTABLE_API_KEY,
6 configuration: { baseURL: "https://api.unrestrictable.ai/v1" },
7 maxTokens: 1024,
8});
9
10const response = await model.invoke("Explain, in three sentences, when a bloom filter beats a hash set.");
11console.log(response.content);
12console.log(response.usage_metadata); // { input_tokens, output_tokens, total_tokens }
13
14const stream = await model.stream("List the POSIX signals a daemon should handle.");
15for await (const chunk of stream) process.stdout.write(String(chunk.content));

An agent on the same instance

Give the model object to create_agent together with your tools. Each pass sends the conversation, executes whichever tool the model requested, adds the result to the thread and asks again, until a plain text reply comes back. Only a build whose model page lists tool calls can drive this; the table further down marks them.

python
1import os
2from langchain.agents import create_agent
3from langchain.tools import tool
4from langchain_openai import ChatOpenAI
5
6
7@tool
8def read_file(path: str) -> str:
9 """Read a UTF-8 text file and return its contents."""
10 with open(path, encoding="utf-8") as f:
11 return f.read()
12
13
14model = ChatOpenAI(
15 model="glm-5.3-uncensored",
16 api_key=os.environ["UNRESTRICTABLE_API_KEY"],
17 base_url="https://api.unrestrictable.ai/v1",
18)
19
20agent = create_agent(
21 model=model,
22 tools=[read_file],
23 system_prompt="You review Python code. Read a file before you comment on it.",
24)
25
26result = agent.invoke({"messages": [{"role": "user", "content": "Review ./app.py for bugs."}]})
27print(result["messages"][-1].content)

Existing LangGraph code on create_react_agent still runs; model and tools are unchanged and the system prompt goes in as prompt. The deprecation message points to the import shown above. In JavaScript the agent looks the same:

typescript
1import { readFile } from "node:fs/promises";
2import { ChatOpenAI } from "@langchain/openai";
3import { createAgent, tool } from "langchain";
4import * as z from "zod";
5
6const readTextFile = tool(async ({ path }) => readFile(path, "utf8"), {
7 name: "read_file",
8 description: "Read a UTF-8 text file and return its contents.",
9 schema: z.object({ path: z.string() }),
10});
11
12const model = new ChatOpenAI({
13 model: "glm-5.3-uncensored",
14 apiKey: process.env.UNRESTRICTABLE_API_KEY,
15 configuration: { baseURL: "https://api.unrestrictable.ai/v1" },
16});
17
18const agent = createAgent({
19 model,
20 tools: [readTextFile],
21 systemPrompt: "You review TypeScript code. Read a file before you comment on it.",
22});
23
24const result = await agent.invoke({ messages: [{ role: "user", content: "Review ./app.ts for bugs." }] });
25console.log(result.messages.at(-1)?.content);

Each argument

model
glm-5.3-uncensored
the id exactly as the models page writes it; it becomes the model field of every request
api_key / apiKey
os.environ["UNRESTRICTABLE_API_KEY"]
the full sk-unr- key, sent as Authorization: Bearer; if omitted, Python reads OPENAI_API_KEY
base_url / configuration.baseURL
https://api.unrestrictable.ai/v1
the destination; the client adds /chat/completions after it, so keep the trailing /v1
max_tokens / maxTokens
1024
ceiling on output tokens per reply; each build’s maximum is on its model page
stream_usage
True
Python only: requests the usage chunk on streams. LangChain disables it once base_url is set, and this API does answer it, so switch it back on. JavaScript sends it by default (streamUsage)
streaming
False
when true, invoke streams under the hood and joins the chunks; stream() streams regardless
temperature, timeout, max_retries
optional
sampling temperature, how long a request may take, and how often the client retries a failed one
tools / system_prompt
create_agent
the functions the agent is allowed to call, and the message placed first in every call; in createAgent the field is systemPrompt

Which build

Every build on the models page answers the OpenAI-format requests that ChatOpenAI sends, so invoke and stream accept any id. Tool calls are the dividing line: the agent loop depends on them, as do bind_tools and with_structured_output in its default function-calling method. Because an agent turn resends the whole conversation plus every file and tool result so far, input tokens dominate the cost, and a low input price is what makes a turn cheap.

ModelOne agent turnTool calls
GLM-5.3 Uncensored$0.01model page
GLM-5.3 Flash Uncensored$0.0047model page
DeepSeek V4.1 Flash Abliterated$0.04model page
DeepSeek V4 Pro Uncensored$0.04model page
GLM-5.3 Abliterated$0.09model page
GLM-5.3 Flash Code Uncensored$0.25model page

A turn of 40,000 input and 1,200 output tokens, priced from the catalog on 2026-11-16. The tool-call column repeats what the catalog publishes; a blank cell means the model page has the answer.

Uncensored models and their prices per million tokens
GLM-5.3 Uncensoredglm-5.3-uncensoredUncensored$0.282$0.846
GLM-5.3 Flash Uncensoredglm-5.3-flash-uncensoredUncensored$0.1053$0.3685
DeepSeek V4.1 Flash Abliterateddeepseek-v4.1-flash-abliteratedAbliterated$0.8488$1.6975
DeepSeek V4 Pro Uncensoreddeepseek-v4-pro-uncensoredUncensored$0.97$1.94
GLM-5.3 Abliteratedglm-5.3-abliteratedAbliterated$2.1825$4.365
GLM-5.3 Flash Code Uncensoredglm-5.3-flash-code-uncensoredUncensored$6.00$6.00

Prices per million tokens, read from the live catalog on 2026-11-16.

Building a coding agent? The uncensored coding AI guide puts the code builds side by side and prices a whole working day on each. The ids here also drop into Cursor, OpenCode and, behind a router, Claude Code.

Prove it works

Ask the API which models the key may call. The id you chose for model has to appear in the list:

shell
1curl https://api.unrestrictable.ai/v1/models -H "Authorization: Bearer sk-unr-live-…"

Next, post one request shaped the way ChatOpenAI posts it. With -i you see the response headers: one carries the request id, and on a non-streamed reply another carries the charge in USD.

shell
1curl -i https://api.unrestrictable.ai/v1/chat/completions \
2 -H "Authorization: Bearer sk-unr-live-…" \
3 -H "Content-Type: application/json" \
4 -d '{"model": "glm-5.3-uncensored", "messages": [{"role": "user", "content": "Reply with the single word ok."}]}'

Now run the Python or JavaScript file. The usage_metadata on the reply is the input and output count the request was billed on, and the console’s usage page shows the same request with its charge. For streams the count rides on the final chunk, and in Python only when stream_usage=True.

When it fails

  • 401 invalid_api_key: a mistyped or revoked key, or UNRESTRICTABLE_API_KEY is not exported in the shell running the script. Export it once more, or make a fresh copy from the console. If the 401 body mentions OpenAI, base_url never took effect and the key went to OpenAI instead.
  • 404 model_not_found: nothing on the models page matches the model value. Compare the spelling. 404 route_not_found: the request landed on a path we do not serve. Either the base URL lost its /v1, so the client posted /chat/completions at the host root, or it went to /responses, which happens when use_responses_api=True is set or when a Responses-only option (reasoning, a built-in tool) is used. We serve /v1/chat/completions; drop those options.
  • 402 insufficient_balance: the balance cannot cover this call; add credit in the console. 402 monthly_limit_reached: the key has spent the monthly cap you set for it.
  • 403 scope_denied: the key is scoped to specific models, and this id is outside that scope.
  • 429 rate_limited: the key is over its rate limit. A retry-after header says how long to wait; with max_retries set, the client waits and retries by itself.
  • usage_metadata comes back None from a Python stream: a present base_url makes LangChain default stream_usage to off. Give stream_usage=True to the constructor, or to the stream call.
  • The agent only writes prose and never picks a tool, or the tools field is rejected: this build has no tool calls. Move to one whose model page lists them. with_structured_output on its default method has the same requirement; method="json_schema" instead needs a build that accepts response_format.
  • The reply cuts off and finish_reason reads length: max_tokens is below what the answer needed. Raise it, up to the limit on the model page.

Questions

No. ChatOpenAI speaks the OpenAI wire format, and it only reaches OpenAI when no base URL is given. Set base_url (Python) or configuration.baseURL (JavaScript) to this API and pass a console key, and the same class, chains and agents run on an uncensored build without an OpenAI account.

Not with this API. ChatOpenAI moves to Responses once use_responses_api=True is set, or once a Responses-only feature (reasoning, a built-in tool) is in play. We serve Chat Completions, which is also ChatOpenAI’s default, so leave those off; invoke, stream, bind_tools and create_agent all work on Chat Completions.

All of them. One key reaches every id on the models page over /v1/chat/completions in OpenAI format, so each can be the model argument, spelled as the page spells it. For agents, bind_tools or default structured output, pick a build with tool calls on its model page; the table above marks them. See the models page.

An endpoint that takes the OpenAI request body at /v1/chat/completions and returns the OpenAI response body, so a client built for OpenAI only needs a new base URL and key. This API is one. ChatOpenAI is such a client, and its usage_metadata reports the tokens each request was billed on, charged per token against your prepaid balance.

Every model above is on the uncensored model list with its live price per million tokens. Per-token pricing sets the whole catalog side by side, and the family directory groups the builds by base model.

Get a keyPrepaid from $10, no subscription.

New models and price changes, once a month.

New uncensored builds with their prices, price moves, and what the daily model check found.

Join on Telegram