LLM API
Image generation
Create images from a text prompt with the Flux and Qwen-Image families.
Generate an image
Send a prompt and pick a model and size. Images come back base64-encoded in data[].b64_json.
import base64
resp = client.images.generate(
model="qwen-image",
prompt="A minimalist lime-green leaf circuit on a dark background",
n=1,
size="1024x1024",
)
png = base64.b64decode(resp.data[0].b64_json)
open("out.png", "wb").write(png)Parameters
model—qwen-imageorflux-2-kleinfor generation;qwen-image-editfor editing.prompt— describe the subject, style, composition and lighting.n— how many images to return (default 1).size— pixel dimensions such as512x512or1024x1024.
Response
{
"created": 1782845004,
"data": [
{ "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..." }
]
}Decoding the image
The string inb64_json is a base64-encoded PNG. Decode it to bytes and write it to a file, or use it inline as a data:image/png;base64,… URL in the browser.