Create Custom Avatar
curl --request POST \
--url https://api.trugen.ai/v1/v2/custom-avatar \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"avatar_name": "my_avatar",
"gender": "male",
"input_image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
'import requests
url = "https://api.trugen.ai/v1/v2/custom-avatar"
payload = {
"avatar_name": "my_avatar",
"gender": "male",
"input_image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
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({
avatar_name: 'my_avatar',
gender: 'male',
input_image: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...'
})
};
fetch('https://api.trugen.ai/v1/v2/custom-avatar', 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.trugen.ai/v1/v2/custom-avatar",
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([
'avatar_name' => 'my_avatar',
'gender' => 'male',
'input_image' => 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...'
]),
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.trugen.ai/v1/v2/custom-avatar"
payload := strings.NewReader("{\n \"avatar_name\": \"my_avatar\",\n \"gender\": \"male\",\n \"input_image\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...\"\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.trugen.ai/v1/v2/custom-avatar")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"avatar_name\": \"my_avatar\",\n \"gender\": \"male\",\n \"input_image\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trugen.ai/v1/v2/custom-avatar")
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 \"avatar_name\": \"my_avatar\",\n \"gender\": \"male\",\n \"input_image\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3b6f4c8a-1234-5678-9abc-def012345678",
"job_id": "sync-abcd-1234",
"avatar_key_id": "a1b2c3d4e5",
"avatar_id": "a1b2c3d4e5",
"avatar_name": "my_avatar",
"gender": "male",
"category": "trugen",
"status": "QUEUED",
"is_private": true
}{
"error": "Image does not meet avatar creation guidelines",
"reason": "Image appears to depict a public figure"
}Avatars
Create Custom Avatar
Submits a custom avatar generation job from a base64-encoded source image. Requires x-api-key authentication.
POST
/
v2
/
custom-avatar
Create Custom Avatar
curl --request POST \
--url https://api.trugen.ai/v1/v2/custom-avatar \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"avatar_name": "my_avatar",
"gender": "male",
"input_image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
'import requests
url = "https://api.trugen.ai/v1/v2/custom-avatar"
payload = {
"avatar_name": "my_avatar",
"gender": "male",
"input_image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
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({
avatar_name: 'my_avatar',
gender: 'male',
input_image: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...'
})
};
fetch('https://api.trugen.ai/v1/v2/custom-avatar', 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.trugen.ai/v1/v2/custom-avatar",
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([
'avatar_name' => 'my_avatar',
'gender' => 'male',
'input_image' => 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...'
]),
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.trugen.ai/v1/v2/custom-avatar"
payload := strings.NewReader("{\n \"avatar_name\": \"my_avatar\",\n \"gender\": \"male\",\n \"input_image\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...\"\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.trugen.ai/v1/v2/custom-avatar")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"avatar_name\": \"my_avatar\",\n \"gender\": \"male\",\n \"input_image\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trugen.ai/v1/v2/custom-avatar")
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 \"avatar_name\": \"my_avatar\",\n \"gender\": \"male\",\n \"input_image\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3b6f4c8a-1234-5678-9abc-def012345678",
"job_id": "sync-abcd-1234",
"avatar_key_id": "a1b2c3d4e5",
"avatar_id": "a1b2c3d4e5",
"avatar_name": "my_avatar",
"gender": "male",
"category": "trugen",
"status": "QUEUED",
"is_private": true
}{
"error": "Image does not meet avatar creation guidelines",
"reason": "Image appears to depict a public figure"
}Authorizations
Body
application/json
Human-readable name for your custom avatar.
Example:
"my_avatar"
Available options:
male, female Example:
"male"
Source photo as a base64 data URI. Max ~12 MB base64 (~9 MB binary).
Example:
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
Response
Custom avatar job accepted
Example:
"3b6f4c8a-1234-5678-9abc-def012345678"
Example:
"sync-abcd-1234"
Example:
"a1b2c3d4e5"
Example:
"a1b2c3d4e5"
Example:
"my_avatar"
Example:
"male"
Example:
"trugen"
Example:
"QUEUED"
Example:
true
Was this page helpful?