Spritesheets

Edit a previously generated spritesheet: re-prompt its underlying animation (edit_mode "prompt"), extend the frame beyond its borders ("outpaint"), repair a bad loop ("fix_loop"), or re-render it with finer detail ("improve": the extra pass hydra-plus runs when it generates, on a spritesheet generated with hydra only - any other returns HTTP 400; a sheet generated on hydra-plus already has it). Pass the `spritesheet_url` you received from `animateSprite`, `animateSpriteKeyframes`, `transferMotion`, or an earlier edit - it must be a spritesheet you generated within the last 7 days; arbitrary external images are not accepted. Omit `duration`, `frames`, `frame_size`, `crop` and `model` to keep the source spritesheet's values. A `prompt` is required for edit_mode "prompt", optional for "outpaint", and not accepted for "fix_loop" or "improve"; optionally add up to 5 reference `images` (URL or base64) to guide the edit. The job result is the same result shape as animateSprite (spritesheet URL, frame layout, optional GIF or individual frames). Credits are held when the job is accepted; the final charge is rate × seconds of video generated, never more than was held, and the difference (or everything, if the job fails or is cancelled) is refunded. The returned sheet is then trimmed to its best loop and can run slightly shorter than the video; that trim is not deducted. Prompt edits are priced per model (credits/second × duration) and held for the duration you requested; "outpaint", "fix_loop" and "improve" run a lighter pipeline in which `model` is ignored and are billed at a flat 1 credit per second of output, held for and capped at the length of the source spritesheet's video (`duration` does not change their price). Outpaint decides the extra margin itself - there is no amount parameter. The result carries the same fields as animateSprite (`spritesheet_url`, `video_url`, grid fields); new audio is generated only by prompt edits on hydra: "fix_loop", "outpaint" and "improve" do not regenerate it, and their result carries the source spritesheet's `audio_url` when it had one. Pass an optional `request_id` to tag the result for later retrieval via listGenerations (type spritesheet). 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/sprite/edit

Request

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

Request body

spritesheet_urlstring required

URL of a spritesheet you generated in the last 7 days (returned by animateSprite, transferMotion, or a previous edit as spritesheet_url). External URLs are not accepted. Edit the original animation rather than a previous edit's result: every edit re-renders the whole animation, so colors and detail drift further with each pass. If an edit did not work, retry from the original instead of editing on top.

edit_mode'prompt' | 'outpaint' | 'fix_loop' | 'improve'

Edit operation to perform. "improve" re-renders the animation with finer detail (the extra pass hydra-plus runs when it generates) and only takes a spritesheet generated with hydra; any other source returns HTTP 400, including an already improved spritesheet (or a loop fix or outpaint of one), which has that detail already.

promptstring

Edit instruction. Required for edit_mode "prompt", optional for "outpaint", not accepted for "fix_loop" or "improve". Focus it on a single change and keep it short (under about 50 words); run a second edit for more.

imagesstring[]

Optional reference images (up to 5), each a URL or base64, to guide the edit. Two, at most three, work best: more references reduce the model's ability to use any of them correctly.

durationnumber float

Output animation length in seconds. Omit to keep the source spritesheet's duration (recommended). Prices a prompt edit; outpaint, fix_loop and improve are billed on the source spritesheet's video length whatever this is.

model'hydra' | 'forge' | 'forge-pixel'

Backing model for edit_mode "prompt" (ignored for "outpaint", "fix_loop" and "improve", which run a fixed pipeline). Hydra is the default and the most capable, and generates audio; forge is the cheaper pick for simple edits; forge-pixel is the pixel-art variant, for spritesheets whose frames are pixel art.

cropboolean

Crop sprite frames to fit content (omit to keep the source spritesheet's setting). Results in smaller spritesheets but inconsistent frame sizes across different animations.

loopboolean

Trim the animation at the beginning or end to create a seamless loop.

frames4 | 9 | 16 | 25 | 36 | 49 | 64

Number of frames in the output spritesheet. Omit to keep the source spritesheet's frame count. Allow about one second of duration per 16 frames - above that the model may not be able to produce them all.

frame_size32 | 64 | 96 | 128 | 192 | 256 | 384 | 0

Size of the sprite in pixels, not of the frame - it sets how big the character is drawn, and each frame also holds the space around it, so frames come out larger than this value. 0 is for maximum resolution. Omit to keep the source spritesheet's setting.

gifboolean

When true, generates an animated GIF from the spritesheet and returns it in gif_url. Disabled by default to reduce response time.

individual_framesboolean

When true, extracts each frame from the spritesheet as an individual image and returns the URLs in individual_frame_urls.

spritesheet_with_backgroundboolean

When true, also returns the spritesheet with background intact (before background removal). The with-background spritesheet URL will be in spritesheet_with_background_url.

use_pixel_gridboolean

Use the animation's pixel grid if one is detected. true: when Ludo detects a pixel grid with confidence, the sheet is packed on it (logical pixels, scaled up by whole blocks); when none is detected, this has no effect. false: always pack as ordinary art, for when the detected grid is wrong for your asset (for example a smooth sprite coming back as coarse blocks). Ignored for forge-pixel animations, which are always packed on their grid. Unset keeps the source spritesheet's setting (true unless it was made with false).

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.

Response

Success

spritesheet_urlstring
video_urlstring
audio_urlstring

URL of the sound effect generated for the animation (MP3 or WAV; the extension says which). hydra and hydra-plus only; absent for forge and forge-pixel.

gif_urlstring
individual_frame_urlsstring[]
num_framesinteger

Number of frames in the spritesheet.

num_colsinteger

Columns in the frame grid. Frames run left-to-right, top-to-bottom.

num_rowsinteger

Rows in the frame grid. The last row may be only partly filled.

spritesheet_with_background_urlstring
individual_frame_with_background_urlsstring[]
durationnumber float
loopboolean

The loop setting the sheet was made with. false is a one-shot animation (an attack, a death) that should play once in an engine.

out_of_frameboolean

true when Ludo detected the sprite running past the edges of the frame during the animation, so parts of it are cut off. It is a hint, not a guarantee: look at the frames. The cut is in the generated video, so adjustSpritesheet can't recover it. Call editSpritesheet with edit_mode "outpaint" to extend the frame beyond its borders, or generate again with a larger margin on the axis that was cut (margin_ratio_horizontal / margin_ratio_vertical).

bad_loopboolean

true when Ludo detected that the animation doesn't loop cleanly. It is a hint, not a guarantee. Call editSpritesheet with edit_mode "fix_loop" to repair the loop.

request_idstring
created_atinteger

Changes