Heygen Avatar IV Serverless API
Single photo into a lifelike talking avatar video.
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) 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
https://api.segmind.com/v1/heygen-avatar-ivParameters
image_urlrequiredstring (uri)Provide a URL for the image. Example: a clear face image.
video_titlerequiredstringSpecify the video title. Example: 'Welcome Video'.
audio_urloptionalstring (uri)Link to audio file. Example: 'https://audio.com/hello.wav'.
custom_motion_promptoptionalstringDescribe avatar motion style. Example: 'energetic gestures'.
enhance_custom_motion_promptoptionalbooleanEnhance motions with AI. Example: 'true' for dynamic avatars.
falsefitoptionalstringSelect how avatar fits on screen. Example: 'contain' for full image.
"cover""cover""contain"heightoptionalintegerOptional custom output height in pixels. Set both Width and Height to override the Resolution preset (sent to HeyGen as dimension).
nullresolutionoptionalstringOutput 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.
"720p""720p""1080p""4k"scriptoptionalstringInput the script text. Example: 'Hello, welcome!'.
video_orientationoptionalstringChoose video orientation. Example: 'portrait' for tall videos.
"landscape""portrait""landscape"voice_idoptionalstringSelect a voice ID. Example: 'Rex - Broadcaster'.
"f80e430f06b34b70b275c9c746436e37""26b2064088674c80b1e5fc5ab1a068ea""6d5ef2eb0cb94193b90dd3cb397ae898""71b0aa6499f6458e8b040818a017db1f""8273e0a033074b5bb98d7ce3ab727bd9""8f0944e10aad4e989bce8f76807b6f36""8f389c2237194f80b50fe7632dcc17b8""9af7667dcc3145b790a5fb1ac226dfe3""5a3cff20eddd491ca1196ffd1a868fdb""9ff7fd2dd9114c3bae005e62aa485e52""acebd7b6419a44a388b9d1620614b29f"widthoptionalintegerOptional custom output width in pixels. Set both Width and Height to override the Resolution preset (sent to HeyGen as dimension).
nullResponse 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
POST /v2/heygen-avatar-ivSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- 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.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out