EN ▾
Get API key

Uncensored AIHow to Use an AI Image API

AI Roleplay No Download: Build a Hosted Web App

AI roleplay no download is possible because the model runs on a hosted API, not on the player's machine. You build a small web app, your server calls the API, and the browser only shows text. This guide covers the architecture, code, memory and costs.

Updated

Browser window styled as a stage with speech bubbles and masks, linked to cloud servers for hosted AI roleplay

01Uncensored AI

Key points

  1. Text APIs handle prompt construction, script writing, and metadata extraction independently of image generation models.

  2. OpenAI-compatible endpoints allow direct integration using standard SDKs without custom protocol development.

  3. Streaming support enables real-time token delivery, essential for interactive prompt refinement workflows.

  4. Token pricing is usage-based, with specific limits on context windows and request rates.

Why hosted beats a local install for roleplay

Running a roleplay model on your own computer means a download of several gigabytes, a GPU with enough memory, a front end to install and a configuration to keep alive. That is fine for hobbyists who enjoy it. It is a poor fit for a product. Your players want to open a link, pick a character and start typing. A hosted API gives you that: the heavy part lives on someone else's hardware, and your app is a thin web layer.

The service here is a text-only, OpenAI-compatible chat API serving one open-weight model under the ID uncensored. It is run by an independent provider and tuned to answer without content refusals for lawful adult use, which matters for fiction where villains act like villains and relationships get complicated. It does not generate images or audio, and it has one hard limit: no sexual content involving minors.

The trade-off is plain. With a local install your data never leaves your machine and you pay no per-token fee. With a hosted API you depend on a network call and pay per use. The price is low: $0.15 per 1M input tokens and $0.50 per 1M output tokens, and prompts are not used for training.

The architecture in one picture

You need three parts, and only one of them is yours to write.

  1. Browser page. A text box, a message list and a button. Plain HTML and a few lines of JavaScript are enough.
  2. Your server. A single endpoint such as /chat. It holds the API key, adds the character prompt and calls the model.
  3. The API. Receives chat-completions requests at https://api.uncensoredaiimage.com/v1 and returns text.

Never call the API directly from browser code. Anything in a page is visible to every visitor, including your key, and a leaked key lets strangers spend your credit. The server also gives you one place to apply your own rules: age gates, content notes, rate limits per visitor and logging.

Get your key on the API key page. A new account can claim $0.50 of trial credit with one click, valid for 7 days, one per person, which is enough to build and test everything below.

Server code: a streaming chat endpoint

This Node example uses Express and the official OpenAI package. It accepts the conversation from the browser, prepends the persona, asks the model for a streamed reply and forwards the text as server-sent events.

import express from "express";
import OpenAI from "openai";

const app = express();
app.use(express.json({ limit: "1mb" }));
app.use(express.static("public"));

const ai = new OpenAI({
  baseURL: "https://api.uncensoredaiimage.com/v1",
  apiKey: process.env.API_KEY,
});

const PERSONA = `You are Mara, a sardonic ship captain in a fantasy sea adventure.
Stay in character. Write in second person, 80 to 150 words per reply.
Never break the story to explain yourself.`;

app.post("/chat", async (req, res) => {
  const history = (req.body.messages || []).slice(-20);
  res.setHeader("Content-Type", "text/event-stream");
  res.setHeader("Cache-Control", "no-cache");

  try {
    const stream = await ai.chat.completions.create({
      model: "uncensored",
      stream: true,
      temperature: 0.9,
      max_tokens: 400,
      messages: [{ role: "system", content: PERSONA }, ...history],
    });
    for await (const part of stream) {
      const text = part.choices[0]?.delta?.content;
      if (text) res.write(`data: ${JSON.stringify(text)}\n\n`);
    }
  } catch (err) {
    res.write(`data: ${JSON.stringify("[The story stalls for a moment. Try again.]")}\n\n`);
  }
  res.end();
});

app.listen(3000);

The server trims the history to the last 20 messages, so a stranger cannot send a huge payload and run up your bill. The max_tokens value is optional on this API, but a cap keeps replies at a readable length and the cost predictable.

The browser side

The page posts the conversation and reads the stream as it arrives, appending text to the last message. Using fetch with a reader works in current browsers and needs no library.

const log = [];

async function send(userText, outputEl) {
  log.push({ role: "user", content: userText });
  const res = await fetch("/chat", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ messages: log }),
  });
  const reader = res.body.getReader();
  const decoder = new TextDecoder();
  let reply = "";
  let buffer = "";
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    buffer += decoder.decode(value, { stream: true });
    const events = buffer.split("\n\n");
    buffer = events.pop();
    for (const e of events) {
      if (e.startsWith("data: ")) {
        reply += JSON.parse(e.slice(6));
        outputEl.textContent = reply;
      }
    }
  }
  log.push({ role: "assistant", content: reply });
}

Use textContent, not innerHTML, when you show model output. It prevents the reply from injecting markup into your page. Add a stop button using AbortController, so a player can cut off a reply that goes the wrong way and spend fewer output tokens.

Make the character feel consistent

Roleplay quality depends mostly on the prompt and the memory you build around the model. The API is stateless, so every request must carry what the model should know.

Write a tight persona

Name the character, describe the voice in a sentence, give the setting, set the length of replies, and list two or three hard rules for the story. Add a short sample of the character speaking. Models imitate samples well, and a good sample fixes tone better than a paragraph of adjectives.

Handle long stories

The context window is 100,000 tokens, prompt plus completion, so a long adventure can fit in one request. But resending everything on every turn raises the bill. A better pattern is to keep the last 20 messages verbatim and store a running summary of everything older. Every 15 turns or so, ask the model to update that summary in a separate call, then place it in the system prompt under a heading such as "Story so far".

Test with your own scripted conversation before real players arrive. Write ten player messages that probe the edges: a very short input, a very long one, a request that tries to make the character leave its role, and a few that push the plot somewhere dark but lawful. Read the replies for drift. If the character forgets its voice after 15 turns, shorten the history window or move more of the persona into the system prompt. If replies run long, lower max_tokens and say the target length in words. Small prompt edits are cheap to try, since each test run costs a fraction of a cent.

Let players steer

Expose temperature as a slider labelled something friendly such as "wildness", and let users regenerate a reply. The seed field is available if you want a reply to be repeatable. Passing stop sequences is useful if you run a script-style format with speaker labels, as it cuts the model off before it writes the player's next line.

Limits and rules for a public app

A full key allows 8 concurrent requests and 300 requests per minute, and a trial key allows 2 and 60. Because every streamed reply holds a concurrency slot until it finishes, 8 players generating at once is the ceiling for one key. In practice, people read and type between turns, so a key can serve many more people than 8 in a session. Still, queue requests on your server and retry on HTTP 429. The error code concurrency means too many at once and rate_limited means too many per minute. On temporary overload a Retry-After: 5 header appears, so wait that long.

Think about your audience before you launch. Roleplay with an unfiltered model is meant for adults. Put an age confirmation in front of the app, state in the interface what the content may include, and give players a way to leave or change the scene. Do not allow any scenario involving minors in a sexual context. The API refuses it, and your app should block it before the request is made.

Also write a privacy note. The API provider does not use prompts for training, but your own server logs and database are your responsibility. If you do not need to store chats, do not. The quickstart lists request fields and limits.

What a roleplay session costs

Take a 40-turn session. Early turns are small and later ones carry more history, so use an average of 3,000 input tokens per turn, with replies around 250 tokens.

  • Input: 40 x 3,000 = 120,000 tokens. At $0.15 per 1M that is $0.018.
  • Output: 40 x 250 = 10,000 tokens. At $0.50 per 1M that is $0.005.
  • Total: $0.023 per session.

So 1,000 sessions of that size cost $23. With the summary pattern from above, which holds input near 2,000 tokens, the input line falls to $0.012 and the total to $0.017. Credit is prepaid, so there is no surprise invoice, and failed or refused requests are not charged.

Top-ups are any whole amount from $20 to $500, with a 5% bonus from $50, 10% from $100 and 15% from $200. Payment is in crypto: USDT on TRC20 or USDC on Base. Credit never expires, which suits a side project that has quiet weeks. The pricing page has the current table. For a free-to-play app, divide your expected daily sessions by the cost above to set a daily cap on your server, and show players a friendly message when it is reached.

02Uncensored AI

Questions and answers

Can players use it without installing anything?

Yes. The model runs on the hosted API and your app is a web page, so players only need a browser.

Should the browser call the API directly?

No. Keep the key on your server and let the browser call your own endpoint, otherwise anyone can copy the key from the page.

How long can a roleplay story be?

The context window is 100,000 tokens for prompt plus reply. For very long stories, keep recent messages and a running summary.

Does it make character images or voices?

No. The API is text only, with no image, audio or video generation.

Uncensored AIuncensoredaiimage.com

Your key is one form away

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

Get API key