EN ▾

Long Stories on a 100k Context LLM API

An LLM API long context story is a piece of fiction written over many calls, where each call has to carry enough of the earlier text to stay consistent. With a 100,000-token window you can hold a lot, but you still need a plan for what goes in.

Updated:

Long scroll passing through a segmented glass tunnel, illustrating a story fitting inside a large context window

Key points

  • The 100,000-token window covers the prompt and the completion together, so the reply shares the space with everything you send.
  • A story bible, a rolling summary and the last chapter usually beat pasting the whole draft every time.
  • Resending full history makes cost grow with every chapter, because each call pays for all earlier text again.
  • Read usage.prompt_tokens from each response and compress before the window fills, not after.

What the window actually holds

Context length is the amount of text the model can look at in a single request. Here it is 100,000 tokens, and that number is shared: everything you send plus everything the model writes back must fit inside it. If your prompt is 90,000 tokens, the answer has at most 10,000 tokens of room.

Tokens are not words. A common rule of thumb for English prose is that one token is about three-quarters of a word, so 100,000 tokens is on the order of 75,000 words. Your real ratio depends on the text, and dialogue, names and unusual spellings usually cost more tokens per word. Treat the rule as a planning estimate and let the usage field in each response tell you the truth.

What does that mean for a story? A short novel of 70,000 to 90,000 words does not fit in one request together with room for a new chapter. A novella does. A serialised web story with 40 chapters certainly does not, if you send every chapter each time. So the window is large enough to remove most small problems and small enough that you still need a method for anything book-length.

The rest of this article is that method: how to divide the space, how to compress what no longer fits, and what each choice costs. The model here is one open-weight model with no content refusals for lawful adult use, reached through an OpenAI-compatible endpoint. The long-context ideas apply to any chat-style model, though, so the planning stays useful.

Budget the window before you write

Decide what goes into each request the way you would plan a page layout. Fixed blocks first, then the space the reply needs, then whatever is left over for history. Here is a plan for a chapter-by-chapter project where each chapter is around 3,000 words, about 4,000 tokens:

BlockTokensPurpose
Story bible in the system message2,000Characters, tone, world rules
Rolling summary of earlier chapters3,000What has happened so far
Previous chapter, verbatim4,000Voice and continuity of prose
Outline for the next chapter500The job for this call
Reserved for the completion6,000Room for the new chapter plus slack
Total15,500Leaves 84,500 tokens unused

The point of the table is the last row. A disciplined plan uses about one sixth of the window, and the other five sixths is a reserve you can spend on things that help: more verbatim chapters, longer character sheets, a list of open plot threads, or a style sample from an author you admire (your own earlier writing works too).

Put the stable material first and the changing material last. The bible does not change between calls, so it sits at the top of the system message. The outline for this chapter changes every time, so it goes at the end of the user message, where the model weighs it most. Models tend to pay less attention to the middle of a very long prompt than to its start and end, so test with your own story before you rely on a fact buried in the middle.

Three ways to feed a growing story

Full history

Append every chapter to the conversation and send it all. This is the easiest to build and gives the model perfect recall of the text, until the window fills. Cost per call rises with each chapter, as shown in the next section.

Rolling summary

Keep a compact summary of everything before the last chapter, and update it after each one. Calls stay the same size forever. The price is lossy memory: if the summary leaves out a throwaway line that matters in chapter 20, the model will not know it.

Hybrid

Pin the bible, keep a rolling summary for the distant past, and include the last two or three chapters verbatim. Add a short list of open threads: promises made, secrets kept, objects that have not yet been used. For most fiction this is the best balance, and it is the shape the table above describes.

MethodRecall of old textSize per callMain risk
Full historyExactGrows each chapterHits the 100,000-token limit
Rolling summaryPartialConstantDropped details
HybridExact for recent, partial for oldRoughly constantSummary drift

What resending history costs

Price is $0.15 per 1M input tokens and $0.50 per 1M output tokens, so input is cheap, but resending it each call adds up through repetition. Take 20 chapters of 4,000 tokens each. Assume a 1,000-token base prompt (bible and outline) plus every earlier chapter.

With full history, chapter n sends 1,000 + 4,000 × (n − 1) input tokens. Summed over 20 chapters that is 20 × 1,000 + 4,000 × (0 + 1 + ... + 19) = 20,000 + 4,000 × 190 = 780,000 input tokens. At $0.15 per 1M that is $0.117. Output is 20 × 4,000 = 80,000 tokens, which is $0.04. Total: $0.157. The last chapter's prompt is 77,000 tokens, plus 4,000 for its reply, so it still fits in 100,000.

With a rolling summary, each call sends about 6,000 input tokens (bible, summary, the last chapter, outline). That is 120,000 input tokens over 20 chapters, or $0.018, plus the same $0.04 for output. Total: $0.058.

So the hybrid method costs about a third as much here, and the gap widens with every extra chapter, because the full-history cost grows with the square of the chapter count. At 25 chapters the last prompt alone would be 97,000 tokens, which leaves under 3,000 tokens for the reply. That is the real ceiling. Money is rarely the problem on this pricing; the window is.

The pricing page lists the top-up options if you want to size a budget for a larger project. Failed or refused requests are not charged.

A loop that watches the window

Do not guess how full the window is. Every non-streamed response includes usage.prompt_tokens, and streamed responses report usage at the end. Use it as the trigger for compression. The snippet below keeps the conversation as a list, and when the prompt crosses 60,000 tokens it replaces the oldest chapters with a summary.

from openai import OpenAI

client = OpenAI(base_url="https://api.unfilteredstory.top/v1", api_key="YOUR_API_KEY")

SYSTEM = open("bible.md", encoding="utf-8").read()
chapters = []        # full text of each finished chapter
summary = ""         # compressed memory of the oldest chapters
LIMIT = 60000        # compress when the prompt grows past this

def build_messages(outline):
    recent = "\n\n".join(chapters[-3:])
    body = "Summary of earlier events:\n" + summary + "\n\nRecent chapters:\n" + recent
    body += "\n\nWrite the next chapter, about 3,000 words. Outline: " + outline
    return [
        {"role": "system", "content": SYSTEM},
        {"role": "user", "content": body},
    ]

def next_chapter(outline):
    global summary, chapters
    r = client.chat.completions.create(
        model="uncensored",
        messages=build_messages(outline),
        temperature=0.85,
        max_tokens=6000,
    )
    chapters.append(r.choices[0].message.content)
    print("prompt tokens:", r.usage.prompt_tokens, "completion:", r.usage.completion_tokens)

    if r.usage.prompt_tokens > LIMIT and len(chapters) > 3:
        old = chapters[:-3]
        s = client.chat.completions.create(
            model="uncensored",
            temperature=0.2,
            messages=[
                {"role": "system", "content": "Write a factual continuity summary, under 600 words. Keep names, places, injuries, promises and unresolved questions."},
                {"role": "user", "content": "Previous summary:\n" + summary + "\n\nChapters to fold in:\n" + "\n\n".join(old)},
            ],
        )
        summary = s.choices[0].message.content
        chapters = chapters[-3:]
    return chapters[-1]

The code folds old chapters into the summary and keeps only the last three. If a chapter fails with a 429, wait five seconds when the Retry-After header says so, and try again. A full key allows 8 concurrent requests, so a single sequential writer is nowhere near the limit.

Keeping the story consistent

A big window does not guarantee a consistent story. These are the problems you will actually meet, and what helps:

  • Names and details drift. A character's eye colour changes or a scar moves to the other arm. Keep a short fact sheet in the bible and repeat the three most important facts at the end of the prompt.
  • Repetition. The model reuses favourite images and sentence openings across chapters. The penalty parameters are passed through, so try a small frequency_penalty or presence_penalty, and add a list of phrases to avoid to the bible.
  • Forgotten threads. A promise from chapter 3 never pays off. Maintain a list of open threads and update it after each chapter; show it to the model with the outline.
  • Style creep. After many generations the prose slides toward a bland average. Include a 300-word sample of the target voice and tell the model to match it.
  • Cut-off endings. If you set max_tokens too low, a chapter stops mid-sentence. Leave generous room, or omit the field.

Lower temperature (0.6 to 0.8) gives steadier continuity; higher values give more surprising prose and more contradictions. Passing a seed makes comparisons between prompt variants fairer, since you change one thing at a time.

Finally, read the output. A summary written by a model is a draft written by a model. Spend two minutes a chapter checking it against the text, and you will avoid hours of repair later.

Where this API fits

For writers building their own tools, the combination is simple: an OpenAI-compatible endpoint, a 100,000-token window, streaming for live output, JSON mode for extracting state, and tool calling if you want the model to fetch character files on demand. The model is tuned to avoid content refusals for lawful adult use. Sexual content involving minors is a hard limit. The service is text only, so covers and illustrations have to come from elsewhere.

If you are new, start with the quickstart docs for the request format and the full list of parameters, and read the integration guide if you plan to connect an existing client. To try the budget plan above, create an account and claim the trial from the API key page: it is $0.50 of credit, valid for 7 days, no card needed.

Start with the hybrid method and a bible of under 1,500 words. Log prompt_tokens for every call. After three or four chapters you will see how your own text behaves, and you can adjust the plan from numbers instead of guesses.

Questions and answers

How many words fit in a 100k context window?

As a rough guide, 100,000 tokens is about 75,000 English words. The window also has to hold the model's reply, so the usable prompt is smaller.

Does the output count against the context window?

Yes. Prompt plus completion must fit in 100,000 tokens. A 90,000-token prompt leaves at most 10,000 tokens for the answer.

Is it better to send the whole story or a summary?

For short projects the whole text is fine. For anything longer, a bible plus a rolling summary plus the last few chapters costs less and keeps each call predictable.

How do I see how many tokens I used?

Each response includes a usage object with prompt and completion token counts. The X-Balance-USD response header shows your remaining credit.

Can I set a limit on the length of a chapter?

Yes, with max_tokens. It is optional; if you leave it out, the completion may use whatever space remains in the window.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key