Skip to main content
Ditto replaces characters, props and backgrounds in an existing video using reference images. One request can carry up to 30 replacements, and they are all applied together in a single generation with one price and one output video. The API runs the same Ditto as the Ditto studio in Melius, and finished videos appear in Ditto’s History. See Ditto for the studio. Every Ditto endpoint lives under /api/v1/ditto:

1. Choose the video and reference images

Name each file in one of three ways:
  • By URL, with POST /ditto. Send the source video as sourceUrl and each reference image as a replacement’s referenceUrl. Melius downloads and checks each file before pricing, so nothing is charged for a file it can’t use.
  • By asset ID. Upload the file with the endpoints under Uploads in the API reference (POST /upload/init, POST /upload/sign-part and POST /upload/complete) and send the assetId it returns as sourceAssetId or referenceAssetId. You can also reuse the asset IDs of files already in your team.
  • By avatar, for a replacement image. See Use an avatar instead of uploading an image.
Each item takes one of these, never two. You can mix them across items.

Use files at a URL

A URL must be public https, carry no user name or password, and return the file itself with its Content-Type: A URL that can’t be downloaded, returns another type, is too large, or isn’t a readable video or image answers 400, and its message names the field. Nothing is charged or started. When Melius is already fetching many files, the request answers 503; retry it with the same Idempotency-Key. Melius stores each downloaded file for your team, keeps it out of Files, and returns its asset ID in the response’s input (sourceAssetId, replacements[].referenceAssetId). The same file sent again resolves to the same asset ID, so you can reuse those IDs in later requests. Length limits are the same as for an uploaded video: GET /ditto/models lists each model’s sourceDurationLimits, and sourceRange chooses the part of a longer video to use.

Use an avatar instead of uploading an image

To cast one of your team’s avatars or a Melius avatar, list them with GET /ditto/avatars:
custom avatars are your team’s own. curated avatars are made by Melius. Send an avatar’s kind and id as a replacement’s avatar, in place of its referenceAssetId:
An avatar your team can’t use answers 404, and one whose image isn’t made yet answers 409.

2. Start the video

Send the source video and an ordered replacements list. Each item has a referenceAssetId, a referenceUrl or an avatar, a targetKind (character, prop or background) and an optional targetDescription naming what it replaces in the video. Starting a video needs an editor role on the team and charges its price to the team.
The same request with files at URLs:
A targetDescription is optional for characters: Ditto picks the main person, or distinct people in reference order when there are several. It is required when two or more items replace props, or two or more replace backgrounds. Optional fields:
  • maxCredits — the most credits the video may cost. A higher price answers 402 and starts nothing.
  • sourceRange — { "startMs": 0, "endMs": 5000 } to use part of the video. The full video is used otherwise.
  • modelId and resolution — leave them out to use Ditto’s default. GET /ditto/models lists both.
  • audioMode — original (default) keeps the video’s audio; mute removes it.
  • additionalInstructions — extra direction that applies to every replacement. With it, replacements can be left out.
  • webhook — { "url": "https://…", "signingSecret": "…" } to get a signed notification when the video is ready or failed. A destination that is not public HTTPS answers 400 and starts nothing.
The response is 202 with a generationId and status: "preparing". When no model can make the video, the response is 400 and its message lists the reasons, such as a source longer than the model takes.

Retry safely

Save an Idempotency-Key before sending the request. If you lose the response, resend the identical request with the same key, and you get the original response back instead of a second video. Resending without a key starts another paid video. See Retry a submission safely for the conflict responses.

3. Get the result

Poll GET /ditto/<generationId> until status is ready or failed. preparing, rendering and finalizing mean it is still working, and estimatedWait gives the typical wait in seconds for its model. When it is ready, videoUrl links to the finished video and outputAssetId is its asset in your team. A failed video includes a failureMessage.
To stop polling, send webhook when starting the video, or register one afterward with POST /ditto/<generationId>/webhook. Melius sends a signed ditto.status_changed event when the video becomes ready or failed. See Generation webhooks for the payload and how to verify the signature.
Last modified on November 24, 2026