Create Your First Avatar

Learn how to generate your first avatar with the Mirako API.

Create an Avatar Generation Task

Use the POST /v1/avatar/async_generate endpoint to submit a prompt describing your desired avatar appearance.

import requests

# Authentication and client setup
api_key = "YOUR_API_KEY"
base_url = "https://api.mirako.ai/v1"
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

payload = {
    "prompt": "A realistic photo of an Asian girl with long black hair, round-shaped eyes, wearing a pink t-shirt, standing in front of a solid background.",
    "seed": 1234567890
}

response = requests.post(
    f"{base_url}/avatar/async_generate",
    headers=headers,
    json=payload
)
response.raise_for_status()
task = response.json()["data"]
task_id = task.get("task_id")
print(f"Avatar generation task started: {task_id}")

Checking Task Status

Poll the status endpoint until the task completes.

status_resp = requests.get(
    f"{base_url}/avatar/async_generate/{task_id}/status",
    headers=headers,
)
status_resp.raise_for_status()
status = status_resp.json()["data"]
print(f"Status: {status.get('status')}")

Once status is succeeded, retrieve the avatar details:

avatar_id = status.get("target_id")
avatar_resp = requests.get(
    f"{base_url}/avatar/{avatar_id}",
    headers=headers,
)
avatar_resp.raise_for_status()
avatar = avatar_resp.json()
print(avatar)

Note: You can optionally specify a webhook URL in the initial request to receive callbacks upon completion.

Dive deeper