EN ▾
Get API key
uncensoredimage.cc

Updated

Image Prompt Generator: ChatGPT vs API Script

Using an image prompt generator chatgpt style, meaning a chat window where you ask a model to write prompts, works well for a handful of images. Once you need dozens or hundreds with a consistent style, a short API script is faster and repeatable. Here is how to decide, and a script to copy.

Two paths: a few loose notes by a lamp versus a conveyor belt turning many tiles into finished frames
Floating masks and glowing speech bubbles on a small stage, representing a roleplay community powered by a text API

Two workflows for the same job

Both approaches ask a language model to write a text prompt for an image tool. They differ in how you control the instructions and how much repeating you do.

Chat windowAPI script
SetupNone; open and typeA key and 30 lines of code
Best forExploring ideas, one or ten promptsBatches of 50 or more
Style consistencyDepends on you pasting the same instructions each timeFixed in the code
Output handlingCopy and paste by handWritten to a file or sent straight to your next tool
Cost modelWhatever your chat plan includes; check current termsPer token, about $0.00019 per prompt here
RepeatabilityLowHigh, with a fixed seed if wanted

A chat window is the better choice more often than people admit. If you need five prompts for a mood board, open a chat, describe what you want, and iterate by talking. A script only pays off when typing the same instruction a hundred times becomes the bottleneck. This article is for that moment.

Where the chat workflow breaks down

Four problems show up when you scale the manual approach.

  1. Style drift. You paste your style rules in the morning and forget one line in the afternoon. The prompts change, and so do the images.
  2. Long threads. The longer a conversation runs, the more earlier text the model has to carry. Quality can slip, and old instructions get less weight.
  3. Copy and paste time. Moving a hundred prompts from a window into a spreadsheet costs more of your time than any token bill.
  4. No audit trail. Reproducing last week's batch is hard when the instruction lived in a chat history.

A script solves all four by moving the instructions into a file. Every row is processed with exactly the same system message, and the result lands in a column next to the idea.

A CSV-in, CSV-out script

Prepare a file called ideas.csv with one column named idea. The script adds a prompt column. It calls an OpenAI-compatible text API with the model uncensored; the service is independent and is not ChatGPT or any other vendor's product.

import csv
import os
from concurrent.futures import ThreadPoolExecutor
from openai import OpenAI

client = OpenAI(base_url="https://api.uncensoredimage.cc/v1",
                api_key=os.environ["API_KEY"])

STYLE = "35mm film look, muted colours, soft natural light, shallow depth of field"

SYSTEM = (
    "Turn the idea into one image prompt of 40 to 70 words. "
    "Keep the subject unchanged. Describe composition, lighting and colour. "
    f"Always end with this style line, word for word: {STYLE}. "
    "Reply with the prompt only."
)

def make(idea):
    r = client.chat.completions.create(
        model="uncensored",
        messages=[{"role": "system", "content": SYSTEM},
                  {"role": "user", "content": idea}],
        temperature=0.7,
        max_tokens=250,
    )
    return r.choices[0].message.content.strip()

with open("ideas.csv", newline="", encoding="utf-8") as f:
    rows = list(csv.DictReader(f))

with ThreadPoolExecutor(max_workers=4) as pool:
    prompts = list(pool.map(make, [r["idea"] for r in rows]))

for r, p in zip(rows, prompts):
    r["prompt"] = p

with open("prompts.csv", "w", newline="", encoding="utf-8") as f:
    w = csv.DictWriter(f, fieldnames=["idea", "prompt"])
    w.writeheader()
    w.writerows(rows)

Notice the style line in STYLE. Because it is a variable, you change your whole batch's look by editing one string. Four workers keep you well inside a full key's limit of 8 concurrent requests. On a trial key, use 2.

Test the idea from a terminal first

Before writing code, confirm that the key and endpoint work with one curl call. It also shows you the response headers, including your remaining balance.

curl -i https://api.uncensoredimage.cc/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"system","content":"Turn the idea into an image prompt of 50 words."},{"role":"user","content":"a lighthouse at night"}],"max_tokens":150}'

Look for X-Balance-USD, which shows your credit, and for X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, which show your limits. If something fails, check the HTTP status. A 401 means the key is wrong. A 429 with code rate_limited or concurrency means you went over a limit, and a 429 with Retry-After: 5 is temporary overload, so wait five seconds and retry. Failed or refused requests are not charged.

Cost: 1,000 prompts

The API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. In the script above each row sends about 250 input tokens (system message plus idea) and returns about 300 tokens of prompt text.

  • Input: 250 x $0.15 / 1,000,000 = $0.0000375
  • Output: 300 x $0.50 / 1,000,000 = $0.00015
  • Per prompt: $0.0001875
  • 200 prompts: $0.0375
  • 1,000 prompts: $0.1875

So 1,000 prompts cost under 19 cents, and the $0.50 trial credit covers about 2,600 of them ($0.50 / $0.0001875 is about 2,667). Compare that with what you pay for your own hours when copying text by hand. For a chat product, check its current pricing and limits; this article does not quote them.

Top-ups are prepaid and credit never expires. Any whole amount from $20 to $500 is accepted, with +5% from $50, +10% from $100 and +15% from $200, paid in crypto (USDT on TRC20 or USDC on Base). See the pricing page for specifics.

Quality checks for a batch

A script makes it easy to produce a thousand prompts, which also makes it easy to produce a thousand bad ones. Build in a few checks before you send anything to an image tool.

  • Spot-check a sample. Read ten random rows from each batch. If three or more look off, fix the system message and rerun that batch; failed or refused requests are not charged, but accepted ones are.
  • Measure length. Count words per prompt and flag anything outside your range. A short Python check after the loop catches rows where the model rambled or cut off early.
  • Check the style line. Because the style string must appear at the end of every prompt, test with endswith and retry any row that fails.
  • Dedupe. Similar ideas can produce near-identical prompts. Ask for a different composition for each when ideas overlap.
  • Use a seed for reruns. The seed parameter is passed through, which helps when you want to compare two versions of the system message on the same inputs.

These checks take minutes to write, and they are the main reason a script beats a long chat thread: the rules are applied the same way on row one and on row nine hundred.

When to stay in the chat window

Be honest about where a script is the wrong tool.

  • You are still finding the look. Conversation is the fastest way to explore. Talk it out in a chat, then freeze the winning instruction as SYSTEM in your script.
  • You need a feature the API lacks. This service is text only. Chat products from other vendors may accept image inputs or generate images; here, there is no image input, output or analysis.
  • You only need a few prompts a week. The time to set up a script is not worth it.
  • You want a second opinion on one image. Show the picture to a model that can see it; a text API cannot.

A good hybrid: explore in chat, then run the batch through the script. The custom image roleplay community page shows how other people share prompt conventions.

Getting a key and next steps

Sign up with Google or with email and password, then open the API key page and claim the one-click $0.50 trial. It needs no payment, applies once per person and lasts 7 days. Trial keys allow 2 concurrent requests and 60 per minute.

The model is tuned to answer without content refusals for lawful adult use, so adult-oriented illustration projects are not blocked by default. It never helps with sexual content involving minors. Prompts are not used for training. The context window is 100,000 tokens, which is far more than a prompt-writing job needs. For parameters such as response_format, seed and stop, read the documentation.

Questions and answers

Can I use ChatGPT as an image prompt generator?

Yes, a chat window works well for a few prompts. For batches with a fixed style, a script that calls a text API is faster and more repeatable.

Does this API generate the images?

No. It is a text API that writes prompts. You pass them to a separate image tool.

How much does a batch of 1,000 prompts cost?

About $0.19 at 250 input and 300 output tokens per prompt, using $0.15 and $0.50 per 1M tokens.

Is this API the same as ChatGPT?

No. It is an independent OpenAI-compatible API running one open-weight model, not made by OpenAI or any other vendor.

Your key is one form away

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