Skip to main content
Edit or outpaint an image from a source image and prompt (inpainting, local changes, etc.).

Basics

  • Endpoint: POST /v1/images/edits/
  • Host: https://tokensmind.ai
  • Auth: Bearer Token
  • Content-Type: multipart/form-data (file upload—use form data)

Form fields

FieldTypeRequiredDescription
imagefileYesSource PNG, square, < 4MB. Without mask, the image must include transparency (alpha) as the edit region.
promptstringYesDesired result, max 1000 chars. E.g. “A cute baby sea otter wearing a beret.”
maskfileNoMask PNG, < 4MB, same size as the image. Fully transparent pixels mark regions to edit.
modelstringNoe.g. dall-e-2.
nintegerNoNumber of images (1–10), default 1.
sizestringNo256x256, 512x512, or 1024x1024.
response_formatstringNourl or b64_json.
userstringNoEnd-user id.

Response

200 OK
FieldTypeDescription
createdintegerCreation timestamp.
dataarrayResults.
└─ urlstringEdited image URL.
└─ b64_jsonstringBase64 image data.

cURL example

curl https://tokensmind.ai/v1/images/edits/ \
  -H "Authorization: Bearer $YOUR_API_KEY" \
  -F image="@otter.png" \
  -F mask="@mask.png" \
  -F prompt="A cute baby sea otter wearing a beret" \
  -F n=1 \
  -F size="1024x1024"

Notes

  1. PNG only—editing relies on the alpha channel to mark regions to repaint.
  2. Mask behavior
    • With mask, transparent areas of the mask are edited.
    • Without mask, transparent areas of image are edited.
  3. Square images—input must be 1:1.