Developer docs
7. Image generation API
Version 1.0 · 2026-10-20
POST /v1/images/generations (also available as POST /v1/images) generates PNG images from text and returns them as base64. The endpoint accepts only the fields below; any other field returns 400.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | flux-schnell or chroma1-hd |
prompt | string | Yes | Description of the image |
n | integer | No | Number of images, 1–4, default 1; billed per image |
size | string | No | WIDTHxHEIGHT, each side 256–1536, rounded down to a multiple of 16; default 1024x1024 |
seed | integer | No | 0–4294967295; fix it to reproduce a result |
steps | integer | No | flux-schnell: default 4, max 8. chroma1-hd: default 25, max 50 |
negative_prompt | string | No | What you do not want in the image; recommended for chroma1-hd only |
guidance_scale | number | No | How closely to follow the prompt; chroma1-hd only |
style | string | No | Portrait layout presets: person, person_scene, object. They rewrite the prompt and add a negative prompt automatically — leave unset for general use |
response_format | string | No | Only b64_json is supported; image URLs are not provided |
Example
import base64
resp = client.images.generate(
model="flux-schnell",
prompt="Jiufen Old Street in morning light, photorealistic",
size="1024x1024",
n=1,
extra_body={"seed": 7},
)
with open("jiufen.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))Response
{
"created": 1792483207,
"data": [{ "b64_json": "iVBORw0KGgo...", "media_type": "image/png" }],
"seed": 7,
"steps": 4,
"model": "flux-schnell",
"guidance_scale": 0.0,
"usage": { "prompt_tokens": 0, "completion_tokens": 1000, "total_tokens": 1000 }
}Which model to choose
- flux-schnell: speed first — suited to large batches of drafts and real-time generation inside a product.
- chroma1-hd: quality first, with negative prompts and
guidance_scale— suited to production assets.
Both cost US$0.01 per image. flux-schnell accepts negative_prompt, but it has almost no effect and makes generation slower; if you need a negative prompt, use chroma1-hd.