December 12, 2024 · Last updated on April 23, 2025
Send personalized messages using HeyGen’s API: a step-by-step walkthrough
# API
# Personalized Video
Creating personalized birthday videos using templates and integrating OpenAI to generate dynamic scripts
HeyGen’s API empowers you to automate video creation, personalize content at scale, and integrate avatars into your projects. In this guide, we’ll demonstrate two examples based on Alec’s webinar:
1) Creating Personalized Birthday Videos Using Templates
2) Integrating OpenAI to Generate Dynamic Scripts
Let’s get started!
Step 1: Access the HeyGen API Documentation
Visitdocs.heygen.com to access HeyGen’s official API documentation. This contains:
Setup guides for beginners.
Detailed API references for developers.
If you’re unfamiliar with APIs, don’t worry—this guide will walk you through the essentials.
Step 2: Create a Video Template
Templates allow you to design reusable videos with customizable elements (variables). These templates are central to automating video creation.
How to Create a Template:
Log into HeyGen and navigate to the Templates section.
Click Create Template and design your video:
Add your avatar, background, and any static elements (e.g., text, images).
Define Variables for dynamic content:
Select an element (e.g., text or image).
Click the API button to assign a variable name (e.g., name, message, background).
Save the template and copy its Template ID by clicking the three dots next to the template.
Step 3: Generate Videos Using the Template API
Python Example:
Below is a corrected script to dynamically generate a personalized birthday video: