Heygen Avatar IV Serverless API

Single photo into a lifelike talking avatar video.

~140.96s
POST /v2/heygen-avatar-iv · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3from segmind import SegmindClient, InferenceFailed, InferenceTimeout
 4
 5# Async (v2) — recommended for long-running / video models.
 6# run() blocks up to 600s; submit_async + job.wait(timeout=...) sets a longer
 7# deadline and keeps the request_id so you can re-poll later.
 8client = SegmindClient()                      # reads SEGMIND_API_KEY
 9payload = {
10    "image_url": "https://segmind-inference-inputs.s3.amazonaws.com/f858aaa9-26a9-4749-83fc-08ac2240c1e2-148863a50eac17d1990d23b873818afa.png",
11    "video_title": "Hello Avatar",
12    "script": "Hello, this is an avatar demo.",
13    "voice_id": "f80e430f06b34b70b275c9c746436e37",
14    "video_orientation": "landscape",
15    "fit": "cover",
16    "custom_motion_prompt": "Subtle hand movements.",
17    "enhance_custom_motion_prompt": False,
18    "audio_url": "https://segmind-resources.s3.amazonaws.com/input/c8a1403e-d409-481d-b269-5eee0f01581f-0e55863604e421fff17ffbe89992a1cc.wav",
19    "resolution": "720p",
20}
21job = client.submit_async("heygen-avatar-iv", **payload)
22print(job.request_id)                         # available immediately
23try:
24    result = job.wait(timeout=900, interval=2.0)
25    print(result["status"])                  # COMPLETED
26    print(result.get("output"))              # model output (e.g. video URL)
27except InferenceTimeout as e:
28    print("still running:", e.request_id)    # re-poll later with this id
29except InferenceFailed as e:
30    print("failed:", e.detail)
31
32# Fast models (<=600s) can use the one-liner instead:
33# result = segmind.run("heygen-avatar-iv", **payload)

API Endpoint

POSThttps://api.segmind.com/v1/heygen-avatar-iv

Parameters

image_urlrequired
string (uri)

Provide a URL for the image. Example: a clear face image.

video_titlerequired
string

Specify the video title. Example: 'Welcome Video'.

audio_urloptional
string (uri)

Link to audio file. Example: 'https://audio.com/hello.wav'.

custom_motion_promptoptional
string

Describe avatar motion style. Example: 'energetic gestures'.

enhance_custom_motion_promptoptional
boolean

Enhance motions with AI. Example: 'true' for dynamic avatars.

Default: false
fitoptional
string

Select how avatar fits on screen. Example: 'contain' for full image.

Default: "cover"
Allowed values :
"cover""contain"
heightoptional
integer

Optional custom output height in pixels. Set both Width and Height to override the Resolution preset (sent to HeyGen as dimension).

Default: null
resolutionoptional
string

Output resolution. Avatar IV is flat-priced, so this affects pixels only, not cost. Note: 1080p/4k are accepted but currently downscaled to 720p until the HeyGen plan is upgraded.

Default: "720p"
Allowed values :
"720p""1080p""4k"
scriptoptional
string

Input the script text. Example: 'Hello, welcome!'.

video_orientationoptional
string

Choose video orientation. Example: 'portrait' for tall videos.

Default: "landscape"
Allowed values :
"portrait""landscape"
voice_idoptional
string

Select a voice ID. Example: 'Rex - Broadcaster'.

Default: "f80e430f06b34b70b275c9c746436e37"
Allowed values (61 total):
Onyx"26b2064088674c80b1e5fc5ab1a068ea"
Coral"6d5ef2eb0cb94193b90dd3cb397ae898"
Nova"71b0aa6499f6458e8b040818a017db1f"
Shimmer"8273e0a033074b5bb98d7ce3ab727bd9"
Lukas in car"8f0944e10aad4e989bce8f76807b6f36"
Lea in car"8f389c2237194f80b50fe7632dcc17b8"
Lea inside"9af7667dcc3145b790a5fb1ac226dfe3"
DARAN INSIDE 2 with mic"5a3cff20eddd491ca1196ffd1a868fdb"
Daran outside sitting"9ff7fd2dd9114c3bae005e62aa485e52"
Gail inside standing"acebd7b6419a44a388b9d1620614b29f"
+51 more
widthoptional
integer

Optional custom output width in pixels. Set both Width and Height to override the Resolution preset (sent to HeyGen as dimension).

Default: null

Response Type

Returns: Video

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/heygen-avatar-iv

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out