Images

Modify an existing image according to text instructions: supply a source image (URL or base64) and a prompt describing the changes (e.g. "add clouds", "warmer color scheme"), with an optional reference_image for extra style or content guidance. To change only one area, pass a mask (white = change, black = keep, the same size as the image): mask_mode "replace" (default) redraws that area from the prompt, "erase" removes what is there. Without a mask the whole image is re-rendered. Never ask for a transparent background in the prompt: it often comes back as a grey-and-white checkerboard painted into the pixels, which removeBackground cannot remove. A sprite keeps its transparency without being asked (see image_type). The job result is an array of image results, each with a url; request n (1-4) to control the number of edited variations. Provided images are uploaded and validated, and any image larger than 15MB is rejected with HTTP 400. Credits are held when the job is accepted and refunded if it fails or is cancelled; the charge scales with the number of images produced. Use editImage to transform a specific existing image; use createImage to generate from text alone, generateWithStyle to borrow a reference's art style, and removeBackground for the dedicated background-removal case. Pass an optional request_id to tag the results so you can retrieve them later via listGenerations (type image). Requires an API key (user scope). The call returns 202 with a job id - poll getApiJob (pass wait 30 to long-poll) honouring poll_after_ms, until status is succeeded; its result field is exactly the response documented for this operation. Synchronous responses are deprecated but still supported: pass `async: false` to block until the result is ready and receive it as the response body. Synchronous calls run on the same queue: the response carries an X-Ludo-Job-Id header, and a job still running after 15 minutes comes back as 202 with the job instead of an error. Each account may have up to 50 generations queued or running at once via the API; a request beyond that returns 429 (code PENDING_JOBS_LIMIT).

Changed on
post/assets/image/edit

Request

  • Base URL
    https://api.ludo.ai/api
  • Auth
    API key in header Authorization

Request body

imagestring required

URL or base64-encoded source image to edit.

promptstring

Text description of the changes to make (e.g., "add clouds to the sky", "make it darker", "change the color scheme to warmer tones"). Required, except with mask_mode "erase". With a mask, describe what should fill the masked area. Describe only the change, never the background's transparency ("transparent background", "on transparency", "transparent padding"); asking for it often paints a checkerboard into the pixels instead. A sprite keeps its transparent background on its own, and removeBackground is the tool for removing one.

reference_imagestring

Optional URL or base64-encoded reference image for style or content guidance. Not used with mask_mode "erase".

maskstring

Optional URL or base64-encoded PNG that limits the edit to one area of the image. White marks the area to change, black the area to keep. It must be exactly the same width and height as image, or the call returns 400. Without a mask the whole image is re-rendered, which can shift colours and details outside the part you meant to change. A masked edit costs more than an unmasked one (see the price).

mask_mode'replace' | 'erase'

Only with mask. "replace" (the default) redraws the masked area from prompt; "erase" removes what is in the masked area and takes no prompt.

image_typestring

What kind of image the source is (e.g. "sprite"). Not needed when image is the URL of an image you generated on Ludo in the last 30 days, which keeps its own type. Set it when the image is an upload or a link from elsewhere, so a sprite is edited as a sprite and keeps its transparent background.

nnumber

Number of edited variations to generate (1-4).

augment_promptboolean

Ignored: edits always rewrite your prompt into the long, structured form the edit model needs (which subjects are in the image, what changes and what stays). Without that rewrite, edits miss the request and lose quality, so it can no longer be turned off. Still accepted so existing requests keep working; omit it.

request_idstring

Optional client-provided identifier, unique per request. Re-sending the same request_id returns the existing job instead of generating again. Also usable as the request_id filter of listGenerations.

asyncboolean

Defaults to true: the call returns 202 immediately with a job id to poll with getApiJob. Set false for a synchronous response (deprecated but supported): the call then blocks until the result is ready.

Example request

{
  "image_type": "sprite"
}

Response

Success

urlstring
request_idstring
created_atinteger
modelstring

The id of the model that generated or edited the image, so you can tell when the model behind an operation changes. Generated and edited images only.

promptstring

The prompt as the model received it. With augment_prompt on, this is the rewritten prompt, not the one you sent. Generated and edited images only.

Changes