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

  • modelqwen-image or flux-2-klein for generation; qwen-image-edit for editing.
  • prompt — describe the subject, style, composition and lighting.
  • n — how many images to return (default 1).
  • size — pixel dimensions such as 512x512 or 1024x1024.

Response

json
{
  "created": 1782845004,
  "data": [
    { "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..." }
  ]
}

Decoding the image

The string in b64_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.