● nureta
Docs
Video

Digital twin

Make a character who resembles your own photo: check the photo and the description, get consent, generate, save and use it in videos.

This page uses NURETA_URL, NURETA_KEY and the wait_task helper from Get started.

Draw a new character who looks like the person in a photo, save it, and use it in any video. Use your own photo, or the photo of an adult who agreed to this use. The API draws a new person who resembles the photo: never a copy of the person in it.

Nothing is charged until step 5 ($0.10 for 2 images). The checks in steps 2 and 4 are free, but they need a balance of at least $0.10.

Step 1. Upload the photo

Use a clear photo of one adult, with the face visible.

UP=$(curl -s -X POST "$NURETA_URL/api/v3/contents/uploads" \
  -H "Authorization: Bearer $NURETA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fileName": "me.jpg", "contentType": "image/jpeg"}')
curl -s -X PUT "$(printf '%s' "$UP" | jq -r .uploadUrl)" \
  -H "Content-Type: $(printf '%s' "$UP" | jq -r .contentType)" --data-binary @me.jpg
PHOTO=$(printf '%s' "$UP" | jq -r .assetUrl)

Step 2. Check the photo

CHECK=$(curl -s -X POST "$NURETA_URL/api/v3/library/reference-checks" \
  -H "Authorization: Bearer $NURETA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_url": "'"$PHOTO"'"}')
printf '%s' "$CHECK" | jq '{sex, age, age_min, age_max, runs_left, error}'
SEX=$(printf '%s' "$CHECK" | jq -r .sex)
AGE=$(printf '%s' "$CHECK" | jq .age)
AGE_GROUP=$(printf '%s' "$CHECK" | jq -r '.age | if . >= 50 then "50plus" elif . >= 40 then "40s" elif . >= 30 then "30s" else "20s" end')
{"sex": "female", "age": 32, "age_min": 29, "age_max": 36, "runs_left": 3}

The check takes up to a minute. It reads the sex and the age range from the photo, and it gives a check_token that is valid for 24 hours. runs_left is how many rounds (step 5) this photo has left: 3 per 24 hours. The person must clearly be older than 25. A photo that fails the check is deleted at once.

Before you go on, the person who sends the photo must confirm this text. Show it in your app and keep their answer:

The person in this photo is me, or an adult who agreed to this use. I'm 18 or older, and I won't present the drawn character as the real person.

Send "consent": true in step 5 only after this confirmation. The API records the time and the API key of each use.

Step 4. Check the description

Describe the character. spec.sex is the sex from step 2, spec.style is realistic, and controls.age is an age between age_min and age_max (here the age from step 2). spec.age_group follows that age: 20s (25–29), 30s, 40s or 50plus. Step 2 set SEX, AGE and AGE_GROUP for you.

Give hair and clothes that differ from the photo. When the description copies two or more traits of the photo, the check that the new face is not too alike gets stricter, and fewer drawn faces pass.

SPEC=$(jq -nc --arg sex "$SEX" --arg group "$AGE_GROUP" \
  '{sex: $sex, age_group: $group, style: "realistic", hair: "long auburn waves", outfit: "green knit sweater"}')
DESC=$(curl -s -X POST "$NURETA_URL/api/v3/library/description-checks" \
  -H "Authorization: Bearer $NURETA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"spec": '"$SPEC"', "prompt": "a warm smile", "controls": {"age": '"$AGE"'},
       "check_token": "'"$(printf '%s' "$CHECK" | jq -r .check_token)"'"}')
printf '%s' "$DESC" | jq '{ok: (.desc_token != null), error}'
DESC_TOKEN=$(printf '%s' "$DESC" | jq -r .desc_token)

The desc_token is valid for 1 hour, and only for exactly this spec, prompt and controls. If you change the description, check it again.

Step 5. Generate, then save a candidate

Send the same spec, prompt and controls as in step 4, with the photo and both tokens.

GEN_ID=$(curl -s -X POST "$NURETA_URL/api/v3/library/generations" \
  -H "Authorization: Bearer $NURETA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "character", "spec": '"$SPEC"', "prompt": "a warm smile", "controls": {"age": '"$AGE"'},
       "consent": true,
       "reference": {"image_url": "'"$PHOTO"'",
                     "check_token": "'"$(printf '%s' "$CHECK" | jq -r .check_token)"'",
                     "desc_token": "'"$DESC_TOKEN"'"}}' | jq -r .id)
until S=$(curl -s "$NURETA_URL/api/v3/library/generations/$GEN_ID" -H "Authorization: Bearer $NURETA_KEY" | jq -r .status); \
      [ "$S" = done ] || [ "$S" = rejected ] || [ "$S" = failed ]; do sleep 5; done; echo "$S"
curl -s "$NURETA_URL/api/v3/library/generations/$GEN_ID" -H "Authorization: Bearer $NURETA_KEY" | jq '{status, reject_code, candidates}'
# Save only when the status is done (a failed round has no candidate and is refunded).
TWIN_ID=$(curl -s -X POST "$NURETA_URL/api/v3/library/items" \
  -H "Authorization: Bearer $NURETA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Me", "from": "'"$GEN_ID"'#0"}' | jq -r .id)

When you save a candidate, the photo is deleted. If you save nothing, the photo is deleted 24 hours after the check. To delete it now (for example, the user picked another photo), send POST /api/v3/library/reference-photos/release with {"image_url": "<the photo's assetUrl>"}.

Step 6. Use the character in a video

Use it like any saved character: see Save a character.

curl -s -X POST "$NURETA_URL/api/v3/contents/generations/tasks" \
  -H "Authorization: Bearer $NURETA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "seahorse-480p", "duration": 5,
       "content": [
         {"type": "text", "text": "She raises a glass and smiles at the camera."},
         {"type": "library_item", "library_item": {"id": "'"$TWIN_ID"'"}, "person": "p1"}
       ],
       "cast": {"members": [{"id": "p1", "sex": "female", "name": "Me"}]}}' | jq '{id, status}'

Common errors

You getWhyFix
422 library_ref_no_face / library_ref_many_facesNo clear face, or more than one person.Use a photo of one person with the face visible.
422 library_ref_ageThe person may look 25 or younger.Use another photo. The photo was deleted.
422 library_ref_public_figureThe photo appears to show a public figure.Use a photo of a private person who agreed.
422 library_ref_runs_usedThis photo (or another photo of the same person) was used for 3 rounds in the last 24 hours. runs_left in step 2 shows how many are left.Save a candidate you already have, or try again later.
422 library_ref_uncheckedThe check could not decide, for example whether the person is clearly older than 25.Use a clear photo in which the person clearly looks adult, or retry later. Upload it again: the photo was deleted.
409 library_limit_reached with limit: "daily_reference_refunds" (step 4)2 photo rounds today ended with no image.Wait until resets_at (midnight in your time_zone).
Step 5 ends failed with reject_code: "library_ref_no_candidate"No drawn face passed the checks: too alike, another sex, background or age, or not clearly adult. The $0.10 is refunded.Use a clear, real photo of one adult. Give hair and clothes that differ from the photo. At most 2 such rounds a day.
422 library_prompt_rejected (step 4)The description asks for something the check refuses, for example another ethnic background or a real person (categories).Change the description.
422 library_ref_invalidThe sex or age in spec does not match the photo, a token expired, or the description changed after step 4.Use the values from step 2, and check the description again.
422 library_consent_requiredconsent is not true (a string "true" does not count).Send "consent": true after the person confirmed.
403 AccountOverdueErrorThe balance is under $0.10.Add funds.