Create a custom avatar
Uploads an image, validates its file type, size, safe decoding, and resolution, stores it in Telnyx-managed private storage, and creates an avatar owned by the authenticated organization. Creating an avatar does not update an AI Assistant; use the returned ID separately wherever the avatar is consumed. The avatar image is stored independently from the rendering model and background, which are selected where the avatar is consumed. Supported image types are JPEG, PNG, and WebP. Images may be up to 10 MiB, must be between 256 and 8192 pixels on each side, and may contain at most 40 megapixels. Each organization may have up to 20 custom avatars. For best results, use a 16:9 landscape image, preferably 1920 by 1080 pixels and at least 1280 by 720 pixels. Show one centered, front-facing person from the shoulders up, keep the full head and hair visible with space around it, and use a sharp, evenly lit image with unobstructed eyes and mouth. Use a transparent PNG or WebP when the avatar will be combined with a selectable background. These composition recommendations are not enforced in the first release; the first release does not validate the number of faces, pose, or image content.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const Avatar = await client.ai.avatars.create();
console.log(Avatar.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
avatar = client.ai.avatars.create()
print(avatar.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
avatar, err := client.AI.Avatars.New(
context.TODO(),
telnyx.AIAvatarNewParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", avatar.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.avatars.AvatarCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
AvatarCreateParams params = AvatarCreateParams.builder()
.build();
var response = client.ai().avatars().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
avatar = telnyx.ai.avatars.create
puts(avatar)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$avatar = $client->ai->avatars->create();
var_dump($avatar);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:avatars create \
--api-key 'My API Key'curl --request POST \
--url https://api.telnyx.com/v2/ai/avatars \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form image_file=@example-file \
--form 'name=Customer portrait'{
"data": {
"id": "avatar_0123456789abcdef0123456789abcdef",
"name": "Customer portrait",
"provider": "telnyx",
"avatar_type": "custom",
"hosted": true,
"image_url": "https://example.com/avatar.png",
"image_url_expires_at": "2026-10-13T15:00:00Z",
"content_type": "image/png",
"size_bytes": 248512,
"width_px": 1920,
"height_px": 1080,
"created_at": "2026-10-13T14:00:00Z",
"updated_at": "2026-10-13T14:00:00Z"
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "The request contains invalid avatar parameters.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10015"
}
}
]
}{
"errors": [
{
"code": "10027",
"title": "Unprocessable Entity",
"detail": "The image must be between 256 and 8192 pixels on each side.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10027"
}
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "Avatar storage is temporarily unavailable. Try again.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10037"
}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Response
The custom avatar was validated, stored, and created.
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const Avatar = await client.ai.avatars.create();
console.log(Avatar.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
avatar = client.ai.avatars.create()
print(avatar.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
avatar, err := client.AI.Avatars.New(
context.TODO(),
telnyx.AIAvatarNewParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", avatar.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.avatars.AvatarCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
AvatarCreateParams params = AvatarCreateParams.builder()
.build();
var response = client.ai().avatars().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
avatar = telnyx.ai.avatars.create
puts(avatar)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$avatar = $client->ai->avatars->create();
var_dump($avatar);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:avatars create \
--api-key 'My API Key'curl --request POST \
--url https://api.telnyx.com/v2/ai/avatars \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form image_file=@example-file \
--form 'name=Customer portrait'{
"data": {
"id": "avatar_0123456789abcdef0123456789abcdef",
"name": "Customer portrait",
"provider": "telnyx",
"avatar_type": "custom",
"hosted": true,
"image_url": "https://example.com/avatar.png",
"image_url_expires_at": "2026-10-13T15:00:00Z",
"content_type": "image/png",
"size_bytes": 248512,
"width_px": 1920,
"height_px": 1080,
"created_at": "2026-10-13T14:00:00Z",
"updated_at": "2026-10-13T14:00:00Z"
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "The request contains invalid avatar parameters.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10015"
}
}
]
}{
"errors": [
{
"code": "10027",
"title": "Unprocessable Entity",
"detail": "The image must be between 256 and 8192 pixels on each side.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10027"
}
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "Avatar storage is temporarily unavailable. Try again.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10037"
}
}
]
}