# Create Avatar & Render

1. [Authenticate](/guides/create-avatar.md#1-authenticate)
2. [Create Avatar](/guides/create-avatar.md#2-create-avatar)
3. [Resolve Rendering](/guides/create-avatar.md#3-resolve-renderings)

### 1. Authenticate

Select the appropriate oauth2 authentication flow for your use case and obtain an API access token. See [Authentication](/api/authentication.md) for details.

For sake of simplicity of this example, you can use your [application's client credentials](/guides/api-credentials.md) to authenticate directly using the [oauth2 resource owner flow](/api/authentication/resource-owner-flow.md). Returns an access token on success.&#x20;

If you use other authentication flows, make sure to enable [scopes](/api/schema/scope.md) `read:avatars write:avatars read:renderings write:renderings`.

```bash
curl --request POST \
  --url 'https://auth.loomai.com/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=http://auth0.com/oauth/grant-type/password-realm \
  --data realm=Username-Password-Authentication \
  --data username={PASSWORD} \
  --data password={USERNAME} \
  --data audience=https%3A%2F%2Fapi.loomai.com%2F \
  --data client_id={CLIENT_ID} \
  --data 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](/api/avatars/create.md) for details.&#x20;

```bash
curl -X POST "https://api.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 Rendering

A rendered preview of created avatar is automatically created and can be resolved using the avatar ID. See [Avatars > Attachments > List](/api/avatars/attachments/list.md) for details.

```bash
{
  "entries": [
    {
      "id": 5754466256551936,
      "type": "renderings_preview",
      "name": "neutral",
      "url": "https://storage.googleapis.com/live-com-loomai-api-attachments/5484235973984256/MThVY01uV2tfbWlhLWF2YXRhcg==.png",
      "updated_at": "2020-04-05T16:37:57Z"
    }
    ...
  ]
}
```

This returns a list of attachments - including uploaded photo, rendered preview (type `renderings_preview`) etc.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.loomai.com/guides/create-avatar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
