ChatGPT SDXL Prompt Generator vs Your Own API Script
A chatgpt sdxl prompt generator workflow means opening a chat window, typing an idea, copying the answer into your image tool, and repeating. It is fine for ten prompts and miserable for a thousand. This article compares that routine with a short script that calls an API, and puts numbers on both.


Key points
- Manual chat is best for exploring a style; a script is best once you need volume or repeatability.
- At 30 seconds per manual prompt, 1,000 prompts take about 8.3 hours; a script can finish in minutes.
- On this API, 1,000 prompts of about 300 tokens in and 200 out cost roughly $0.145.
- A script also gives you fixed formats, saved inputs and retries, which a chat window does not.
Two ways to get SDXL prompts from a language model
The first way is a chat assistant. You paste a system-style instruction once, then send short ideas one at a time and copy each reply into your image tool. It needs no code, you see the answer immediately, and you can say "darker, more cinematic" and get a revision. For discovery that is hard to beat.
The second way is a script. You write the instruction once in code, load a list of ideas from a file, call a chat completions endpoint for each, and write the results to a file or send them straight to your image generator. This service is an OpenAI-compatible, text-only API serving one open-weight model from an independent provider. It is not ChatGPT and not an OpenAI product, but any OpenAI SDK talks to it once you change the base URL and key.
Neither approach draws pictures. In both, the model writes text and a separate tool such as SDXL renders it.
Side by side
| Factor | Chat window | API script |
|---|---|---|
| Setup | None | Key, 30 lines of Python |
| Best batch size | 1 to 20 prompts | Hundreds to thousands |
| Output format | Whatever the chat returns; you clean it by hand | JSON mode returns fields you can parse |
| Repeatability | Drifts as the conversation grows | Same instruction on every call, optional seed |
| Iteration | Natural: reply with feedback | You edit the script and rerun |
| Cost model | Depends on the plan you hold; check its current terms | Pay per token, prepaid |
| Refusals | Depends on the assistant's content policy | This model answers without content refusals for lawful adult use |
The honest summary: if you make a handful of images a week and enjoy conversing about them, stay with the chat. A script starts to pay off at the point where copy-pasting becomes the slowest step in your pipeline.
The time cost of copy and paste
Take a modest assumption: 30 seconds per prompt to type the idea, wait, copy the result and paste it where it belongs. Over 1,000 prompts that is 1,000 × 30 s = 30,000 s, or about 8.3 hours of attention.
A script has a different shape. Say each API call takes around 5 seconds (that is an assumption, so measure your own). With 8 requests in flight, which is the concurrent limit of a full key, 1,000 calls take about 1,000 / 8 × 5 s = 625 s, a little over 10 minutes. The request cap of 300 per minute means the absolute floor is just over 3 minutes. You start it, make coffee, and read the file afterward.
The saved time is the main argument. The money is secondary, as the next section shows.
Cost per 1,000 prompts
This API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. Suppose each call sends a 250-token instruction and a 50-token idea (300 in) and returns a 200-token prompt.
- Input: 1,000 × 300 = 300,000 tokens × $0.15 / 1M = $0.045.
- Output: 1,000 × 200 = 200,000 tokens × $0.50 / 1M = $0.10.
- Total: $0.145 for 1,000 prompts.
For comparison with a chat subscription or another API, divide that plan's price by the number of prompts you will actually make in a month, and check their current pricing instead of trusting a figure from an article. The $0.50 trial credit, claimed with one click on the API key page after sign-up, covers a bit over 3,400 prompts of this size. See the pricing page for top-ups from $20 to $500, by card or crypto.
A batch script with retries
The script below reads ideas from ideas.txt, one per line, and writes prompts.jsonl. It runs 6 workers in parallel and retries on 429.
import json, time
from concurrent.futures import ThreadPoolExecutor
from openai import OpenAI, RateLimitError
client = OpenAI(base_url="https://api.sdxlapi.com/v1", api_key="YOUR_KEY", max_retries=0)
SYSTEM = (
"Expand the idea into one SDXL prompt of 40 to 60 words: subject, setting, "
"lighting, style, mood, comma-separated. Return JSON with key 'prompt'."
)
def make(idea):
for attempt in range(5):
try:
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "system", "content": SYSTEM},
{"role": "user", "content": idea}],
response_format={"type": "json_object"},
temperature=0.8,
)
return {"idea": idea, **json.loads(r.choices[0].message.content)}
except RateLimitError:
time.sleep(5 * (attempt + 1))
return {"idea": idea, "prompt": None}
ideas = [l.strip() for l in open("ideas.txt") if l.strip()]
with ThreadPoolExecutor(max_workers=6) as pool, open("prompts.jsonl", "w") as out:
for row in pool.map(make, ideas):
out.write(json.dumps(row, ensure_ascii=False) + "\n")
Keep the worker count at or below 8 on a full key, or 2 on a trial key. If you see 429 with the code concurrency, lower it; rate_limited means you exceeded the per-minute cap. Failed requests are not billed, so retries are free. More on parameters is in the docs.
Getting better output from the script
The first run of a batch is rarely the best one. Three cheap changes improve results more than switching tools.
- Add two or three examples to the system prompt. Paste prompts that gave you images you liked, each with the short idea that produced it. The model copies the structure and level of detail.
- Pass a style field. Keep a small dictionary such as "film still", "watercolor", "isometric render", and append the chosen style to each idea. One list of ideas can then yield several looks.
- Filter the output. Reject rows whose prompt is shorter than 25 words or longer than 80, then rerun only those. A short check in code beats reading a thousand lines.
Save the idea next to every result. When one image comes out well, you want to see exactly what produced it, and a chat history scrolls away. Subject matter stays your decision: the model is tuned for lawful adult use, and the one hard limit is that nothing sexual involving minors is ever generated.
When to stay with chat
A script is not always the better choice. Stay with a chat assistant when you do not yet know what you want, when each image needs a conversation about composition, or when your volume is small enough that setup time would exceed the time saved. A common pattern is to use chat to find a good instruction, then paste that instruction into the script as the system prompt and run the bulk work there.
Also think about data. Prompts sent to this API are not used for training. For any other service, read their data policy before sending unreleased creative work.
More guides
Questions and answers
Is this API the same as ChatGPT?
No. It is an OpenAI-compatible endpoint serving one open-weight model from an independent provider. It is not an OpenAI product.
Can the API produce the SDXL image too?
No. It writes text only. Your prompt goes to SDXL, ComfyUI, Automatic1111 or another image tool.
How much does it cost to generate 1,000 prompts?
About $0.145 for prompts of roughly 300 tokens in and 200 out, at $0.15 per 1M input and $0.50 per 1M output tokens.
How fast can a batch run?
A full key allows 8 concurrent requests and 300 per minute, so 1,000 short prompts can finish in minutes. Trial keys allow 2 and 60.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.