Build an Uncensored AI Writing Tool With an API
An uncensored AI writing tool is a small web app with four parts: an editor, a set of prompt templates, a server that streams text from the model, and storage for drafts. This article lays out each part and gives code you can run today.

The architecture in one picture
A writing tool for fiction, drafts and roleplay scenes does not need much. Most of the work is deciding where each responsibility lives. Here is the layout that holds up well:
- Editor. A text area or a rich editor in the browser. It holds the current draft and a selection.
- Template layer. Named prompts such as "continue scene", "rewrite in a darker tone" or "describe the setting". They are stored as data.
- Proxy server. A small backend that adds your API key, calls the model and forwards the stream. The browser never sees the key.
- Storage. A database table of drafts with a project id and a timestamp.
The model sits behind an OpenAI-compatible endpoint at https://api.uncensoredaitool.com/v1, so any OpenAI SDK works. You pass the model id uncensored, send a messages array and read the response. If you have not made a call yet, the API documentation shows the shortest path.
A word on scope. The model is text only. If your product needs covers, voice or embeddings for search, those come from other services. For a writing app, text is what matters, and the model is tuned to answer without content refusals for lawful adult use, which is why writers of dark fiction pick this kind of backend.
The proxy: keeping the key off the client
Never call the API from browser code with a real key. Anyone who opens the developer tools can copy it. Put a thin route on your server instead. This Node example uses Express and the official openai package, with the key read from the API_KEY environment variable:
import express from "express";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.API_KEY,
baseURL: "https://api.uncensoredaitool.com/v1",
});
const app = express();
app.use(express.json({ limit: "1mb" }));
app.post("/api/generate", async (req, res) => {
const { system, prompt } = req.body;
res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache");
const stream = await client.chat.completions.create({
model: "uncensored",
stream: true,
temperature: 0.9,
messages: [
{ role: "system", content: system },
{ role: "user", content: prompt },
],
});
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta?.content;
if (text) res.write(`data: ${JSON.stringify(text)}\n\n`);
}
res.write("data: [DONE]\n\n");
res.end();
});
app.listen(3000);The route accepts a system prompt and a user prompt, opens a streamed completion and writes each text delta as a server-sent event. A streamed request holds one of your concurrent slots until the stream ends, so a user who closes the tab should trigger an abort on the upstream call. With req.on("close", ...) you can call stream.controller.abort() and free the slot.
Add your own authentication in front of this route. Without it, anyone who finds the URL can spend your credit.
Streaming tokens into the editor
Waiting thirty seconds for a finished scene feels broken. Streaming makes the text appear as it is produced, and writers can stop a bad direction early. The browser side is a plain fetch with a reader:
async function generate(system, prompt, onText) {
const res = await fetch("/api/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ system, prompt }),
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { value, done } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const events = buffer.split("\n\n");
buffer = events.pop();
for (const ev of events) {
const data = ev.replace(/^data: /, "");
if (data === "[DONE]") return;
onText(JSON.parse(data));
}
}
}Call generate() with a callback that appends text to a preview pane, not to the draft itself. When the user clicks "accept", copy the preview into the editor. That one extra step prevents the most common complaint in writing tools: a regeneration that destroys what you had.
At the end of a stream the API also reports token usage. Log it per request. You will want those numbers when you price your own plans.
Prompt templates that writers can edit
Hard-coding prompts in your source is the fastest way to ship and the slowest way to improve. Treat templates as records: a name, a system prompt, a user prompt with placeholders, and sampling settings. A small set covers most needs.
A starter set
- Continue. Sends the last 1,500 words and asks for the next 300 in the same voice.
- Rewrite. Sends a selection plus an instruction such as "tighter, same events".
- Brainstorm. Asks for five options, with a higher temperature.
- Character check. Sends a character sheet plus a scene and asks where the behaviour drifts.
Sampling per template
temperature, top_p, stop, seed and the penalties are passed through to the model. Store them with the template. Brainstorming wants a high temperature; a continuity check wants a low one. A fixed seed helps when you test a template change and want to see only the effect of your edit.
Keep a standing "story bible" block (setting, names, tone rules, hard boundaries) that is prepended to every request. Writers refer to it constantly, and putting it in the system message keeps it consistent.
Saving drafts and handling long projects
Treat each accepted generation as a new version, not an overwrite. A single table is enough to start:
CREATE TABLE drafts (
id INTEGER PRIMARY KEY,
project_id INTEGER NOT NULL,
body TEXT NOT NULL,
template TEXT,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
);Insert a row on every accept and on every manual save. Undo then becomes "load the previous row", and you get a history for free.
Long projects raise the context question. The window is 100,000 tokens, prompt plus completion, which is far more than a chapter. Still, sending the entire manuscript on each click is wasteful and slow. A practical approach is to send the story bible, a short running summary of earlier chapters, and the last few pages. Update the summary with a cheap extra call whenever a chapter is finished.
The request body can be up to 8 MB, so size is rarely the limit. Cost and focus are. A model with a focused prompt writes better than one buried in 80,000 tokens of old text.
What it costs to run
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, billed from prepaid credit. Take one "continue scene" click: 3,000 tokens in (bible, summary, recent pages) and 600 tokens out.
- Input: 3,000 × $0.15 / 1,000,000 = $0.00045
- Output: 600 × $0.50 / 1,000,000 = $0.0003
- Total per click: $0.00075
A heavy user who clicks 200 times in a month spends $0.15. Even 1,000 users doing that cost $150 in model usage. The pricing page lists the top-up tiers, and failed or refused requests are not charged. You can also try the whole pipeline on the $0.50 trial credit, available from the API key page after sign-up.
For rate limits, a full key allows 8 concurrent requests and 300 requests per minute. If your app has many simultaneous writers, queue requests on your server and answer 429 responses with a retry after the delay given in Retry-After.
Boundaries to build in from day one
An uncensored backend gives you freedom, and it also moves responsibility to you. Add an age gate if your product deals with mature themes, write clear terms, and keep content use lawful and adult. The one hard limit is that sexual content involving minors is not allowed, and a good tool refuses to help with it at the template level too.
Prompts are not used for training, but your own database still holds your users' stories. Treat it with the care you would give any private writing. Our comparison of models and providers covers how to judge a backend before you commit to one.
More guides
Questions and answers
Can I use the OpenAI SDK for an uncensored writing app?
Yes. Change the base URL to https://api.uncensoredaitool.com/v1, set your key as the bearer token and use the model id uncensored. Streaming, JSON mode and tool calling work through the same calls.
Should the browser talk to the API directly?
No. A key placed in browser code can be copied by any visitor. Route requests through your own server and add your own sign-in check there.
How long can a manuscript be?
The context window is 100,000 tokens for prompt plus completion. For a full novel, send a summary and the recent pages instead of the whole text.
What happens when many writers use the app at once?
A full key allows 8 concurrent requests. Beyond that the API returns 429 with the code concurrency, so queue requests and retry after a short delay.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.
Key points
- Keep the API key on your server and stream tokens to the browser through a thin proxy.
- Store prompt templates as data, so writers can edit them without a deploy.
- Save every draft version; a regenerated paragraph should never overwrite the last good one.
- A typical 1,000-word generation costs a fraction of a cent at $0.15 and $0.50 per 1M tokens.
Start with trial credit
Email and password, key on screen right away.