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
- Install the model package. Add the agent package too if you want a tool loop later:
pip install -U langchain langchain-openainpm install langchain @langchain/openai @langchain/core zod- Export the key into the shell. The scripts below read the variable, so the key never sits in a file you might commit.
export UNRESTRICTABLE_API_KEY="sk-unr-live-…"- Python: build
ChatOpenAIfrom the id, the key and our base URL.invokegives back anAIMessage; itsusage_metadatais the token count you paid for.streamhands over chunks while the model is still writing.
import osfrom langchain_openai import ChatOpenAI model = ChatOpenAI( model="glm-5.3-uncensored", api_key=os.environ["UNRESTRICTABLE_API_KEY"], base_url="https://api.unrestrictable.ai/v1", max_tokens=1024, stream_usage=True, # usage on streamed replies too; LangChain switches it off when base_url is given) response = model.invoke("Explain, in three sentences, when a bloom filter beats a hash set.")print(response.content)print(response.usage_metadata) # {'input_tokens': …, 'output_tokens': …, 'total_tokens': …} for chunk in model.stream("List the POSIX signals a daemon should handle."): 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:
from langchain.chat_models import init_chat_model model = init_chat_model( model="glm-5.3-flash-uncensored", model_provider="openai", base_url="https://api.unrestrictable.ai/v1", api_key=os.environ["UNRESTRICTABLE_API_KEY"],)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.
export OPENAI_API_KEY="sk-unr-live-…"export OPENAI_BASE_URL="https://api.unrestrictable.ai/v1"- JavaScript: identical values, except the URL sits inside
configuration.baseURL. Thatconfigurationobject goes straight to the OpenAI SDK client, which is where any other client option belongs as well.
import { ChatOpenAI } from "@langchain/openai"; const model = new ChatOpenAI({ model: "glm-5.3-uncensored", apiKey: process.env.UNRESTRICTABLE_API_KEY, configuration: { baseURL: "https://api.unrestrictable.ai/v1" }, maxTokens: 1024,}); const response = await model.invoke("Explain, in three sentences, when a bloom filter beats a hash set.");console.log(response.content);console.log(response.usage_metadata); // { input_tokens, output_tokens, total_tokens } const stream = await model.stream("List the POSIX signals a daemon should handle.");for 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.
import osfrom langchain.agents import create_agentfrom langchain.tools import toolfrom langchain_openai import ChatOpenAI @tooldef read_file(path: str) -> str: """Read a UTF-8 text file and return its contents.""" with open(path, encoding="utf-8") as f: return f.read() model = ChatOpenAI( model="glm-5.3-uncensored", api_key=os.environ["UNRESTRICTABLE_API_KEY"], base_url="https://api.unrestrictable.ai/v1",) agent = create_agent( model=model, tools=[read_file], system_prompt="You review Python code. Read a file before you comment on it.",) result = agent.invoke({"messages": [{"role": "user", "content": "Review ./app.py for bugs."}]})print(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:
import { readFile } from "node:fs/promises";import { ChatOpenAI } from "@langchain/openai";import { createAgent, tool } from "langchain";import * as z from "zod"; const readTextFile = tool(async ({ path }) => readFile(path, "utf8"), { name: "read_file", description: "Read a UTF-8 text file and return its contents.", schema: z.object({ path: z.string() }),}); const model = new ChatOpenAI({ model: "glm-5.3-uncensored", apiKey: process.env.UNRESTRICTABLE_API_KEY, configuration: { baseURL: "https://api.unrestrictable.ai/v1" },}); const agent = createAgent({ model, tools: [readTextFile], systemPrompt: "You review TypeScript code. Read a file before you comment on it.",}); const result = await agent.invoke({ messages: [{ role: "user", content: "Review ./app.ts for bugs." }] });console.log(result.messages.at(-1)?.content);Each argument
- model
- glm-5.3-uncensoredthe 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/v1the destination; the client adds /chat/completions after it, so keep the trailing /v1
- max_tokens / maxTokens
- 1024ceiling on output tokens per reply; each build’s maximum is on its model page
- stream_usage
- TruePython 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
- Falsewhen true, invoke streams under the hood and joins the chunks; stream() streams regardless
- temperature, timeout, max_retries
- optionalsampling temperature, how long a request may take, and how often the client retries a failed one
- tools / system_prompt
- create_agentthe 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.
| Model | One agent turn | Tool calls |
|---|---|---|
| GLM-5.3 Uncensored | $0.01 | model page |
| GLM-5.3 Flash Uncensored | $0.0047 | model page |
| DeepSeek V4.1 Flash Abliterated | $0.04 | model page |
| DeepSeek V4 Pro Uncensored | $0.04 | model page |
| GLM-5.3 Abliterated | $0.09 | model page |
| GLM-5.3 Flash Code Uncensored | $0.25 | model page |
| GLM-5.3 Uncensored | Uncensored | $0.282 | $0.846 |
| GLM-5.3 Flash Uncensored | Uncensored | $0.1053 | $0.3685 |
| DeepSeek V4.1 Flash Abliterated | Abliterated | $0.8488 | $1.6975 |
| DeepSeek V4 Pro Uncensored | Uncensored | $0.97 | $1.94 |
| GLM-5.3 Abliterated | Abliterated | $2.1825 | $4.365 |
| GLM-5.3 Flash Code Uncensored | Uncensored | $6.00 | $6.00 |
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:
curl 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.
curl -i https://api.unrestrictable.ai/v1/chat/completions \ -H "Authorization: Bearer sk-unr-live-…" \ -H "Content-Type: application/json" \ -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, orUNRESTRICTABLE_API_KEYis 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_urlnever took effect and the key went to OpenAI instead.404 model_not_found: nothing on the models page matches themodelvalue. 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/completionsat the host root, or it went to/responses, which happens whenuse_responses_api=Trueis 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. Aretry-afterheader says how long to wait; withmax_retriesset, the client waits and retries by itself.usage_metadatacomes backNonefrom a Python stream: a presentbase_urlmakes LangChain defaultstream_usageto off. Givestream_usage=Trueto the constructor, or to thestreamcall.- The agent only writes prose and never picks a tool, or the
toolsfield is rejected: this build has no tool calls. Move to one whose model page lists them.with_structured_outputon its default method has the same requirement;method="json_schema"instead needs a build that acceptsresponse_format. - The reply cuts off and
finish_reasonreadslength:max_tokensis 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.