API reference

Images

Generate and edit images.

On this page

POST/v1/images/generations

Creates images from a prompt.

Auth: API key, or pay per request under https://api.usdf.fi/x402

NameTypeRequiredDescription
modelstringYesAn image model id.
promptstringYesWhat to draw.
nintegerNoHow many images.
sizestringNoWidth by height, for example 1024x1024.
response_formatstringNob64_json or url.

POST /v1/images/generations

curl
curl -X POST https://api.usdf.fi/v1/images/generations \
  -H "Authorization: Bearer $USDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<image model>",
    "prompt": "A lighthouse at dawn, watercolor",
    "n": 1,
    "size": "1024x1024",
    "response_format": "b64_json"
  }'

Response, trimmed

{
  "created": …,
  "data": [{ "b64_json": "…" }],
  "model": "<image model>",
  "receipt": { "request_id": "<request_id>", "cost": { … }, … }
}

POST/v1/images/edits

Changes an uploaded image as the prompt describes. Sent as multipart form data.

Auth: API key, or pay per request under https://api.usdf.fi/x402

NameTypeRequiredDescription
modelstringYesAn image model that supports edits.
promptstringYesThe change to make.
imagefileYesThe image to edit.

POST /v1/images/edits

curl
curl -X POST https://api.usdf.fi/v1/images/edits \
  -H "Authorization: Bearer $USDF_API_KEY" \
  -F model=<image model> \
  -F prompt="The same scene at night" \
  -F image=@input.png