Qwen Uncensored Workflow: Automate with an OpenAI API
A qwen uncensored workflow is a chain of model calls that runs without you babysitting each one. This page builds one in Python against an OpenAI-compatible endpoint, from the first outline to a JSON summary of each result.

Key points
- Any OpenAI SDK or workflow tool that accepts a custom base URL can drive the API: set the base URL and the key, and use the model ID uncensored.
- Split a job into small stages (outline, draft, extract) and use JSON mode for the stages whose output a program reads.
- Run up to 8 requests at once on a full key; the batch example costs $0.29 for 200 chapters.
- Log token usage per stage so you can compute costs from $0.15 per 1M input and $0.50 per 1M output tokens.
What the workflow looks like
Most automated writing and roleplay pipelines have the same skeleton. A planning step turns a short brief into a structure. A drafting step produces the long text, one piece at a time. A checking or extraction step reads each piece and records facts a later step needs. Each stage is a plain chat completion call with its own prompt, and the stages pass text or JSON to one another.
The reason to separate stages instead of writing one giant prompt is control. A long prompt that asks for an outline, a draft and a summary in one go produces results that are hard to test and expensive to redo. Three small calls let you rerun only the part that went wrong, use a low temperature for the extraction and a higher one for the drafting, and measure the cost of each part.
The service in question is a hosted, OpenAI-compatible text API. The model is an open-weight model run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not the official API of any vendor. The base URL is https://api.qwenuncensored.com/v1, the model ID is uncensored, and the key goes in an Authorization: Bearer header. The quickstart covers the very first request if you want to see one before building the pipeline.
Connecting your tools
Because the endpoint follows the OpenAI format, you do not need a special connector. Anything that lets you set a custom base URL will work: the official OpenAI SDKs for Python and Node, LangChain and LlamaIndex chat model classes, and automation tools such as n8n, which allows a custom base URL in its OpenAI credentials. Check the current settings screen of your tool, since labels differ between versions.
The three values are always the same:
- Base URL:
https://api.qwenuncensored.com/v1 - API key: the key you create on the key page
- Model:
uncensored
In Node, the setup looks like this:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.qwenuncensored.com/v1",
apiKey: process.env.API_KEY,
});
const res = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Outline a three-chapter adult fantasy story." }],
});
console.log(res.choices[0].message.content);Keep the key in an environment variable or in the credential store of your automation tool, not in the workflow definition itself, so you can share or export the workflow without exposing it.
Stage one: plan with JSON mode
The planning stage is the first place JSON mode pays off. A program has to read the outline, so you want valid JSON every time. Set response_format to {"type": "json_object"} and describe the keys in the system message.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenuncensored.com/v1", api_key="YOUR_KEY")
def plan(brief, chapters=5):
r = client.chat.completions.create(
model="uncensored",
temperature=0.7,
response_format={"type": "json_object"},
messages=[
{"role": "system", "content":
"You plan serial fiction for adult readers. Reply with a JSON object: "
"{\"title\": string, \"chapters\": [{\"n\": integer, \"summary\": string}]}."},
{"role": "user", "content": f"Brief: {brief}. Plan {chapters} chapters."},
],
)
return json.loads(r.choices[0].message.content)
outline = plan("A smuggler and a disgraced court mage share a cursed ship.")
print(outline["title"], len(outline["chapters"]))JSON mode guarantees valid JSON syntax, but it does not guarantee that your keys appear. Validate the result: check that chapters is a list and that every item has the fields you need, and retry once with a stricter prompt if it does not. A failed or refused request is not charged, which keeps retries cheap.
Stage two: draft in parallel
Drafting is the expensive stage, and it is also where the workflow gains the most from running calls at once. A full key allows 8 concurrent requests and 300 per minute, so a thread pool of 8 workers keeps the key busy without hitting the concurrency error. A trial key allows 2 concurrent requests and 60 per minute, so use 2 workers while you test.
Each chapter call receives the shared context (title, the whole outline) plus its own summary. Passing the full outline into every call keeps the chapters consistent without needing the previous chapter's text.
from concurrent.futures import ThreadPoolExecutor
def draft(chapter, outline):
context = "\n".join(f"{c['n']}. {c['summary']}" for c in outline["chapters"])
r = client.chat.completions.create(
model="uncensored",
temperature=0.9,
max_tokens=1500,
messages=[
{"role": "system", "content":
"You write chapters of adult fiction. Keep the tone consistent with the outline."},
{"role": "user", "content":
f"Title: {outline['title']}\nOutline:\n{context}\n\n"
f"Write chapter {chapter['n']}: {chapter['summary']}"},
],
)
return {
"n": chapter["n"],
"text": r.choices[0].message.content,
"usage": (r.usage.prompt_tokens, r.usage.completion_tokens),
}
with ThreadPoolExecutor(max_workers=8) as pool:
chapters = list(pool.map(lambda ch: draft(ch, outline), outline["chapters"]))If a worker meets a 429, wait and retry. The code that does this correctly is the same for every pipeline: honor Retry-After when it is present, and otherwise back off with a short random delay. The SDKs retry a few times by default, which is enough for light use.
Stage three: extract facts for continuity
The third stage reads each finished chapter and records structured facts: who appeared, what changed, what the next chapter must remember. Use a low temperature, because you want the same facts each time you run the stage.
def extract(chapter_text):
r = client.chat.completions.create(
model="uncensored",
temperature=0.1,
response_format={"type": "json_object"},
messages=[
{"role": "system", "content":
"Return JSON with keys characters (list of names), events (list of short strings) "
"and open_threads (list of short strings)."},
{"role": "user", "content": chapter_text},
],
)
return json.loads(r.choices[0].message.content)
facts = [extract(ch["text"]) for ch in chapters]You can store these facts in a file or database and feed them back into later runs, so a series that spans weeks keeps its continuity. The model has a 100,000-token context window, so for most projects you can also paste the full text of several chapters into one call. The extraction record becomes more useful as the story grows and the full text no longer fits comfortably.
If you want the model to trigger actions of its own, such as saving the facts to your database, tool calling is available through the tools parameter, and streamed responses use stream: true with server-sent events.
What a batch costs
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, so every stage can be costed from the usage numbers. Suppose each chapter call sends 3,000 tokens in (system message, outline and summary) and gets 2,000 tokens back. The math for one chapter is:
- Input: 3,000 x $0.15 / 1,000,000 = $0.00045
- Output: 2,000 x $0.50 / 1,000,000 = $0.001
- One chapter: $0.00145
For a batch of 200 chapters that is 200 x $0.00145 = $0.29. The extraction pass adds a little more. If each chapter text of 2,000 tokens is read again with 300 tokens returned, that is $0.0003 for input plus $0.00015 for output, or $0.00045 per chapter, which comes to $0.09 for 200 chapters. The whole batch of drafting and extraction is $0.38.
The numbers are examples built on assumed token counts, so run a few real calls and read usage from the responses to get your own figures. The X-Balance-USD response header shows the remaining credit after every call, which makes a handy check on the budget while a long job runs. The pricing page lists top-ups from $20 to $500 with bonuses of 5% from $50, 10% from $100 and 15% from $200. You can pay with crypto (USDT on TRC20, USDC on Base), and credit does not expire.
Keeping a workflow reliable
A pipeline that runs unattended needs a few habits that save you from surprises.
- Save every stage's output. Write the plan, each draft and each fact record to disk as soon as it exists. If a run stops at chapter 140, you restart at 141.
- Set timeouts. A request that hangs holds a concurrency slot. Pass a timeout to the client so a stuck call fails and gets retried.
- Log request IDs. Each response carries
X-Request-Id. Store it next to the output so you can point to a specific call if you ask for help. - Use a seed for tests. The
seedparameter is passed through, which helps when you compare two versions of a prompt on the same input. - Set your content boundaries in the prompt. The model is tuned for lawful adult use, and the one hard limit is that sexual content involving minors is not allowed.
If you are choosing between uncensored services, the page that compares Uncensored Grok and Qwen Uncensored sets out the differences. For prompt privacy: prompts sent to this API are not used for training.
When you are ready, claim the $0.50 trial credit with one click on your key page after signing up. It lasts 7 days, needs no card and is limited to one per person, which is enough to run the five-chapter plan above several times.
More guides
Questions and answers
Which tools can run a qwen uncensored workflow against this API?
Any client that lets you set a custom OpenAI base URL: the OpenAI SDKs, LangChain, LlamaIndex, or automation tools with a custom base URL field. Use the model ID uncensored and your API key.
How many calls can my workflow run in parallel?
A full key allows 8 concurrent requests and 300 per minute. A trial key allows 2 concurrent and 60 per minute.
Can I get structured output for the next step?
Yes. Use JSON mode with response_format set to json_object, or tool calling with the tools parameter. Validate the keys you need before using the result.
How do I estimate the cost of a batch?
Multiply input tokens by $0.15 and output tokens by $0.50, each divided by 1,000,000. The usage field in every response gives the token counts.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.