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.
| Parameter | Meaning |
|---|---|
| prompt | What 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 |
| seed | Optional. The same seed and prompt may still give a different image. |
| n | Optional. 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
$call = @{
Method = "Post"
Uri = "https://api.axforge.ai/v1/images/generations"
Headers = @{ Authorization = "Bearer $env:AXFORGE_API_KEY" }
ContentType = "application/json"
Body = '{"model":"ernie-image-turbo","prompt":"Poster reading GRAND OPENING in bold red serif on cream paper","size":"1024x1024","seed":7,"n":1}'
TimeoutSec = 300
}
$r = Invoke-RestMethod @call
[IO.File]::WriteAllBytes("$PWD\poster.png", [Convert]::FromBase64String($r.data[0].b64_json))
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).
| Parameter | Meaning |
|---|---|
| prompt | The edit instruction, e.g. "make the sky overcast" |
| image | The source image, as base64 or a data URL. Use images for several sources. |
| n | Optional. 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
# photo.png → edited.png
$img = [Convert]::ToBase64String([IO.File]::ReadAllBytes("$PWD\photo.png"))
$call = @{
Method = "Post"
Uri = "https://api.axforge.ai/v1/images/edits"
Headers = @{ Authorization = "Bearer $env:AXFORGE_API_KEY" }
ContentType = "application/json"
Body = @{ model = "flux2-klein-4b"; prompt = "Make the sky overcast"; image = "data:image/png;base64,$img" } | ConvertTo-Json
TimeoutSec = 300
}
$r = Invoke-RestMethod @call
[IO.File]::WriteAllBytes("$PWD\edited.png", [Convert]::FromBase64String($r.data[0].b64_json))
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.