Character Swap – Analyze

namifusion/character-swap/analyze

Detect and track every person in a video with SAM3. Returns a character list with preview images and a track manifest for the generate step.

Parameters

NameTypeDefaultConstraintsDescription
resolutionResolutionselect720p480p | 720p

Output fields

FieldTypeDescription
objectsarrayDetected characters: obj_id, preview url, masked_url, coverage, representative_frame, bbox
video_infoobjectInput video info: width/height/fps/frame_count
analysis_idstringAnalysis session id
detected_objectsnumberNumber of detected characters
track_manifest_urlstringTrack manifest URL - pass it to the generate model

API

Call this model through one unified REST API. Get a key on the API Keys page.

cURL
# 1) Submit — returns { "task_uuid": "..." }
curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/namifusion/character-swap/analyze" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "resolution": "720p"
  }
}'

# 2) Poll until status is "completed", then read the output URLs
curl "https://www.namifusion.com/api/v1/marketplace/run/tasks/TASK_UUID" \
  -H "Authorization: Bearer YOUR_API_KEY"
Python
import time, requests

API_KEY = "YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

# 1) Submit
resp = requests.post(
    "https://www.namifusion.com/api/v1/marketplace/run/namifusion/character-swap/analyze",
    headers=HEADERS,
    json={
        "input": {
            "resolution": "720p"
        }
    },
)
resp.raise_for_status()  # 401/402/429/5xx stop here instead of polling a bad task
task = resp.json()

# 2) Poll until a terminal state (completed / failed / cancelled).
#    This model is allowed up to 1800s server-side.
deadline = time.time() + 1860
while task.get("status") not in ("completed", "failed", "cancelled"):
    if time.time() > deadline:
        raise TimeoutError(f"still {task.get('status')} — keep the task_uuid and poll later")
    time.sleep(3)
    poll = requests.get(f"https://www.namifusion.com/api/v1/marketplace/run/tasks/{task['task_uuid']}", headers=HEADERS)
    poll.raise_for_status()
    task = poll.json()

print(task["status"], task.get("output"))
JavaScript
const API_KEY = "YOUR_API_KEY";
const HEADERS = { Authorization: `Bearer ${API_KEY}` };

// 1) Submit
const resp = await fetch("https://www.namifusion.com/api/v1/marketplace/run/namifusion/character-swap/analyze", {
  method: "POST",
  headers: { ...HEADERS, "Content-Type": "application/json" },
  body: JSON.stringify({
    "input": {
      "resolution": "720p"
    }
  }),
});
if (!resp.ok) throw new Error(`submit failed: ${resp.status} ${await resp.text()}`);
let task = await resp.json();

// 2) Poll until a terminal state (completed / failed / cancelled).
//    This model is allowed up to 1800s server-side.
const deadline = Date.now() + 1860 * 1000;
while (!["completed", "failed", "cancelled"].includes(task.status)) {
  if (Date.now() > deadline) throw new Error(`still ${task.status} — keep the task_uuid and poll later`);
  await new Promise((r) => setTimeout(r, 3000));
  const poll = await fetch(`https://www.namifusion.com/api/v1/marketplace/run/tasks/${task.task_uuid}`, { headers: HEADERS });
  if (!poll.ok) throw new Error(`poll failed: ${poll.status}`);
  task = await poll.json();
}

console.log(task.status, task.output);

Documentation

Character Swap – Analyze

Step 1 of the character swap pipeline. Detects and tracks every person in the input video.

Input

FieldTypeRequiredNotes
video_urlstring (video URL)yesUp to 30 seconds, 480p/720p processing
resolution"480p" | "720p"noDefault 720p; must match the generate step

Output

  • objects[]: detected characters — obj_id, preview url, masked_url, coverage
  • track_manifest_url: pass this to namifusion/character-swap/generate
  • video_info: width/height/fps/frame_count

Typical flow

  1. POST /run/namifusion/character-swap/analyze with your video
  2. Poll GET /run/tasks/{task_uuid} until completed
  3. Pick the obj_id(s) you want to replace from objects
  4. Call namifusion/character-swap/generate with track_manifest_url + mappings

Pricing: 5 credits per call.