Game or client: pick by what you want to control
AI Dungeon is a well-known text adventure game that runs in the browser and on phones. If you want to open an app and play, a finished game is the easier path, and nothing here replaces that. Check each service's current features, plans and content rules on its own site before you decide.
A custom client makes sense when you want something a game does not give you: your own system prompt and story rules, a fixed world with named characters, an interface shaped for one genre, or the freedom to wire the model into a Discord bot, a site or a writing tool. You also pay per token rather than a flat plan, which suits light and bursty use.
| Finished game | Your own client on an API | |
|---|---|---|
| Setup | Sign up and play | Write about 60 lines of code |
| Prompt control | Limited to what the app exposes | Full: system prompt, memory, sampling |
| Interface | Fixed | Anything: terminal, web, bot |
| Community and shared scenarios | Built in | You build it or go without |
| Cost model | Check their current plans | Per token from prepaid credit |
This site offers the API side: one open-weight model, OpenAI-compatible, tuned to answer without content refusals for lawful adult fiction. Sexual content involving minors is never allowed.
The smallest story client
A text adventure needs only a loop: read the player's action, send the story so far, print the continuation. Get a key from the API key page and set it as an environment variable.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.unfilteredstory.cc/v1", api_key=os.environ["STORY_KEY"])
SYSTEM = (
"You are the narrator of an interactive text adventure. "
"Write in second person, present tense, 80 to 150 words per reply. "
"Describe results of the player's action and end with an open moment. "
"Never decide the player's actions or thoughts."
)
story = [{"role": "system", "content": SYSTEM},
{"role": "assistant", "content": "You wake on a salt-crusted dock. A lantern swings above you."}]
print(story[-1]["content"])
while True:
action = input("\n> ").strip()
if action in ("quit", "exit"):
break
story.append({"role": "user", "content": action})
stream = client.chat.completions.create(
model="uncensored", messages=story, temperature=0.9, stream=True,
)
parts = []
for chunk in stream:
piece = chunk.choices[0].delta.content or ""
parts.append(piece)
print(piece, end="", flush=True)
print()
story.append({"role": "assistant", "content": "".join(parts)})
That is a playable adventure. Streaming makes it feel alive, because text appears as it is written. Everything else in this article improves on this loop.
Memory: keep a long story coherent
Early text games forget details quickly. With a 100,000-token window you have far more room. A typical reply is 150 to 250 tokens, so even 300 turns is around 60,000 tokens, which fits. Still, a good client treats memory in layers.
- Story rules (system message): genre, tone, what the narrator never does.
- World notes: a short list of places, factions and named characters. The player or the author edits it.
- Running summary: key events as one-line facts, updated every 20 turns by a separate call.
- Recent turns: the last 20 to 40 messages in full.
- Author's note: one line added near the end of the prompt, such as "Keep the mood tense; the storm is getting worse." Instructions placed near the end affect the next reply most.
Build the message list from these layers on every request. A reader can find more on handling long stories in the guide to the best AI for writing unfiltered stories, and the page on unlimited roleplay covers character-driven play.
Features worth adding next
Once the loop works, the improvements are small and local.
Undo and retry
Store each exchange. "Retry" removes the last assistant message and calls again, ideally with a slightly different temperature. "Undo" removes both messages. These two commands are the features players use most.
Save and load
Write the message list to a JSON file after every turn. Reloading the file restores the exact story, and you can share it.
Modes
Keep a small table of prompt snippets: "do" (the player acts), "say" (the player speaks), "story" (the player writes narration directly). Each mode wraps the input differently before sending.
Presets
Offer a few starter prompts per genre. Ship them as text files; players can add their own.
For a hosted chatbot-style setup rather than a game loop, see the unfiltered chatbot API page.
What a session costs
Prices are $0.15 per 1M input tokens and $0.50 per 1M output tokens. In a story client the input grows as the story grows, so use a mid-story turn for the estimate: 4,000 tokens sent and 250 tokens received.
- Input: 4,000 / 1,000,000 x $0.15 = $0.0006
- Output: 250 / 1,000,000 x $0.50 = $0.000125
- Turn total: $0.000725
One hundred turns at that size cost $0.0725, a bit over seven cents. Early turns are cheaper and late ones in a long adventure cost more, so treat this as a middle value. Failed or refused requests are not charged. Credit is prepaid, never expires, and has no subscription; top-ups are any whole amount from $20 to $500, paid by crypto (USDT on TRC20, USDC on Base). Bonuses add 5% from $50, 10% from $100 and 15% from $200. Full details are on the pricing page.
Put it on the web without leaking your key
A browser page must never hold your API key. Put a thin server between the page and the API. It adds the key, forwards the story and streams the answer back. This sketch uses Node and Express.
import express from "express";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.unfilteredstory.cc/v1",
apiKey: process.env.STORY_KEY,
});
const app = express();
app.use(express.json({ limit: "1mb" }));
app.post("/turn", async (req, res) => {
res.setHeader("Content-Type", "text/event-stream");
const stream = await client.chat.completions.create({
model: "uncensored",
stream: true,
temperature: 0.9,
messages: req.body.messages,
});
for await (const chunk of stream) {
const piece = chunk.choices[0]?.delta?.content ?? "";
res.write("data: " + JSON.stringify(piece) + "\n\n");
}
res.end();
});
app.listen(3000);
Two habits keep this safe. Limit how many requests one visitor can send per minute, since your single key shares the 8 concurrent slots among all visitors. And cap the size of the message list the page may send, so nobody can push huge prompts through your credit. If you serve more than a handful of players at once, queue requests and show a short waiting message when the API answers 429 with a Retry-After: 5 header.
Limits and what this setup cannot do
Be clear about the limits before you commit.
- Text only. No images, audio or video generation, no embeddings.
- One model. An open-weight model run by an independent provider. It is not the same model as any particular game and not an official product of any model maker.
- Rate limits. A full key allows 8 concurrent requests and 300 per minute. A trial key allows 2 and 60. A streamed request holds its slot until the stream ends. Over a limit you get HTTP 429 with the code
rate_limitedorconcurrency. - No built-in game features. Memory, save files, worlds and community are yours to build.
If you only want to play, a finished game is simpler. If you want to build or customize, the client above is a good base. The documentation has the parameter list, including tools and JSON mode if you later want the narrator to return structured state like inventory or health.

