AI Roleplay with Images: What a Text API Can Do
For ai roleplay with images, know first that this API returns text only, so it cannot draw. It can run the roleplay and write the image prompts, which a separate image tool then turns into pictures.
Updated

Key points
- The API is text in, text out: no image, audio or video generation.
- The usual pattern is two steps: the model writes the scene and an image prompt, another tool renders it.
- JSON mode keeps the image prompt separate from the story text for easy parsing.
- Text-only calls stay cheap, so adding image prompts costs little.
What is possible and what is not
People who search for this usually picture one product that chats in character and also shows pictures of the scene. That is two jobs, and this API does one of them. It handles the roleplay itself, the dialogue, narration and character voice. It does not produce pictures, and no parameter will make it do so.
What it can do is bridge the gap. A language model is good at describing a scene in precise visual language: who is present, the setting, the light, the camera angle, the mood. That description is exactly what an image generator needs as input. So the practical design is a pipeline: your app chats with the model, the model also emits an image prompt, and an image service of your choice renders it.
The model here is uncensored, one open-weight model tuned to answer without content refusals for lawful adult use. For companion and roleplay apps that matters, because a character that suddenly breaks the fiction ruins the experience. The hard limit stays in place: no sexual content involving minors, in text or in image prompts.
The two-step pattern
Think of each user turn as producing two outputs from one model call.
- Story text. The in-character reply the user reads.
- Image prompt. A short, visual description of the current moment, written for an image model rather than a human reader.
Your app shows the story text immediately. It sends the image prompt to whichever generator you use, and displays the picture when it arrives. Keeping the two outputs separate means the user never reads prompt jargon inside the story, and the image tool never sees dialogue it cannot use.
You can also generate images only on demand, for example when the user presses a button, or only when the scene changes. That cuts image costs and keeps the chat fast. The text call itself is cheap, which the cost section below works out.
Getting both outputs in one call
JSON mode is the cleanest way to separate them. Ask the model for an object with two fields and set response_format to json_object. Mention the word JSON and the field names in the system message so the model knows the shape.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredaiimage.cc/v1", api_key="YOUR_KEY")
system = (
"You are the narrator of an adult fantasy roleplay. Stay in character. "
"Reply only with JSON using the keys 'reply' (the in-character text, "
"2 to 4 sentences) and 'image_prompt' (one visual sentence describing "
"the current scene: setting, lighting, characters, mood)."
)
history = [
{"role": "system", "content": system},
{"role": "user", "content": "I push open the tavern door and scan the room."},
]
resp = client.chat.completions.create(
model="uncensored",
messages=history,
response_format={"type": "json_object"},
temperature=0.9,
)
data = json.loads(resp.choices[0].message.content)
print(data["reply"])
print("IMAGE PROMPT:", data["image_prompt"])
Always wrap json.loads in a try block. Models occasionally return a malformed object, especially on long outputs, and your app should fall back to showing the text or retrying once. Because failed or refused requests are not charged, a retry on a bad response costs you nothing for the failed attempt.
Keeping characters visually consistent
The hard part of pairing chat with pictures is consistency. If the image prompt says "a woman with dark hair" on turn one and "a brunette in a green cloak" on turn nine, the generated faces and clothes will drift. Two habits fix most of it.
Keep a character sheet
Store a fixed visual description for each character: hair, build, clothing, distinguishing marks. Put it in the system message and tell the model to copy those traits verbatim into every image prompt. The model is good at repeating a block of text exactly when told to.
Separate the scene from the subject
Ask for the image prompt in two labeled parts, the fixed subject and the changing scene, then join them in your own code. That way the subject text never mutates, and only the setting and action vary.
A third option is to pass a seed. The API passes seed through to the model, which helps make text output more repeatable while you test prompts, though it does not control your image generator. Seed behavior on the image side depends on that tool.
Streaming the story while the image loads
For a responsive feel, stream the reply and fire the image request as soon as you have the prompt. If you want streaming and a separate image prompt, make two calls: a streamed one for the story and a small non-streamed one for the prompt. Streaming uses server-sent events and reports usage at the end.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.uncensoredaiimage.cc/v1", apiKey: process.env.API_KEY });
const stream = await client.chat.completions.create({
model: "uncensored",
stream: true,
messages: [
{ role: "system", content: "You are a dry-witted ship's AI in a space-opera roleplay." },
{ role: "user", content: "Status report, please." },
],
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
Remember that a streamed request holds its concurrency slot until the stream ends. A full key allows 8 requests at once, so an app with many simultaneous players should queue image-prompt calls and not open them all together. If you hit the concurrency error, wait and retry. A 429 with a Retry-After: 5 header means temporary overload, and five seconds is the right pause.
What this costs per scene
Text is the cheap part of the pipeline. Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Take a roleplay turn with 3,000 input tokens (system message, character sheet and recent history) and 400 output tokens (story plus image prompt).
- Input: 3,000 × $0.15 / 1,000,000 = $0.00045
- Output: 400 × $0.50 / 1,000,000 = $0.0002
- Total per turn: $0.00065
A 100-turn session therefore costs about $0.065 in text. The image generator will almost certainly cost more than the chat does, so it is worth rendering images only when the scene changes. Check your image provider's current pricing. For the text side, see the pricing page, and note that crypto top-ups start at $20, with credit that never expires.
Pitfalls and how to avoid them
A few problems come up again and again once roleplay and image generation share a pipeline.
Prompts that are too long. Image tools tend to follow a focused sentence better than a paragraph. Tell the model to keep the image prompt to one sentence of visual facts and to leave out dialogue, backstory and feelings that a camera could not show.
Prompts that describe the wrong moment. The model sometimes describes where the story is heading and not where it is now. Add a line such as "describe the scene exactly as it stands at the end of your reply" to the system message.
Mixed-up history. If you store the full JSON reply in the chat history, the model starts copying the format in odd ways. Store only the story text as the assistant message and keep the image prompt in your own database.
Rules for your own app. The model will not refuse lawful adult material, so your product needs its own policy for what users may request and what you send on to an image service. The minors rule applies without exception, and image providers usually have rules of their own that you should read.
Related media pipelines and next steps
The same idea of text driving another model applies to video. Our page on Veo 3 API myths and facts covers how text prompts feed video pipelines and what to expect from them.
To build the chat half, read the API quickstart for headers, limits and error codes, then get an API key. New accounts can claim a $0.50 trial credit with one click, valid for 7 days and without payment details, which covers several hundred turns of the example above. Prompts are not used for training.
More guides
Questions and answers
Can this API generate images for my roleplay?
No. It returns text only. It can write detailed image prompts that you send to a separate image generator.
How do I get the story and the image prompt together?
Use JSON mode with a system message that asks for two keys, such as reply and image_prompt, and parse the result in your code.
Will the character look the same in every picture?
Not automatically. Store a fixed visual description and have the model copy it into every image prompt, then check how your image tool handles consistency.
Is there a content restriction on the prompts?
The model is tuned for lawful adult use without content refusals. Sexual content involving minors is never allowed, in story text or in image prompts.
Does a roleplay session cost much?
The text side is inexpensive: about $0.00065 for a turn with 3,000 input and 400 output tokens, or roughly $0.065 for 100 such turns.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.