Skip to main content
POST
/
v3
/
avatars
Create Avatar
curl --request POST \
  --url https://api.heygen.com/v3/avatars \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "type": "<string>",
  "name": "<string>",
  "prompt": "<string>",
  "reference_images": [
    {
      "type": "<string>",
      "url": "<string>"
    }
  ],
  "avatar_group_id": "<string>",
  "avatar_id": "<string>"
}
'
import requests

url = "https://api.heygen.com/v3/avatars"

payload = {
"type": "<string>",
"name": "<string>",
"prompt": "<string>",
"reference_images": [
{
"type": "<string>",
"url": "<string>"
}
],
"avatar_group_id": "<string>",
"avatar_id": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: '<string>',
name: '<string>',
prompt: '<string>',
reference_images: [{type: '<string>', url: '<string>'}],
avatar_group_id: '<string>',
avatar_id: '<string>'
})
};

fetch('https://api.heygen.com/v3/avatars', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.heygen.com/v3/avatars",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => '<string>',
'name' => '<string>',
'prompt' => '<string>',
'reference_images' => [
[
'type' => '<string>',
'url' => '<string>'
]
],
'avatar_group_id' => '<string>',
'avatar_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.heygen.com/v3/avatars"

payload := strings.NewReader("{\n \"type\": \"<string>\",\n \"name\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\"\n }\n ],\n \"avatar_group_id\": \"<string>\",\n \"avatar_id\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.heygen.com/v3/avatars")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"<string>\",\n \"name\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\"\n }\n ],\n \"avatar_group_id\": \"<string>\",\n \"avatar_id\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.heygen.com/v3/avatars")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"<string>\",\n \"name\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n {\n \"type\": \"<string>\",\n \"url\": \"<string>\"\n }\n ],\n \"avatar_group_id\": \"<string>\",\n \"avatar_id\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "avatar_item": {
      "id": "<string>",
      "name": "<string>",
      "group_id": "ag_abc123",
      "preview_image_url": "https://files.heygen.ai/look/business_preview.jpg",
      "preview_video_url": "https://files.heygen.ai/look/business_preview.mp4",
      "gender": "female",
      "tags": [
        "<string>"
      ],
      "default_voice_id": "1bd001e7e50f421d891986aad5c8bbd2",
      "supported_api_engines": [
        "<string>"
      ],
      "image_width": 1920,
      "image_height": 1080,
      "status": "completed",
      "error": {
        "code": "<string>",
        "message": "<string>"
      }
    },
    "avatar_group": {
      "id": "<string>",
      "name": "<string>",
      "created_at": 123,
      "looks_count": 123,
      "preview_image_url": "https://files.heygen.ai/avatar/anna_preview.jpg",
      "preview_video_url": "https://files.heygen.ai/avatar/anna_preview.mp4",
      "gender": "female",
      "default_voice_id": "1bd001e7e50f421d891986aad5c8bbd2",
      "consent_status": "approved",
      "status": "completed",
      "error": {
        "code": "<string>",
        "message": "<string>"
      }
    }
  }
}
{
"error": {
"code": "invalid_parameter",
"message": "At least one file source is required: provide image, video, or consent_video.",
"param": "files",
"doc_url": null
}
}
{
"error": {
"code": "authentication_failed",
"message": "Invalid or expired API key. Verify your x-api-key header.",
"param": null,
"doc_url": null
}
}
{
"error": {
"code": "request_in_progress",
"message": "A request with this Idempotency-Key is already in progress. Retry shortly.",
"param": null,
"doc_url": null
}
}
{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Retry after the duration specified in the Retry-After header.",
"param": null,
"doc_url": null
}
}

Authorizations

x-api-key
string
header
required

HeyGen API key. Obtain from your HeyGen dashboard.

Headers

Idempotency-Key
string

Optional client-supplied key for safely retrying mutations. Subsequent calls within 24 hours that share this key replay the original response — even if the request body differs slightly (a warning is logged). A retry that arrives while the original is still in flight gets a 409 request_in_progress. Keys must be 1–255 characters from [A-Za-z0-9_:.-]; a UUID is a safe default. Scope is per-endpoint and per-resource: the same key on a different route or path parameter is independent.

Required string length: 1 - 255
Pattern: ^[A-Za-z0-9_\-:.]{1,255}$

Body

application/json

Discriminated union for POST /v3/avatars request body.

type
string
required

Must be 'prompt' for AI-generated avatars.

Allowed value: "prompt"
name
string
required

Name of the avatar.

prompt
string
required

Prompt for avatar generation.

Maximum string length: 1000
reference_images
(AssetUrl · object | AssetId · object | AssetBase64 · object)[] | null

Reference images — each as {"type": "url", "url": "https://..."} or {"type": "asset_id", "asset_id": "..."}. Max 3.

Maximum array length: 3

Asset input via publicly accessible HTTPS URL.

avatar_group_id
string | null

Optional identity (group) to save the generated avatar to. By default a new identity is created. If avatar_id is also provided, it must belong to this group.

avatar_id
string | null

Optional avatar id to use as the visual reference for the generation. When provided without avatar_group_id, the new avatar is saved to the referenced avatar's group; when provided with avatar_group_id, the avatar must belong to that group and the result is saved there. The referenced avatar must exist and have a usable image, otherwise the request is rejected.

Response

Successful response

data
CreateAvatarResponse · object