Build with the API

Generate images

POST /v1/images/generations creates images from a prompt, with a model whose capabilities include images in the model list. The images come back inside the response, as base64-encoded PNG.

curl https://sven.swedishembedded.com/v1/images/generations \
  -H "Authorization: Bearer $SVEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "prompt": "A lighthouse at dawn",
    "n": 1,
    "size": "1024x1024"
  }'

Parameters#

  • model and prompt are required.
  • n is how many images, 1 to 10. The default is 1.
  • size is WIDTHxHEIGHT, each side 1 to 4096.
  • response_format can only be b64_json: images are always returned inline, never as a link.

The response#

json
{ "created": 1767225600, "data": [{ "b64_json": "iVBORw0KGgo..." }] }

data has one entry per image delivered. Decode b64_json to get the PNG.

What it costs#

You are charged for each image delivered what it cost, which for a typical image is about the model's image price and is never more than its image_max. See How calls are charged.