HeyGen Video Text-to-Video
Generate a 5- to 15-second video with sound from text, optionally guided by reference images, video, or audio.
Overview
Use the text to video endpoint with a supported model. Use the returned Task ID to retrieve its state, or provide callback_url for the deliveries documented below.
Quick start
- Create an API key and set it as RUNAPI_API_KEY.
- Choose a supported model and send a POST request whose body matches that model's schema.
- Store the returned task ID, then poll until a terminal state or handle the callbacks documented below.
Endpoint
- Base URL
https://runapi.ai- API version
v1- Authentication
Authorization: Bearer YOUR_API_TOKEN
Supported models
Open a model page for current pricing, rate limits, and commercial-usage details.
Request schema
Fields and allowed values depend on the selected model. When supplied, callback_url receives the Task deliveries documented below.
heygen-video-110 fields
aspect_ratiostringGenerated video aspect ratio; adaptive follows the first reference image or video and is available only with reference media at 480p or 768p.
Allowed values:adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16
callback_urlstringWebhook URL for async notifications.
duration_secondsintegerGenerated video duration in seconds.
Allowed values:5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Default: 5
modelstringModel slug.
output_resolutionstringGenerated video resolution; 1080p and 2k support only 16:9 and 9:16.
Allowed values:480p, 768p, 1080p, 2k
Default: 768p
promptstringVideo generation prompt describing the scene, dialogue, and sound.
Range:1 - 16000
reference_audio_urlsarrayPublic HTTPS reference audio URLs, up to 32 MB each; requires reference images or videos.
Item limit:3
reference_image_urlsarrayPublic HTTPS reference image URLs, up to 16 MB each; up to 12 reference files in total across images, videos, and audio.
Item limit:9
reference_video_urlsarrayPublic HTTPS reference video URLs with aspect ratio between 1:4 and 4:1, up to 32 MB each; only the first 5 seconds of each video are used.
Item limit:3
seedintegerRandom seed for reproducible generation.
Range:0 - 4294967295
Conditional rules
These requirements apply when all listed conditions match.
-
When
reference_audio_urls present- Required
- Not accepted
-
When
reference_image_urls absent,reference_video_urls absent- Required
- Not accepted
-
When
output_resolution = 1080p- Required
- Not accepted
-
When
output_resolution = 2k- Required
- Not accepted
Create acceptance
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
},
"task_replayed": {
"type": "boolean"
}
},
"required": [
"id",
"status"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"id": "tsk_reference_demo",
"status": "processing"
}
Polling processing
GET /api/v1/heygen_video/text_to_video/:id
Response schema
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
}
},
"required": [
"id",
"status"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"id": "tsk_reference_demo",
"status": "processing"
}
Polling completed
GET /api/v1/heygen_video/text_to_video/:id
Response schema
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
},
"usage": {
"properties": {
"cost": {
"type": "number"
}
},
"required": [
"cost"
],
"type": "object",
"unevaluatedProperties": false
},
"videos": {
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
}
},
"required": [
"id",
"status",
"videos",
"usage"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"id": "tsk_reference_demo",
"status": "completed",
"usage": {
"cost": 0.05
},
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
Polling failed
GET /api/v1/heygen_video/text_to_video/:id
Response schema
{
"properties": {
"error": {
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Task processing failed.",
"id": "tsk_reference_demo",
"status": "failed"
}
Customer callback: completed
POST callback_url
Response schema
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
},
"usage": {
"properties": {
"cost": {
"type": "number"
}
},
"required": [
"cost"
],
"type": "object",
"unevaluatedProperties": false
},
"videos": {
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
}
},
"required": [
"id",
"status",
"videos",
"usage"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"id": "tsk_reference_demo",
"status": "completed",
"usage": {
"cost": 0.05
},
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
Customer callback: failed
POST callback_url
Response schema
{
"properties": {
"error": {
"oneOf": [
{
"type": "string"
},
{
"properties": {
"code": {
"type": "string"
},
"limit_cents": {
"type": "integer"
},
"message": {
"type": "string"
},
"reset_at": {
"format": "date-time",
"type": [
"string",
"null"
]
},
"used_cents": {
"type": "integer"
},
"window": {
"enum": [
"1h",
"1d",
"7d",
"daily",
"weekly",
"monthly",
"lifetime"
],
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object",
"unevaluatedProperties": false
}
]
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": {
"code": "generation_failed",
"message": "Task processing failed."
},
"id": "tsk_reference_demo",
"status": "failed"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Authentication required"
}
Errors
GET /api/v1/heygen_video/text_to_video/:id
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Authentication required"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"oneOf": [
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "Human-readable validation summary.",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
Response example
{
"error": "model must be one of: heygen-video-1"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Insufficient balance"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "API key credit limit exceeded"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "The request uses features that are not supported for the selected model"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Rate limit reached. Please retry later."
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Service under maintenance, please try again later"
}
Errors
POST /api/v1/heygen_video/text_to_video
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "The request timed out"
}
Errors
GET /api/v1/heygen_video/text_to_video/:id
Response schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
Response example
{
"error": "Task with id 'tsk_reference_demo' not found"
}
Generated Code Samples
Use cURL directly, or install an SDK for your language. Each sample submits the validated request shown in this reference.
Install
pip install runapi-heygen-video
import os
from runapi.heygen_video import HeyGenVideoClient
client = HeyGenVideoClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_video.create(
model="heygen-video-1",
prompt="A plant supervisor in a plain grey coat stands beside a conveyor line and speaks to camera.",
aspect_ratio="16:9",
output_resolution="768p"
)