Tutorial
How to Call heygen-avatar-6-turbo/identity-to-video via the HiAPI API
On this page
What the identity-to-video endpoint actually does
Identity-to-video is the branch of avatar video generation where the visual subject is defined by an identity image you supply, not by a fixed preset avatar you pick from a gallery. You hand the endpoint a face, the service animates that face to match an audio track or a script, and you get back a rendered video. The model name heygen-avatar-6-turbo/identity-to-video makes the two halves explicit: heygen-avatar-6-turbo is the avatar video family, identity-to-video is the variant that expects your own identity asset.
That distinction drives everything about how you plan the integration. Your request is only as good as the two inputs that define the result: the identity image (what the viewer sees) and the audio or script (what the viewer hears). Everything else — endpoint path, auth, polling — is plumbing.
What you get back is a rendered video artifact, not a stream and not a synchronous payload. Plan for job submission, then retrieval. That means your pipeline needs a place to put the finished file (object storage, a CDN, a signed URL you hand to your app) and a way to correlate the returned job identifier with the record of what you asked for.
Prepare your identity image and audio before the request
The most reliable way to avoid failing your first call is to treat input preparation as a separate step with its own acceptance criteria. Do this before you touch the API.
The identity image. Choose a single, clean, front-facing portrait. The subject should be the only face in frame, evenly lit, reasonably sharp, and not obscured by hands, hair, masks, or heavy filters. Avoid extreme crops that cut off the jawline, avoid side profiles, and avoid images that already contain text or watermarks — the model has to interpret the whole frame as an identity, and clutter invites artifacts. Make sure the asset is reachable by the request: either an uploaded file reference or a publicly accessible URL, depending on how you're sending it. Verify that the URL resolves without an auth cookie before you build the request.
The audio or the script. Decide now which path you're taking, because it changes the payload. If you supply audio, the video length follows the audio length and the model aligns mouth movement to the waveform — so use clean speech with minimal background music and no long silences at the head. If you supply a script, the service handles the speech synthesis and the timing is derived from the generated audio. Pick a voice (or accept the default) and keep the script in plain text.
Order of operations. Upload or host the identity image first, confirm it's retrievable, then confirm your audio asset the same way, then compose the payload. Debugging a request that contains two unverified assets is much harder than debugging a request with one variable at a time.
Build the request: endpoint, auth, and payload shape
Every call to the HiAPI platform follows the same skeleton, so once you've internalized it for one model you can reuse it across the catalog.
- Base URL and path. Requests go to the HiAPI API host, with the model identified in the path:
heygen-avatar-6-turbo/identity-to-video. The full model page lives at /models/heygen-avatar-6-turbo-identity-to-video and is the authoritative reference for the current field list. - Authentication. A bearer token in the
Authorizationheader, using the API key from your HiAPI account. Never place the key in the URL or in client-side code. - Content type.
Content-Type: application/json, with the identity and audio inputs carried as fields inside the JSON body. - Payload fields. In practice the body carries the identity image (a URL or upload reference), the audio input (an audio URL or an uploaded file reference) or the script text plus a voice selection, and any output or rendering options the model exposes. Field names are case-sensitive — copy them from the model reference rather than from memory.
The request is a submission, so the response you care about first is the job handle, not the video. Treat the submit step and the retrieval step as two distinct functions in your code, even if you call them back to back.
Run it with curl
Here is a complete request you can adapt. Replace the placeholders — the uppercase tokens in angle brackets — with your own values.
curl -X POST "<HIAPI_API_BASE>/<MODEL_PATH>" \
-H "Authorization: Bearer <HIAPI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "heygen-avatar-6-turbo/identity-to-video",
"identity_image": "<PUBLIC_URL_TO_IDENTITY_IMAGE>",
"audio": "<PUBLIC_URL_TO_AUDIO_FILE>"
}'
For the script-input path, swap the audio field for the script text and a voice:
curl -X POST "<HIAPI_API_BASE>/<MODEL_PATH>" \
-H "Authorization: Bearer <HIAPI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "heygen-avatar-6-turbo/identity-to-video",
"identity_image": "<PUBLIC_URL_TO_IDENTITY_IMAGE>",
"script": "Welcome to the product tour. Let me show you around.",
"voice": "<VOICE_ID>"
}'
Run the first version once with a short audio clip — five to ten seconds — before you commit to a full-length asset. A short clip exercises every part of the path: identity parsing, audio ingestion, rendering, and retrieval.
Run it with Python
The same request in Python, structured so the submit and the read-back are separate, testable functions:
import os
import requests
API_BASE = os.environ["HIAPI_API_BASE"]
API_KEY = os.environ["HIAPI_API_KEY"]
MODEL = "heygen-avatar-6-turbo/identity-to-video"
def submit_identity_video(identity_image_url, audio_url):
response = requests.post(
f"{API_BASE}/<MODEL_PATH>",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"model": MODEL,
"identity_image": identity_image_url,
"audio": audio_url,
},
timeout=60,
)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
job = submit_identity_video(
identity_image_url=os.environ["IDENTITY_IMAGE_URL"],
audio_url=os.environ["AUDIO_URL"],
)
print(job)
Keeping the credentials in environment variables and the model identifier in a module constant means the same function works in a script, a queue worker, or a web handler without edits. Log the full submit response — including the job identifier and any echoed parameters — so you can reconstruct a failed render later.
Handle the async result and poll for the video
Video rendering takes time, and the endpoint reflects that: the submit response returns a job you then track. Don't assume the first response contains a playable file.
Read the submit response for the job identifier and the initial status. Then poll the job's status endpoint on an interval — a few seconds between checks is reasonable for short clips; back off for longer ones — until the status reaches a terminal state. On success, read the output location from the response and download or hand off the URL. On failure, capture the error payload before you discard the job record; it's the only thing that will tell you which input was rejected.
Wrap the poll in a maximum number of attempts or a wall-clock deadline. A loop that waits forever turns a transient provider issue into an outage in your own system. When the deadline expires, mark the job as timed out in your own records and decide explicitly whether to retry from scratch — a fresh submission with identical inputs — or to surface the failure.
Troubleshoot the common failures
Group your diagnostics by which input the error blames.
- Identity image rejected. Usually an unreachable URL, an unsupported format, a frame with no clear single face, or a file too small to interpret. Verify the URL resolves outside your browser session, then simplify the image: one face, front-facing, well lit.
- Audio unusable. Check that the audio URL is public and that the format is supported. Very quiet recordings, long leading silence, or heavy background music can produce poor lip alignment rather than a hard error — if the result looks wrong rather than failing, the audio is the first suspect.
- Malformed request. Field names that don't match the model reference, a JSON body sent without the JSON content type, or sending both an audio field and a script field when the model expects one. Compare your body field by field against /models/heygen-avatar-6-turbo-identity-to-video.
- Auth problems. A missing or malformed
Authorizationheader, a key with a typo, or a key sent as a query parameter. Confirm the header format first — it's the cheapest check. - Stuck jobs. A job that never leaves the pending state points at input ingestion (an asset the service can't fetch) rather than at rendering. Re-verify asset reachability and permissions, then resubmit.
A useful habit: log the request body with credentials stripped, alongside the job identifier, for every submission. When something breaks, you'll compare what you sent against the model reference in seconds instead of minutes.
Fit it into a real pipeline and choose wisely
In production, wrap the submit-and-poll pattern behind an idempotency key so a retried request doesn't produce duplicate renders. Store finished videos in your own object storage rather than relying on a transient URL, and record the input assets alongside the output so you can regenerate a video when the identity or the script changes. Set the poll timeout from your own latency budget, and treat timeouts as retryable only when the inputs are known-good.
This endpoint is the right choice when the person on screen must be a specific, recognizable individual — a founder's message, a personalized sales follow-up, a localized version of a training video — and you have a clean portrait to work from. If you need a generic presenter and don't care whose face appears, a preset-avatar variant will save you the identity-asset work. If the face is fixed but the content is highly dynamic, the decisive question is whether your audio pipeline or the model's synthesis should own the speech; that answer determines whether you send audio or a script.
The full field reference lives on the model page: heygen-avatar-6-turbo/identity-to-video. Start with a short clip, confirm the whole submit-and-poll path end to end, and scale the asset length once the pipeline is boring.
Related articles
View all articles →-
Tutorial
HeyGen Avatar 6 Turbo Ref Video-to-Video API: Working curl and Python Request
A practical integration path from first call to a finished video
10 min read -
Tutorial
Midjourney Niji 8 in Practice: Inputs, Settings, and Acceptance for Four Types of Japanese-Style Illustration Delivery Tasks
From game characters to light novel illustrations, use structured fields to complete image selection and acceptance
-
Tutorial
5 GLM 5.4 Use Cases for Developers: From Large Codebases to 3D
3 min read