Unfiltered ChatGPT API in Node.js: Setup Steps
The official openai package works as is. Point it at a new base URL, use the model ID uncensored, and you have a Node.js client with streaming, tools and JSON mode.
Updated

What you need before you start
For an unfiltered chatgpt api node js setup you need three things: Node 18 or newer, an API key, and the official openai package. There is nothing special to install. The service speaks the OpenAI request format, so the same SDK you would use for any OpenAI-style endpoint works once you change the base URL to https://api.unfilteredchatgpt.top/v1 and the model to uncensored.
Be clear about what this is. It is not ChatGPT and it is not an official API from OpenAI or any other big vendor. It is an open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use. It never produces sexual content involving minors.
Create an account (Google, or email and password), then open the API key page. A one-click $0.50 trial is available there, valid for 7 days, with no card. Export the key as an environment variable so it stays out of your source:
# https://api.unfilteredchatgpt.top/v1 is the base URL, uncensored is the model id
export API_KEY="paste-your-key-here"Install the SDK and check the key
Create a folder, install the package and make one request to /v1/models. If the key is right you get a JSON list with the uncensored model in it.
# project setup, then call the API once to confirm the key works
npm init -y
npm install openai
curl https://api.unfilteredchatgpt.top/v1/models -H "Authorization: Bearer $API_KEY" # model id: uncensored
Use ES modules so top-level await works. Either name the file index.mjs or add "type": "module" to package.json. If you prefer CommonJS, wrap the code in an async function and use require("openai").
Your first chat completion
This is the full minimum. The only differences from a stock OpenAI example are the two lines that set baseURL and model.
// index.mjs (Node 18 or newer)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.unfilteredchatgpt.top/v1",
apiKey: process.env.API_KEY,
});
const res = await client.chat.completions.create({
model: "uncensored",
messages: [
{ role: "system", content: "You are a blunt, witty co-writer for adult fiction." },
{ role: "user", content: "Describe a rainy border town in four sentences." },
],
temperature: 0.9,
});
console.log(res.choices[0].message.content);
console.log(res.usage);
Run it with node index.mjs. You get the reply text and a usage object with prompt and completion token counts. A system message is where you set persona and tone, and this model follows it closely, so be specific about what you want. The temperature, top_p, stop, seed and penalty parameters are passed through to the model.
Context is 100,000 tokens for prompt plus completion. max_tokens is optional. If you leave it out, the completion can use whatever is left of the window, which is useful for long scenes and expensive if a loop goes wrong, so set it in test code.
Streaming tokens as they arrive
For a chat UI or a CLI you want text to appear while it is being generated. Set stream: true and iterate over the chunks. Usage arrives at the end of the stream.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unfilteredchatgpt.top/v1", apiKey: process.env.API_KEY });
const stream = await client.chat.completions.create({
model: "uncensored",
stream: true,
stream_options: { include_usage: true },
messages: [{ role: "user", content: "Tell me a short story about a lighthouse keeper." }],
});
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta?.content;
if (delta) process.stdout.write(delta);
if (chunk.usage) console.log("\n", chunk.usage);
}
One detail matters for production code. A streamed request holds its concurrency slot until the stream ends. A full key allows 8 concurrent requests and a trial key 2, so if your users abandon streams without closing them, abort the request on the client side (the SDK supports an AbortController signal) or you will run into the concurrency error sooner than expected.
Tool calling and JSON mode
Both work through the standard fields. For tools, pass tools and optionally tool_choice. The model returns tool_calls, you run the function, and you send the result back as a message with role: "tool". Streamed responses carry tool_calls too.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unfilteredchatgpt.top/v1", apiKey: process.env.API_KEY });
const tools = [{
type: "function",
function: {
name: "roll_dice",
description: "Roll a die with the given number of sides",
parameters: {
type: "object",
properties: { sides: { type: "integer" } },
required: ["sides"],
},
},
}];
const messages = [{ role: "user", content: "Roll a d20 for my attack." }];
const first = await client.chat.completions.create({ model: "uncensored", messages, tools, tool_choice: "auto" });
const msg = first.choices[0].message;
if (msg.tool_calls) {
messages.push(msg);
for (const call of msg.tool_calls) {
const { sides } = JSON.parse(call.function.arguments);
const result = 1 + Math.floor(Math.random() * sides);
messages.push({ role: "tool", tool_call_id: call.id, content: String(result) });
}
const final = await client.chat.completions.create({ model: "uncensored", messages, tools });
console.log(final.choices[0].message.content);
}
For structured output, JSON mode is one extra field. Say the word JSON in the prompt and describe the shape you want, since the flag guarantees syntax and not your schema.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unfilteredchatgpt.top/v1", apiKey: process.env.API_KEY });
const res = await client.chat.completions.create({
model: "uncensored",
response_format: { type: "json_object" },
messages: [
{ role: "system", content: "Reply with JSON only: {\"name\": string, \"traits\": string[]}" },
{ role: "user", content: "Invent a cynical ship captain." },
],
});
const character = JSON.parse(res.choices[0].message.content);
console.log(character.name, character.traits);
Always wrap JSON.parse in a try/catch in real code. If the model cuts off at max_tokens, the JSON will be incomplete.
Handling errors and rate limits
A full key allows 8 concurrent requests and 300 per minute. A trial key allows 2 and 60. Over a limit you get HTTP 429 with the error code rate_limited (too many per minute) or concurrency (too many at once). Temporary overload also returns 429, with a Retry-After: 5 header. The fix is the same in all cases: wait and retry, with a cap on attempts.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unfilteredchatgpt.top/v1", apiKey: process.env.API_KEY, maxRetries: 0 });
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function chat(messages, attempt = 0) {
try {
return await client.chat.completions.create({ model: "uncensored", messages });
} catch (err) {
if (err.status === 429 && attempt < 5) {
const wait = Number(err.headers?.["retry-after"] ?? 5) * 1000;
await sleep(wait + attempt * 500);
return chat(messages, attempt + 1);
}
throw err;
}
}
The retry above turns off the SDK's built-in retries so you control the timing. For batch jobs, put a small queue in front, for example p-limit with a limit of 6, which leaves headroom under the 8-request ceiling. The maximum request body is 8 MB, which is far more than any text prompt, but base64 blobs pasted into messages can hit it.
Failed or refused requests are not charged, so retries on errors cost nothing extra.
Keeping conversation history
The API is stateless. Every request must carry the messages the model should see, so a chat bot needs an array that grows with each turn. Keep the system message first and trim from the oldest user and assistant messages when the history gets long.
import OpenAI from "openai";
import readline from "node:readline/promises";
const client = new OpenAI({ baseURL: "https://api.unfilteredchatgpt.top/v1", apiKey: process.env.API_KEY });
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const history = [{ role: "system", content: "You are a dry-humored narrator for an adult text adventure." }];
while (true) {
const text = await rl.question("> ");
if (text.length === 0) break;
history.push({ role: "user", content: text });
const res = await client.chat.completions.create({ model: "uncensored", messages: history, max_tokens: 600 });
const reply = res.choices[0].message.content;
history.push({ role: "assistant", content: reply });
console.log(reply);
while (history.length > 21) history.splice(1, 2); // keep system + last 20
}
rl.close();
Because input tokens are billed on every call, a 40-message history costs far more than a 4-message one. The window is 100,000 tokens, so you rarely hit the limit, but you will notice the bill first. Long roleplay sessions benefit from a short running summary in place of the oldest turns.
Common problems and fixes
- 401 or an authentication error. The key is missing or has a typo. Check that
process.env.API_KEYis set in the shell that runs Node, since a new terminal tab does not inherit exports. - 404 on every call. The base URL is missing
/v1, or has a doubled path. Use the address exactly as shown above and let the SDK add/chat/completions. - Model not found. The model ID is
uncensored, all lowercase. CallGET /v1/modelsto see what the key can use. - Broken JSON from JSON mode. The output was cut at
max_tokens. Raise the limit or shorten the schema. - Streams that hang the app. Always consume or abort the stream. An open stream keeps its concurrency slot.
- Costs higher than expected. Log
usageon every response and look at input tokens first. History resent on each turn is the usual cause.
If something still fails, send the X-Request-Id header value from the response to support. The support page has the contact details.
No SDK: plain fetch
If you want zero dependencies, Node 18 has fetch built in. The response headers include X-Request-Id for support questions and X-Balance-USD for your remaining credit.
const res = await fetch("https://api.unfilteredchatgpt.top/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "uncensored",
messages: [{ role: "user", content: "Say hello in one line." }],
}),
});
console.log(res.headers.get("x-request-id"), res.headers.get("x-balance-usd"));
console.log((await res.json()).choices[0].message.content);
Other OpenAI-compatible tools work the same way. In any client that lets you set a custom endpoint, such as SillyTavern or LangChain's OpenAI wrapper, enter the base URL, paste your key and type uncensored as the model name. The docs page has the short version of this, and the chatbot API article shows how to turn these calls into a full bot.
Cost check before you ship: input is $0.15 per 1M tokens and output is $0.50 per 1M. A reply of 5,000 input and 1,500 output tokens costs $0.00075 + $0.00075 = $0.0015, so $20 of credit covers about 13,333 of them. The pricing page has the top-up tiers.
More guides
Questions and answers
Can I use the official openai npm package?
Yes. Set baseURL to the API address and use the model ID uncensored. No other changes are needed.
Which Node version do I need?
Node 18 or newer, which gives you built-in fetch and works with the current openai package. Use ES modules for top-level await.
Why do I get a 429 error?
You hit a limit. The code rate_limited means too many requests per minute, concurrency means too many at once. Wait and retry, and cap simultaneous requests.
Does it support streaming and function calling?
Yes. Streaming runs over SSE with usage at the end, and tool calling follows the OpenAI format including streamed tool_calls.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.