Documentation / API

Image generation & editing

Two endpoints, two models. ERNIE Image Turbo generates new images, including dense, accurate in-image text. FLUX.2 Klein edits an existing image from an instruction. Both return base64 PNG in the OpenAI images shape.

Generation

POST /v1/images/generations, model ernie-image-turbo, €0.05 / image.

ParameterMeaning
promptWhat to draw. ERNIE follows text-in-image instructions well, so quote the exact wording you want rendered.
size"WxH", e.g. "1024x1024", up to 2048 per side
seedOptional. The same seed and prompt may still give a different image.
nOptional. Number of images, up to 4.
curl --max-time 300 https://api.axforge.ai/v1/images/generations \
  -H "Authorization: Bearer $AXFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ernie-image-turbo",
    "prompt": "Poster reading GRAND OPENING in bold red serif on cream paper",
    "size": "1024x1024",
    "seed": 7,
    "n": 1
  }' \
  | sed -n 's/.*"b64_json":"\([^"]*\)".*/\1/p' | base64 -d > poster.png

The response carries the PNG in data[].b64_json:

{
  "data": [
    {"b64_json": "iVBORw0KGgoAAAANSUhEUg..."}
  ]
}

Generation is not instant. Expect tens of seconds per image. Set your client timeout accordingly.

Editing

POST /v1/images/edits, model flux2-klein-4b. Send the source image plus an instruction; get the edited image back as base64 PNG. €0.06 per edit (launch pricing).

ParameterMeaning
promptThe edit instruction, e.g. "make the sky overcast"
imageThe source image, as base64 or a data URL. Use images for several sources.
nOptional. Number of variants.
# photo.png → edited.png
IMG=$(base64 < photo.png | tr -d '\n')
printf '{"model":"flux2-klein-4b","prompt":"Make the sky overcast","image":"data:image/png;base64,%s"}' "$IMG" > edit.json
curl --max-time 300 https://api.axforge.ai/v1/images/edits \
  -H "Authorization: Bearer $AXFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @edit.json \
  | sed -n 's/.*"b64_json":"\([^"]*\)".*/\1/p' | base64 -d > edited.png

Edits are faster than full generations, seconds-scale rather than tens of seconds.

Changing text inside an image

Regenerate, don't edit. To change words inside an image, re-run /v1/images/generations with ernie-image-turbo and the new wording. ERNIE renders dense in-image text accurately; instruction editors like FLUX mangle letterforms.

Ask on the forum Markdown For AI Updated 2026-11-06

Anything unclear on this page?

Ask on the forum. The answer helps the next person too.

Ask about this page