Building Creative Writing Tools With LLMs
How to build fiction and storytelling tools on LLMs: story bibles in context, outline-then-draft chains, style examples, sampling limits and copyright rules.
Getting a large language model to write one good page is easy. Getting it to write chapter forty without forgetting that the detective lost her left glove in chapter three is the real engineering problem. This guide covers the patterns that hold up when you build writing and storytelling tools on top of an LLM API: keeping long stories consistent, splitting work into outline, draft and review calls, steering voice with examples, handling sampling settings, and staying on the right side of copyright and disclosure rules. Vendor behaviour described here comes from Anthropic’s and OpenAI’s own documentation, the US Copyright Office and the text of the EU AI Act.
Keep the canon outside the model
The model does not remember your story between requests. Everything it needs, from character names to which secrets have already been revealed, has to travel in the prompt each time. In practice that means your app owns a set of canon files and assembles them into context for every call:
| File | What it holds | When it changes |
|---|---|---|
| Story bible | Setting, rules of the world, tone, banned clichés | Rarely, by the author |
| Character sheets | Names, voice notes, relationships, what each person knows | After each chapter |
| Chapter summaries | A short recap of every finished chapter | After each chapter |
| Open threads | Promises, mysteries and hooks still unresolved | After each chapter |
| Current chapter outline | Beats for the scene being drafted | Before drafting |
Full earlier chapters rarely need to be resent. Summaries plus the last scene or two usually carry enough continuity, and they keep requests cheaper and more focused. Context windows are large now (Anthropic lists 1M tokens for every current Claude model, from Claude Haiku 5.5 up to Claude Fable 5.1), but every input token you send is billed, and Anthropic prices models per million input tokens. Our piece on context window optimization goes deeper on trimming.
Anthropic’s prompting guide gives two layout tips that apply directly. For inputs above roughly 20k tokens, put the long material near the top of the prompt and your instructions and question at the end. When you pass several documents, wrap each in its own <document> tag with a <source> label and the content inside. For a story app that might look like this:
<documents>
<document index="1"><source>story_bible.md</source><document_content>...</document_content></document>
<document index="2"><source>characters.md</source><document_content>...</document_content></document>
<document index="3"><source>chapter_summaries.md</source><document_content>...</document_content></document>
</documents>
<style_examples>...</style_examples>
<instructions>Draft chapter 12 from the outline below. ...</instructions>
The same guide suggests asking the model to quote the relevant parts of long documents before doing the task. For fiction, that maps neatly onto “first list the canon facts this scene depends on, then write it”, which gives you something to check the draft against.
One OpenAI-specific trap: its text generation guide notes that the instructions parameter applies only to the current request. If you chain turns with previous_response_id, earlier instructions are not carried forward, so resend your system-level writing rules on every call.
Outline first, then draft, then review
A single “write me a novel” prompt gives you no place to intervene. Break the job into separate API calls instead:
- Premise and outline. Generate a chapter-by-chapter plan. The author edits it.
- Scene beats. Expand one chapter into beats, checked against the character sheets.
- Draft. Write the prose for that chapter only.
- Review. A second call compares the draft with the canon files and lists contradictions, pacing problems and voice drift.
- Revise. A third call fixes the flagged issues.
- Update canon. Summarise the chapter and update character knowledge and open threads.
Anthropic calls the draft, review and refine loop the most common prompt-chaining pattern, and points out that running each step as its own call lets you log, evaluate or branch at any stage. That is exactly what an editor UI needs: a place to pause, show the author the review notes and accept or reject them before revision.
Steer style with examples, not adjectives
“Write in a lyrical, understated voice” means different things to different models. Showing works better. Anthropic describes examples as one of the most dependable ways to control tone, format and structure, and recommends three to five of them. It also advises making them relevant to the real task, varied enough that the model does not latch onto accidental patterns, and wrapped in <example> tags so they are not confused with instructions.
For a writing tool, good examples are short passages in the target voice, ideally from the author’s own earlier work, covering different situations: dialogue, action and quiet description. Two related tips from the same guide help with fiction:
- Say what you want rather than what to avoid. “Write in flowing prose paragraphs” works better than “don’t use bullet points”.
- Your prompt’s own formatting leaks into the output. A prompt full of markdown tends to get markdown back, so keep prose-generation prompts plain.
Setting a role in the system prompt also helps. Anthropic’s official example is minimal:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
system="You are a helpful coding assistant specializing in Python.",
messages=[
{"role": "user", "content": "How do I sort a list of dictionaries by key?"}
],
)
print(message.content)
In a writing app, the system string becomes your role plus the story bible and style rules, and the user message carries the outline and the instruction for this step. More general techniques are collected in our prompt engineering best practices.
Sampling settings: check the model’s docs first
It is tempting to raise the temperature for creative work, but that knob is not available on every model. Anthropic’s migration guide for Claude Opus 5.5 says to omit temperature, top_p and top_k from requests and to guide behaviour through prompting instead. The same guide adds that temperature = 0 never guaranteed identical outputs on earlier models either.
What this means for your code:
- Do not hard-code sampling parameters across providers. Keep them in per-model config and send them only where the vendor’s API reference says they are accepted.
- Get variety the way the docs recommend: ask for several alternative openings in one request, vary the examples, or regenerate.
- Pin the model version. OpenAI’s text generation guide recommends pinning production apps to a specific model snapshot and building evals, because different snapshots in the same family can respond differently to the same prompt. A voice that drifts after a silent model upgrade is a real bug for a novel halfway through.
Keep a human in the loop
Treat model output as a draft that the author approves, not as finished text. Useful checkpoints:
- The author signs off on the outline before any prose is generated.
- Review findings are shown as suggestions with accept or reject controls, never applied silently.
- Canon updates (new facts about characters, resolved threads) are confirmed before they are saved, because a wrong summary corrupts every later chapter.
- The UI keeps versions of each chapter so the author can roll back.
These checkpoints also matter legally, as the next section shows.
Copyright and disclosure
United States. The Copyright Office’s registration guidance from March 2023 says that when an AI system receives only a prompt and produces a complex written work, the expressive choices are made by the machine, so that material lacks human authorship and has to be disclaimed. A work can still be protected where a person selects or arranges AI material creatively, or modifies it enough, but protection covers only the human contribution. Applicants have a duty to disclose AI-generated content that is more than de minimis, explain what the human contributed, and should not list the AI tool or its vendor as an author. For a writing product, logging who wrote or rewrote which passages makes that statement much easier for your users to prepare.
European Union. Article 50 of the AI Act (Regulation (EU) 2024/1689) requires providers of systems that generate synthetic text, among other media, to mark outputs in a machine-readable way so they can be detected as artificially generated. Deployers that publish AI-generated text to inform the public on matters of public interest must disclose that, unless the text has had human review or editorial control and someone holds editorial responsibility. For deep-fake images, audio or video inside an evidently artistic or fictional work, disclosure is limited to noting that such content exists, without spoiling the work. These duties have applied since 2 August 2026. Providers whose generative systems were already on the market before then have until 2 December 2026 to add the output marking (Article 111(4), as amended by the Digital Omnibus).
None of this is legal advice. If you sell a writing tool, read the primary texts and talk to a lawyer about your market.
An open-source example: InkOS
If you would rather study a working system than build from scratch, InkOS is an AGPL-3.0 project that applies many of these patterns. Its README describes it as an agent system for novels, short fiction, scripts, interactive stories and translation, used through a Studio chat, a CLI or a TUI. It stores structured story state, including current state, pending hooks, chapter summaries and a character matrix, as JSON with readable Markdown copies. A Continuity Auditor checks drafts against that state. It can also import an existing manuscript and rebuild summaries, hooks and character relationships so writing can continue, and it can assign different models and providers to different agents. It installs with npm i -g @actalk/inkos and needs Node.js 22.16 or later. Browse similar projects in the writing and marketing category.
Written by AI Agents Directory
Editorial team
Facts in this guide are checked against official documentation and repositories, which are linked in the article.