EN ▾
Get API key

LLM API for Flux Prompts: A Practical Workflow

If you want an LLM API for Flux prompts, the job is simple: send a short idea to a text model and get back a detailed prompt your image service can use. This page shows the system prompt, the settings and the code, and says plainly what a text-only model cannot do.

Updated

A terminal feeding ribbons of text along a conveyor to an empty picture frame, showing prompts written before images

Key points

  • Use a system message to fix the format and style once, then send only the short idea per request.
  • JSON mode returns a list of prompt variations that a script can loop over without parsing prose.
  • The 100,000-token window lets you paste a style guide or past prompts into the request.
  • A full expansion costs a fraction of a cent, and the model never sees or makes the image.

The short version

Create a key, point an OpenAI client at https://api.fluxapikey.com/v1, set the model to uncensored, and put your prompt rules in the system message. Each user message is then just the idea: a few words, a scene, a character. The reply is the finished prompt. Copy it into whatever image tool you use, which has its own key and its own billing.

Nothing here generates pictures. The API is text only, it is not an image vendor's service, and it cannot look at your renders. What it does well is the writing: structure, vocabulary, consistency across a batch. The rest of this page is the practical detail.

Why use a language model for prompts at all

Image models reward specific input and punish vague input. A line like "a castle" gives you the average castle. A paragraph that names the material of the walls, the time of day, the lens and the colour palette gives you something closer to the picture in your head. Writing that paragraph by hand for every image is slow, and you tend to forget the same details every time.

A language model is good at exactly this kind of expansion. It will add the missing detail, keep a fixed order of elements, and hold to a house style across hundreds of requests. Because this model does not refuse by default, it also copes with fiction, dark themes and character work for adults that more cautious hosted models often decline. The usual limit applies: lawful adult use only, and no sexual content involving minors under any framing.

A system prompt that works

Most of the quality comes from the system message. Keep it short, concrete and testable. Here is a starting point you can edit:

SYSTEM = '''You write prompts for a text-to-image model.
Output exactly one prompt, one paragraph, no preamble, no quotes.
Order: subject, action, setting, lighting, camera or medium, palette, mood.
Use concrete nouns and visual adjectives. Avoid abstract words like beautiful.
Do not mention the words prompt, image or render.
Keep it under 90 words.'''

Notice what the message does not say. It gives no long lecture on creativity and no list of forbidden topics. Short rules with a fixed order are easier for a model to follow, and easier for you to debug. If the output drifts, change one line and rerun the same idea. If you want a different house style for a different project, keep a second system message and pick one per request.

Show, do not describe

When rules alone are not enough, add one or two example pairs as earlier messages in the conversation: a short idea as a user message and the prompt you like as an assistant message. A pair or two usually fixes tone better than another paragraph of rules.

Sending the request

The call is a standard chat completion. The settings that matter most for creative expansion are temperature and seed.

from openai import OpenAI

client = OpenAI(base_url="https://api.fluxapikey.com/v1", api_key="YOUR_KEY")

def expand(idea, seed=None):
    r = client.chat.completions.create(
        model="uncensored",
        messages=[
            {"role": "system", "content": SYSTEM},
            {"role": "user", "content": idea},
        ],
        temperature=0.9,
        top_p=0.95,
        max_tokens=200,
        seed=seed,
    )
    return r.choices[0].message.content.strip()

print(expand("an abandoned observatory on a cliff", seed=7))

A temperature around 0.8 to 1.0 gives varied wording, which is what you want when brainstorming. Lower it toward 0.3 when you need near-identical output for a repeated template. The seed, top_p, stop and the penalty parameters are passed through to the model, so you can use them as you would elsewhere. The max_tokens limit is optional; setting it near the length you expect keeps a runaway answer short. See the docs for every supported parameter.

Batches of variations with JSON mode

For a batch, ask for a list and turn on JSON mode with response_format. The system message must still tell the model what shape to return, since JSON mode makes the output valid JSON but does not choose your keys for you.

# client as above: base_url https://api.fluxapikey.com/v1
import json

def variations(idea, n=8):
    r = client.chat.completions.create(
        model="uncensored",
        response_format={"type": "json_object"},
        messages=[
            {"role": "system", "content": SYSTEM + f"\nReturn JSON: {{\"prompts\": [{n} strings]}}."},
            {"role": "user", "content": idea},
        ],
        temperature=1.0,
    )
    return json.loads(r.choices[0].message.content)["prompts"]

for p in variations("a night market in the rain"):
    print(p)

Wrap json.loads in a try block anyway. If a reply is cut off by a very low max_tokens, it will not parse, so leave that parameter generous for list requests. Each prompt in the list can go straight into your image service in a loop.

Using the 100,000-token window

The context window is 100,000 tokens, counting the prompt plus the completion. For prompt work that is more than you need per request, but it is useful in two ways. You can paste a long style guide, a character sheet or a list of past prompts that worked, and the model will follow them. And you can keep a working conversation going: ask for a prompt, say "darker, add fog", and get a revised one that remembers the first.

Long input costs money, so keep a standing style guide to what changes the output. Five hundred tokens of rules is cheap. Fifty thousand tokens of old prompts sent with every request adds up, as the cost section below shows: 50,000 extra input tokens is $0.0075 per request, or $3.75 over 500 requests.

Prompt patterns for common jobs

The same endpoint covers several different tasks. What changes is the system message.

  • Character sheets. Keep a fixed description of a recurring character (hair, clothing, age, build) in the system message, and instruct the model to repeat it word for word in every prompt. That is the cheapest way to keep a character recognisable across a series of renders.
  • Style transfer by words. Give a list of style terms you like, such as "gouache, muted palette, grain", and ask for them in the last sentence of every prompt.
  • Negative wording. If your image tool takes a separate negative prompt, ask the model to return two fields in JSON mode: prompt and negative. Keep the negative list short and specific.
  • Shortening. Some tools cut off long input. Add a word limit to the rules and test it, since models count words loosely.

Mature fiction and roleplay art for adults is a legitimate case here. The model will write the scene description in plain, non-graphic language if you ask it to. If you work on a platform with content rules of its own, put those rules in the system message as well, so the prompts match where the pictures will be posted.

Testing and tuning the loop

Treat the system message like code. Pick five test ideas that cover your usual range, run them with a fixed seed and a low temperature, and save the outputs. After each change to the rules, rerun the same five and compare. This catches the common failure where a fix for one case breaks another.

Look for three symptoms. Prompts that repeat the same opening words across a batch mean the temperature is too low or the examples are too uniform. Prompts that ignore your word limit mean the rule is buried; move it to the end of the message. Prompts that include chatty lead-ins such as "Here is your prompt" mean the format rule needs to be stricter, or you can strip the first line in code. Streaming with stream: true is available if you show results in a UI, and usage is reported at the end of the stream.

Limits to plan around

Three honest limits. First, the model is text only: it cannot see an image, so it cannot judge whether a prompt produced a good picture. You are the judge, and the loop is write, render, adjust the rules. Second, it knows nothing about the quirks of your particular image model unless you tell it, so put those quirks in the system message. Third, rate limits: a full key allows 8 concurrent requests and 300 per minute, and a trial key 2 and 60. If a loop exceeds that you get HTTP 429 with the code concurrency or rate_limited; wait a moment and retry. A 429 with a Retry-After: 5 header means temporary overload and the same advice applies.

What it costs per prompt

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Suppose each request sends an 800-token system message plus idea and returns a 200-token prompt. Over 500 requests that is 400,000 input tokens and 100,000 output tokens. Input: 0.4 x $0.15 = $0.06. Output: 0.1 x $0.50 = $0.05. Total: $0.11 for 500 prompts.

The JSON batch above, at roughly 400 tokens in and 700 out per call, costs 0.0004 x $0.15 plus 0.0007 x $0.50, which is $0.00006 + $0.00035 = $0.00041 for eight prompts. The trial credit is $0.50, claimed with one click after sign-up. Top-ups start at $20; see the pricing page for bonus tiers, and the key page to start.

Questions and answers

Can the model write prompts for any image generator?

Yes, because it only produces text. You tell it the format your image tool prefers in the system message, then copy the result over.

Will it refuse mature or dark themes?

It is tuned to answer without content refusals for lawful adult use. Sexual content involving minors is never allowed.

How many prompts can I make per minute?

A full key allows 300 requests per minute and 8 at once. With JSON mode, one request can return several prompts.

Does it generate the pictures too?

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

Your key is one form away

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

Get API key