Build an Uncensored Prompt Generator With a Text LLM
An uncensored prompt generator is a small program that asks a text model for writing prompts and does not get stopped by refusals on lawful adult themes. This article builds one in under 70 lines of Python: a draft step, a refine step, JSON output and a system prompt you can reuse.

Summary
- The generator is two calls: one drafts prompts from a theme, one tightens them.
- JSON mode keeps the output easy to parse; ask for JSON in the system prompt too.
- Temperature is high for drafting and lower for editing, and a seed makes runs repeatable.
- This is text only and meant for adult authors; sexual content involving minors is never allowed.
What the tool does and what it does not
The target is a writing aid: you type a theme, and you get several prompts you can use as the seed for a scene, a short story or a roleplay setup. Think of premises for adult fiction, villain monologue starters, or opening lines for a companion character. The output is text. No images are generated, and there is no image prompt engineering here.
The reason to use an uncensored model is plain. A model that refuses or lectures on a dark but lawful theme breaks a generator, because the user gets a warning in place of a prompt. This API runs one open-weight model tuned to answer without content refusals for lawful adult use. One hard limit applies: no sexual content involving minors. Your system prompt should state that rule too.
Design: draft, then refine
A single call produces serviceable prompts, but they tend to be generic and similar to one another. Splitting the job in two helps:
- Draft. A high temperature gives variety. The model returns a list of candidate prompts.
- Refine. A lower temperature and an editor persona make each prompt more specific and keep the premise.
Both calls use JSON mode, so the program gets a list it can loop over. Set response_format to {"type": "json_object"} and also describe the JSON shape in the system prompt, since the model needs the instruction as well as the flag.
Setup
Create a key on the API key page. New users can claim $0.50 of trial credit with one click, which is far more than this script needs for testing. Install the SDK and export the key:
pip install openai
export API_KEY="paste-your-key-here"
The endpoint is OpenAI-compatible, so the client only needs the base URL https://api.uncensoredpromptgenerator.com/v1, your key, and the model ID uncensored.
The full script
Save this as promptgen.py. It reads the theme from the command line, runs both steps, prints numbered prompts and shows the token count and cost.
import json
import os
import sys
from openai import OpenAI
client = OpenAI(
base_url="https://api.uncensoredpromptgenerator.com/v1",
api_key=os.environ["API_KEY"],
)
MODEL = "uncensored"
DRAFT_SYSTEM = """You write story prompts for adult authors of fiction.
Turn the theme you are given into the requested number of distinct writing prompts.
Rules:
- Each prompt is two to four sentences and names a character, a conflict and one constraint.
- Keep the author's premise as given. Do not moralize, warn or add disclaimers.
- Never involve minors in sexual content.
- Reply with a JSON object that has one key, "prompts", holding a list of strings."""
REFINE_SYSTEM = """You are a sharp fiction editor.
You receive a JSON object with a "prompts" list. Rewrite each prompt so it is more specific,
has a clearer source of tension and a less predictable opening, without changing the premise.
Keep the same order and the same number of items.
Reply with a JSON object that has one key, "prompts", holding the rewritten list."""
def ask(system, user, temperature):
for attempt in range(2):
resp = client.chat.completions.create(
model=MODEL,
messages=[
{"role": "system", "content": system},
{"role": "user", "content": user},
],
response_format={"type": "json_object"},
temperature=temperature,
)
try:
data = json.loads(resp.choices[0].message.content)
return data["prompts"], resp.usage
except (json.JSONDecodeError, KeyError):
continue
raise RuntimeError("The model did not return valid JSON twice in a row.")
def generate(theme, count=5):
drafts, u1 = ask(DRAFT_SYSTEM, f"Number of prompts: {count}\nTheme: {theme}", 1.0)
final, u2 = ask(REFINE_SYSTEM, json.dumps({"prompts": drafts}), 0.6)
tokens_in = u1.prompt_tokens + u2.prompt_tokens
tokens_out = u1.completion_tokens + u2.completion_tokens
return final, tokens_in, tokens_out
if __name__ == "__main__":
theme = " ".join(sys.argv[1:]) or "a lighthouse keeper who stops trusting the lamp"
prompts, t_in, t_out = generate(theme)
for number, text in enumerate(prompts, start=1):
print(f"{number}. {text}\n")
cost = t_in * 0.15 / 1_000_000 + t_out * 0.50 / 1_000_000
print(f"tokens in/out: {t_in}/{t_out} cost: ${cost:.5f}")
Run it with python promptgen.py "a retired assassin opens a bakery". A few details are worth noticing. The retry loop in ask guards against the rare reply that is not valid JSON. The cost line applies the published prices of $0.15 per 1M input and $0.50 per 1M output tokens to the usage numbers the API returns.
A system prompt template you can adapt
The draft system prompt in the script is a template. The parts that matter, in order of impact:
- Role and audience. "Story prompts for adult authors of fiction" tells the model who reads the result.
- Structure. A character, a conflict and a constraint in every prompt stops vague outputs like "a story about betrayal".
- No lecturing. A direct line telling the model to keep the premise and skip disclaimers saves you from wrapping text you then need to strip.
- Safety rule. State the minors rule explicitly. It makes your tool's behavior predictable for the people using it.
- Output shape. Name the JSON key and its type.
For genre control, add a short style line, such as "Noir tone, short sentences" or "Gothic horror, slow dread", to the user message rather than the system prompt. Then the same system prompt serves every genre.
Tuning the output
Temperature is the main dial. Around 1.0 gives varied drafts; 0.5 to 0.7 suits the editing pass. If you want a run you can reproduce, pass seed as well, since seed, temperature, top_p, stop and the penalties are passed through to the model. Add frequency_penalty if prompts in one batch keep repeating the same words.
To get more variety without more calls, ask for 8 prompts and show the user the best 5, or let the user mark favorites and feed those back as examples in the next draft. Keep the user message short: the theme, the count and a style line is enough.
Streaming is optional here, because each call returns a short JSON object. If you build a web interface, you can stream the draft step to show progress, but parsing JSON is easier once the full reply has arrived.
Cleaning up the output
Even a good generator returns the odd duplicate. After parsing, lowercase the first eight words of every prompt and drop any whose opening matches an earlier one. Drop prompts under a minimum length, and cap the list at the number the user asked for. These few lines of plain code are cheaper and more predictable than asking the model for a third pass.
Where to take it next
Wrap generate in a small web endpoint, store the prompts a user likes, or add a "make this darker" button that calls the refine step again with an extra instruction. Mind the limits: a full key allows 8 concurrent requests and 300 per minute, a trial key 2 and 60. The context window is 100,000 tokens, which leaves room for long style guides in the system prompt.
Pricing is covered on the pricing page, request details are in the docs, and the uncensored AI options comparison helps if you are weighing this approach against others.
Variations worth building
Once the two-step loop works, small changes in the system prompt give you different tools from the same code.
- Scene starters. Ask for an opening line plus a hidden detail the author can reveal later. Useful for roleplay game masters.
- Character seeds. Ask for a name, a want, a flaw and a secret. Four short fields in JSON make it easy to store and reuse them.
- Dialogue hooks. Ask for a single line of dialogue that implies a conflict without explaining it.
- Tone shifts. Feed an existing prompt back with an instruction like "same premise, colder tone". The refine step already does this when you change its system prompt.
To judge quality, keep a list of ten themes and run them after every prompt change. Read the output for three failure modes: prompts that repeat each other, prompts that ignore the constraint you asked for, and replies that slip in warnings. Fix each in the system prompt first, then adjust temperature. A good generator is mostly a good system prompt and a habit of re-running the same ten themes.
More guides
Common queries
Does the generator make images?
No. This API is text only, so the tool creates writing prompts as text. It has no image, audio or video generation.
Why use JSON mode for a prompt generator?
It returns a parseable list in one reply, so your code does not have to split text by hand. Ask for JSON in the system prompt as well as setting response_format.
Is there a rule about what it will write?
The model answers without content refusals for lawful adult use. Sexual content involving minors is never allowed.
Can I run it on the trial credit?
Yes. The $0.50 trial is enough for many runs of this script. Trial keys allow 2 concurrent requests and 60 per minute.
Retrieve your key now
Register, copy the token, update the endpoint URL. Configuration is complete.