Description
Add a HeyGen video generation tool so PraisonAI agents can create AI avatar videos programmatically. HeyGen is the leading AI video platform for generating photorealistic talking-head avatar videos from text scripts.
Use Cases
- Content automation: Agents generate marketing/explainer videos from text
- Multi-agent pipelines: Research agent → Script agent → HeyGen video agent
- Personalized outreach: Agents create personalized video messages at scale
HeyGen API Reference
Endpoints Required
| Action |
Method |
Endpoint |
| List Avatars |
GET |
https://api.heygen.com/v2/avatars |
| List Voices |
GET |
https://api.heygen.com/v2/voices |
| Generate Video |
POST |
https://api.heygen.com/v2/video/generate |
| Check Status |
GET |
https://api.heygen.com/v1/video_status.get?video_id={id} |
Auth
Header: x-api-key: <HEYGEN_API_KEY>
Generate Video Request Body
{
"title": "My Video",
"video_inputs": [
{
"character": {
"type": "avatar",
"avatar_id": "YOUR_AVATAR_ID"
},
"voice": {
"type": "text_to_speech",
"voice_id": "YOUR_VOICE_ID",
"input_text": "Hello, this is generated by HeyGen API."
}
}
],
"dimension": { "width": 1920, "height": 1080 }
}
Key Details
- Async: Returns
video_id immediately, poll status endpoint until completed
- Avatar IV: Latest model — use
use_avatar_iv_model: true for photorealistic quality
- Credits: ~1 credit/min standard, ~6 credits/min Avatar IV
- Limits: 5000 chars per script, 1-50 scenes per video
- Webhook: Optional
callback_url for completion notification
Implementation Requirements
Tool Functions (using @tool decorator pattern)
from praisonaiagents import Agent, tool
@tool
def heygen_list_avatars() -> list:
"""List available HeyGen avatars with their IDs."""
@tool
def heygen_list_voices() -> list:
"""List available HeyGen voices with their IDs."""
@tool
def heygen_generate_video(
script: str,
avatar_id: str = "default",
voice_id: str = "default",
title: str = "Generated Video",
width: int = 1920,
height: int = 1080
) -> dict:
"""Generate an AI avatar video from a text script using HeyGen."""
@tool
def heygen_video_status(video_id: str) -> dict:
"""Check the status of a HeyGen video generation and return download URL when ready."""
Agent Usage Example
from praisonaiagents import Agent
from praisonai_tools import heygen_generate_video, heygen_list_avatars, heygen_list_voices, heygen_video_status
agent = Agent(
name="Video Creator",
instructions="You create professional AI avatar videos using HeyGen.",
tools=[heygen_list_avatars, heygen_list_voices, heygen_generate_video, heygen_video_status]
)
result = agent.start("Create a 30-second explainer video about PraisonAI multi-agent framework")
print(result)
Reference Pattern
Follow the existing LumaLabsTool pattern in praisonai_tools/tools/lumalabs_tool.py:
- Lazy imports (
import requests inside functions)
- Environment variable:
HEYGEN_API_KEY
- All parameters as function arguments (agent-discoverable)
- Proper error handling with descriptive messages
- Both class-based (
HeyGenTool) and functional (@tool) interfaces
Location
- Tool implementation:
praisonai_tools/tools/heygen_tool.py
- Export from:
praisonai_tools/__init__.py
Environment Variables
HEYGEN_API_KEY — Required, from HeyGen dashboard Settings > API
Acceptance Criteria
Description
Add a HeyGen video generation tool so PraisonAI agents can create AI avatar videos programmatically. HeyGen is the leading AI video platform for generating photorealistic talking-head avatar videos from text scripts.
Use Cases
HeyGen API Reference
Endpoints Required
GEThttps://api.heygen.com/v2/avatarsGEThttps://api.heygen.com/v2/voicesPOSThttps://api.heygen.com/v2/video/generateGEThttps://api.heygen.com/v1/video_status.get?video_id={id}Auth
Header:
x-api-key: <HEYGEN_API_KEY>Generate Video Request Body
{ "title": "My Video", "video_inputs": [ { "character": { "type": "avatar", "avatar_id": "YOUR_AVATAR_ID" }, "voice": { "type": "text_to_speech", "voice_id": "YOUR_VOICE_ID", "input_text": "Hello, this is generated by HeyGen API." } } ], "dimension": { "width": 1920, "height": 1080 } }Key Details
video_idimmediately, poll status endpoint untilcompleteduse_avatar_iv_model: truefor photorealistic qualitycallback_urlfor completion notificationImplementation Requirements
Tool Functions (using
@tooldecorator pattern)Agent Usage Example
Reference Pattern
Follow the existing
LumaLabsToolpattern inpraisonai_tools/tools/lumalabs_tool.py:import requestsinside functions)HEYGEN_API_KEYHeyGenTool) and functional (@tool) interfacesLocation
praisonai_tools/tools/heygen_tool.pypraisonai_tools/__init__.pyEnvironment Variables
HEYGEN_API_KEY— Required, from HeyGen dashboard Settings > APIAcceptance Criteria
heygen_list_avatars()returns available avatarsheygen_list_voices()returns available voicesheygen_generate_video(script, avatar_id, voice_id)creates a video and returnsvideo_idheygen_video_status(video_id)returns status and download URL when completeimport requests)@tooldecorator for simple usage