Create Avatar & Download GLTF

Tutorial on how to use the API to create an avatar and download its GLTF representation.

GLTF is a premium feature. Please contact us for access.

1. Authenticate

Select the appropriate oauth2 authorisation flow for your use case and obtain an API access token. See Authentication for details.

For sake of simplicity of this example, you can use your application's client credentials to authenticate directly using the oauth2 client credentials flow. Returns an access token on success.

If you use other authorisation flows, make sure to enable scopes read:avatars write:avatars read:features write:features read:gltf.

curl --request POST \
--url 'https://auth.loomai.com/oauth/token' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'audience=https%3A%2F%2Fapi.loomai.com%2F&grant_type=client_credentials&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}'

2. Create Avatar

Post a photo of a face to create an avatar. Returns response header X-Loom-Status containing the id of created avatar if successful. See Avatars > Create for details.

curl -X POST "https://api.live.loomai.com/v0.5/avatars" \
-H "Authorization: Bearer {ACCESS_TOKEN}" \
-H "Content-Type: multipart/form-data" \
-F "image=@{IMAGE_FILE};type=image/jpeg"

3. Resolve GLTF

The GLTF of created avatar is automatically exported and can be resolved using the avatar ID. See Avatars > Attachments > List for details.

curl -X GET "https://api.live.loomai.com/v0.5/avatars/{AVATAR_ID}/attachments" \
-H "Authorization: Bearer {ACCESS_TOKEN}"

This returns a list of attachments - including uploaded photo, rendered preview & exported GTLF (type gltf).

{
"entries": [
{
"id": 5670865657659392,
"type": "gltf",
"name": "",
"url": "https://storage.googleapis.com/live-com-loomai-api-attachments/5484235973984256/model.glb",
"updated_at": "2020-04-05T16:37:44Z"
}
...
]
}