Unrestricted AI Story Generator Built on an API
A story generator that does not refuse mature or dark themes in fiction is a short script around a chat endpoint. This guide builds one that keeps characters and plot consistent across a whole book.

Summary
- A story bible plus a rolling summary beats pasting the whole draft every time.
- The 100,000-token window leaves room for the bible, the summaries and the latest chapters of a long story.
- A 12-chapter story costs about six cents at $0.15 and $0.50 per 1M tokens.
- Text only, for lawful adult fiction. Content involving minors is never allowed.
What the generator needs to do
If you want an unrestricted ai story generator, the model is only half the work. A story breaks when the names change in chapter four, when a dead character walks back in, or when the tone drifts from tense to chatty. Those are memory problems, and you fix them with structure, not with a bigger prompt.
The design below has three parts: a fixed story bible (characters, setting, rules, style), a short running summary of what has happened, and the last one or two chapters verbatim. Each request sends all three and asks for the next chapter. Because the endpoint is OpenAI-compatible, the whole thing is about forty lines of Python.
Use it for fiction, interactive stories and roleplay scenarios for adults. The model is tuned to answer without content refusals for lawful adult use, so a villain can be menacing and a war story can be grim. One rule has no exceptions: no sexual content involving minors.
Plan the project before you code it. Decide the unit of generation: a chapter, a scene or a page. Smaller units give you more control and more chances to steer, larger units give smoother prose. Most people settle on scenes of 600 to 1,200 words.
Set up the client
Get a key on the API key page. New accounts can claim a $0.50 trial with one click, valid for 7 days, which is plenty for the experiments below. Then point the standard OpenAI SDK at this site's base URL.
from openai import OpenAI
client = OpenAI(
base_url="https://api.generatoraiunrestricted.com/v1",
api_key="YOUR_KEY",
)
def ask(messages, max_tokens=1800, temperature=0.9):
r = client.chat.completions.create(
model="uncensored",
messages=messages,
max_tokens=max_tokens,
temperature=temperature,
)
return r.choices[0].message.content
The model ID is always uncensored. Request and parameter details are in the API docs. A temperature around 0.8 to 1.0 suits prose; drop it to 0.3 when you ask for summaries.
Write the story bible
The bible is a plain text block that never changes unless you edit it. Keep it short and specific, because the model reads it on every call.
- Premise: two or three sentences.
- Characters: name, age, one speech habit, one want, one secret.
- Setting rules: what technology or magic exists, what does not.
- Style: point of view, tense, sentence length, what to avoid.
- Content boundaries: the themes you want, and anything you want left out.
BIBLE = '''PREMISE: A salvage crew finds a derelict ship that is still hunting.
CHARACTERS:
- Mara Voss, 41, captain. Clips her sentences. Wants the payout. Hides a debt.
- Teo Iyer, 23, engineer. Talks to machines. Wants to get home.
SETTING: No faster-than-light travel. Radio lag is real.
STYLE: Third person past tense, close on Mara. Short paragraphs. Dark, tense.
'''
SYSTEM = (
"You are a novelist writing for adult readers. Follow the story bible exactly. "
"Never rename characters or contradict established facts. "
"Write the requested chapter only, no commentary.\n\n" + BIBLE
)
Two lines in the system prompt do most of the consistency work: "follow the bible exactly" and "no commentary". The second one stops the model from ending a chapter with a note to you, which would then leak into the next prompt.
Chapter loop with a rolling summary
After each chapter, ask the model for a summary of only the new events in under 120 words, and append it to a running list. The next call then contains the bible, all summaries, and the last chapter in full.
summaries, last_chapter = [], ""
def next_chapter(n, direction):
context = "STORY SO FAR:\n" + "\n".join(summaries) if summaries else "This is chapter 1."
messages = [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": (
f"{context}\n\nPREVIOUS CHAPTER:\n{last_chapter}\n\n"
f"Write chapter {n}, about 1200 words. Direction: {direction}"
)},
]
return ask(messages)
def summarize(text):
return ask([
{"role": "system", "content": "Summarize story events in under 120 words. Facts only."},
{"role": "user", "content": text},
], max_tokens=250, temperature=0.3)
for n, d in enumerate(["They board the ship.", "The lights fail.", "Teo finds the log."], 1):
chapter = next_chapter(n, d)
summaries.append(f"Ch{n}: " + summarize(chapter))
last_chapter = chapter
print(chapter)
You can send the full text of every chapter instead, and for a short story that is fine. Summaries earn their keep once the draft passes a few tens of thousands of tokens, because they keep each call cheap and leave room for the answer. The context window is 100,000 tokens for prompt plus completion, and the completion can use whatever is left of it.
What it costs
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit. Take a 12-chapter story. Each chapter is about 1,500 output tokens, and the prompt averages 30,000 tokens (bible, growing summaries, previous chapter).
| Item | Tokens | Cost |
|---|---|---|
| Input per chapter | 30,000 | $0.0045 |
| Output per chapter | 1,500 | $0.00075 |
| One chapter | $0.00525 | |
| Twelve chapters | $0.063 |
The worst case is a prompt that fills the window: 90,000 input tokens and 1,500 output tokens cost $0.0135 plus $0.00075, or $0.01425 per call. Even then a hundred calls come to about $1.43. The summary calls add a few hundredths of a cent each. See the pricing page for top-up amounts and bonuses.
Tone, pacing and repeatable runs
Prose quality comes mostly from the instructions you give, so spend your words there. Three habits help.
- Describe the voice with examples, not adjectives. Paste a 100-word sample paragraph into the bible and say "match this rhythm". Adjectives like "gritty" mean different things to different readers, a sample does not.
- Set a length and an ending rule. "About 1,200 words, end on an unresolved moment" avoids both chapters that stop early and chapters that wrap up the plot too soon.
- Use the sampling controls. Temperature, top_p, stop, seed and the repetition penalties are passed through to the model. If scenes start to echo each other, raise
frequency_penaltya little, for example to 0.3. If you want to rerun a chapter with one change in the prompt and compare, fixseed.
Remember what the model cannot see. It only knows what is in the request, so a detail that mattered in chapter two but is not in the bible or in a summary is gone by chapter nine. When you notice a drift, the fix is almost always to add a line to the bible.
Turn it into an interactive story
The same loop can drive a choose-your-path game. Ask for the next scene plus three options as JSON, show them to the player, and feed the pick back in. JSON mode keeps the reply parseable.
import json
def scene(history, choice):
r = client.chat.completions.create(
model="uncensored",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": SYSTEM + "\nReply as JSON: {\"scene\": str, \"options\": [str, str, str]}"},
{"role": "user", "content": f"{history}\n\nPlayer chose: {choice}"},
],
max_tokens=900,
)
return json.loads(r.choices[0].message.content)
Wrap json.loads in a try block and retry once on a parse failure. Failed requests are not charged, which makes a retry cheap. Keep the history as compact summaries after the first few scenes, as in the chapter loop above, so each turn stays small and fast.
Keeping the story consistent
Pin facts that drift
If a character's eye colour or a ship's name keeps changing, add it to the bible. Do not rely on the summary to carry it.
Ask for beats first
For a long arc, make one cheap call that returns a ten-line outline, store it, and pass the relevant line as the direction for each chapter. The model then writes toward something instead of improvising forever.
Stream long chapters
Set stream=True so text appears as it is written. A streamed request holds one of your concurrency slots until the stream ends, and a full key allows 8 at once, so a single-user app never notices.
Handle 429 errors
If you run many stories in parallel you can hit the limit and get HTTP 429 with rate_limited or concurrency. Back off for a few seconds and retry; on temporary overload the response carries Retry-After: 5.
Limits to know
This is a text API. It does not draw covers, voice characters or create embeddings, so a "search my old chapters" feature needs a separate tool. It is one open-weight model run by an independent provider, not the official API of any big vendor. For a broader look at working with uncensored models, read our uncensored ChatGPT guide. Prompts are not used for training.
More guides
Frequently asked questions
Can I paste a whole novel into the prompt?
Up to the 100,000-token window for prompt plus completion, which is a long manuscript but not an unlimited one. A rolling summary is cheaper and leaves room for the next chapter.
Does it refuse dark themes in fiction?
The model is tuned to answer without content refusals for lawful adult use. Sexual content involving minors is never allowed.
Are failed requests billed?
No. Failed or refused requests are not charged.
Is there a free way to test it?
New users can claim $0.50 of trial credit with one click on the API key page. It lasts 7 days, needs no card and is limited to 2 concurrent requests and 60 per minute.
How do I pay?
With prepaid credit in USDT (TRC20) or USDC (Base), any whole amount from $20 to $500. Credit never expires.
Obtain your API key via sign-up
Register, retrieve the key, and update your base URL. That is the entire configuration.