# Advanced - Assembling

## 1. Getting a token

[Getting a token](https://docs.metahumansdk.io/service-apis-for-creating-virtual-avatars/getting-started/getting-a-token)

## 2. Get data for model construction

{% hint style="warning" %}
Note: This service only works with parameters from the [3D Face Reconstruction Service](https://docs.metahumansdk.io/service-apis-for-creating-virtual-avatars/getting-started/3d-face-reconstruction)
{% endhint %}

Need to have:

* JSON with parameters (*head\_config.json*  in example)
* UV face texture (*my\_unique\_image\_name\_texture.png* in example)
* (optional) [reconstructed hair model](https://docs.metahumansdk.io/service-apis-for-creating-virtual-avatars/getting-started/3d-hair-reconstruction)

## 4. Create models config

Models config is the JSON file with the pairs of model IDs for the model types from the scheme that you want to add to the finished GLB file.

For example, if you want to add body\_02 from the schema (and don't add hair), models config should look like this:

{% code title="models\_config.json" %}

```json
{
	"body": [
		"body_02"
	]
}
```

{% endcode %}

## 3. Make a request

Make a request by sending the files above.

{% tabs %}
{% tab title="curl" %}

```bash
token="ENTER_YOUR_TOKEN"
head_uv="ENTER_UV_PATH"
head_config="ENTER_HEAD_CONFIG_PATH"
model_config="ENTER_MODEL_CONFIG_PATH"

 curl -X POST\
    'https://api.metahumansdk.io/glb_const/assemble' \
   -H 'accept: application/json' \
   -H 'Content-Type: multipart/form-data' \
   -F "token=$token" \
   -F "head_uv=@$head_uv;type=image/png" \
   -F "head_config=@$head_config;type=application/json" \
   -F "models_config=@$model_config;type=application/json" \
   -F 'add_facs=true' > model.glb
```

{% endtab %}

{% tab title="python" %}
{% code lineNumbers="true" %}

```python
import json
import requests

token="ENTER_YOUR_TOKEN"
head_uv="ENTER_UV_PATH"
head_config="ENTER_HEAD_CONFIG_PATH"
model_config="ENTER_MODEL_CONFIG_PATH"

if __name__ == "__main__":
    service_url = "https://api.metahumansdk.io/glb_const"
    headers = {
        "accept": "application/json",
    }

    files = {
        "token": (None, token),
        "head_uv": ("head_model", open(head_uv, "rb"), "image/png"),
        "head_config": ("head_config", open(head_config, 'rb'), "application/json"),
        "models_config": ("models_config", open(model_config, 'rb'), "application/json"),
        "add_facs": (None, True)
    }

    response = requests.post(service_url + "/assemble", headers=headers, files=files)

    assert response.status_code == 200

    with open('model.glb', "wb") as f:
        f.write(response.content)

```

{% endcode %}
{% endtab %}
{% endtabs %}

## 4. Check response

Open the GLB file in the GLB viewer. For example, you can import the GLB file in Blender.

<figure><img src="https://1042198524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6orDwlXzPvb3WASo4u11%2Fuploads%2FzbsbwFntblNronFhskft%2Fimage.png?alt=media&#x26;token=7e476f22-ca13-40b9-9bdd-e35798dbdea8" alt=""><figcaption></figcaption></figure>

Rendering in Maya:

<figure><img src="https://1042198524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6orDwlXzPvb3WASo4u11%2Fuploads%2F0TbcVdjB3dOfmRKBt0Wp%2Fimage.png?alt=media&#x26;token=efcade43-5d11-4968-a77e-1684959d21bc" alt=""><figcaption></figcaption></figure>
