Generate Images of the Avatar

With your avatar model ready, create new images using the POST /v1/image/async_generate endpoint.

Request

Include your avatar_id in the prompt and specify aspect_ratio.

import requests

api_key = "YOUR_API_KEY"
base_url = "https://api.mirako.ai/v1"
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
avatar_id = "YOUR_AVATAR_ID"

payload = {
    "prompt": f"A close-up portrait of avatar {avatar_id} smiling in a coffee shop",  # include avatar_id
    "aspect_ratio": "16:9",
    "seed": 42
}

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

Checking Task Status

Poll until completion:

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

if status.get("status") == "succeeded":
    image_id = status.get("target_id")
    print(f"Generated image ID: {image_id}")

Note: Always reference the avatar_id in your prompt to ensure the correct avatar is used.

Dive deeper