Generate

Recast

API parameters and input requirements for editing an existing video with a reference image.

Use model: "MiniMax-H3" and task_type: "RECAST" to replace a person, head, outfit, object or background in an existing video. Each request takes one source video, one reference image and one edit scope.

API request

Upload the video and image with POST /api/v0/upload, then prefix the returned artifact_path values with @input/. See the REST API guide for authentication and uploads.

Replace a person
curl --fail-with-body https://api.machgen.ai/api/v0/generate \
  -H "Authorization: Bearer $MACHGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-H3",
    "task_type": "RECAST",
    "prompt": "Replace the woman in the white dress with the person in the reference image, including her face, hair and outfit. Preserve her movement, the other people, the background and camera motion.",
    "edit_config": {"scope": "person"},
    "src_video_urls": ["@input/<video_artifact_path>"],
    "src_image_urls": ["@input/<image_artifact_path>"],
    "video_config": {
      "height": 768,
      "fps": 24,
      "duration_secs": 10
    }
  }'

The response contains a task_id. Poll GET /api/v0/tasks/{task_id} until COMPLETED or FAILED, then download a completed result from GET /api/v0/assets/{task_id}. See Check status and download for the response format and commands. Failed tasks include an error_msg.

Parameters

FieldRequiredDescription
src_video_urlsYesExactly one source video.
src_image_urlsYesExactly one replacement reference image, for every scope.
promptYesThe edit instruction, up to 4,000 characters. Identify the source subject and describe the replacement.
edit_config.scopeYesperson, head, clothing, object or background.
edit_config.targetNoAn additional description of the target as it appears in the source. Omit when the prompt identifies it clearly.
video_config.heightYes768, selecting the output's shorter side.
video_config.duration_secsYesSource duration rounded up to whole seconds, from 1 to 30. The measured source duration determines the output length.
video_config.fpsNo24. The output is always 24 FPS.

Omit video_config.num_frames, width and aspect_ratio. Recast derives the output dimensions and duration from the source; duration_secs does not trim or extend it.

Edit scopes

scopeEditReference image
personReplace the person's face, hair and outfit.Replacement person.
headReplace the face and hair, retaining the source body and clothing.Replacement face and hair.
clothingReplace the outfit, retaining the source person's identity.Desired outfit.
objectReplace the object identified in the prompt.Replacement object.
backgroundReplace the setting, retaining the foreground subjects.Desired location.

The prompt identifies the subject in the source video. The image supplies the replacement. For example, a clothing edit can use "Replace the dancer's green outfit with the red outfit in the reference. Keep her face, hair and choreography." with "edit_config": {"scope": "clothing"}. An optional target, such as "the dancer in green", describes the original appearance, not the reference.

Input limits

InputLimits
VideoMP4 or MOV with H.264 or H.265 video; up to 50 MB; 1-30 seconds; 23.976-60 FPS.
Video dimensionsAt most 2,073,600 pixels in total, such as 1920x1080 or 1080x1920. Each edge must be at least 256 pixels; width-to-height ratio must be 0.4-2.5.
Source audioOptional. AAC or MP3, mono or stereo.
Reference imageJPG, PNG, WebP, HEIC, HEIF or GIF. Only the first frame of an animated image is used.

Output

The result is an MP4 at 768p and 24 FPS. Dimensions follow the source aspect ratio, rounded to multiples of 32 pixels. The source audio is retained, and the source duration is matched to 24 FPS precision. Read the actual dimensions and duration from the completed task's metadata.

Recast regenerates video frames. Movement and composition are guided by the source; regions outside the requested edit are not guaranteed to remain pixel-identical. For additional replacements, submit the completed output as the source of a separate request.