Generate Your First Avatar
Generating avatar images is one of the most exciting features of Mirako. You can describe the appearance you want in natural language, and let Mirako's AI service generate a realistic avatar.
As with any AI-generated content, the quality of the output may varies and may not always match your expectations. You are suggest to experiment with multiple trials with the same prompt, or try tweaking the prompt to get the desired results.
Quick Start
You can start generating avatars right away using the Mirako CLI tool in your local terminal.
mirako avatar generate -p "A realistic photo of an Asian woman with long black hair, wearing blue business attire, almond-shaped brown eyes, against a clean white background"
The -p
command specifies the text prompt describing the avatar appearance. An avatar protrait image will be generated and save to your current directory.
Image Format
All generated avatar images are in JPG
format with a resolution of 1920x1080 pixels.
Seed
If you generate the avatar using the same prompt again, you will find that each time you will get a different avatar image. By default, the cli uses a random seed
for each generation, causing the output to be different each time.
You can specify a custom seed value using -s
to get reproducible results.
mirako avatar generate -s 10523481 -p "Photo of a Japanese Old Man, silver-white hair, wearing antique glasses"
To explore more options, you can also run --help
to see the available parameters.
Generate Avatar Using API
You can also integrate avatar generation into your applications using the Mirako API.
import requests
import time
# API configuration
API_KEY = "your_api_key_here"
BASE_URL = "https://mirako.co"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
def generate_avatar(prompt, seed=None):
"""Generate an avatar from a text prompt"""
payload = {
"prompt": prompt
}
# Optional: Set a specific seed for reproducible results
if seed:
payload["seed"] = seed
response = requests.post(
f"{BASE_URL}/v1/avatar/async_generate",
headers=headers,
json=payload
)
if response.status_code == 200:
result = response.json()['data']
task_id = result['task_id']
status = result['status']
print(f"✅ Avatar generation started")
print(f"📋 Task ID: {task_id}")
print(f"📊 Status: {status}")
return task_id
else:
print(f"❌ Error starting avatar generation: {response.status_code}")
print(response.text)
return None
# Generate your first avatar
task_id = generate_avatar(
"A realistic photo of Asian woman with long black hair, "
"round-shaped eyes, wearing a professional blue blazer, "
"standing against a clean white background"
)
Checking Generation Status
Like many other Mirako generative API, Avatar generation is an asynchronous process - you'll submit a generation request, receive a task ID, and then poll for the results. This allows you to generate multiple avatars simultaneously and check their progress.
The generation usually takes approximately 10 - 15 seconds to complete, depending on the request traffic. You can check the status of your avatar generation task using the task ID
returned from the previous step.
def check_avatar_generation_status(task_id):
"""Check the status of an avatar generation task"""
response = requests.get(
f"{BASE_URL}/v1/avatar/async_generate/{task_id}/status",
headers=headers
)
if response.status_code == 200:
result = response.json()['data']
task_id = result['task_id']
status = result['status']
print(f"📋 Task ID: {task_id}")
print(f"📊 Status: {status}")
if status == "COMPLETED":
image_b64 = result.get('image')
if image_b64:
print(f"✅ Avatar generated successfully!")
print(f"📸 Image data: {len(image_b64)} characters (base64)")
return result
elif status == "FAILED":
print(f"❌ Avatar generation failed")
elif status in ["IN_QUEUE", "IN_PROGRESS"]:
print(f"⏳ Avatar generation in progress...")
return result
else:
print(f"❌ Error checking status: {response.status_code}")
print(response.text)
return None
# Check status
if task_id:
status_result = check_avatar_generation_status(task_id)
Using Webhook
Alternatively, you can setup webhook to receive notifications when the avatar generation is complete.
def generate_avatar_with_webhook():
webhook_url = "https://mydomain.com/webhook" # Replace with your actual webhook URL
auth_token = "your_auth_token_here" # Optional auth token used for webhook authentication
payload = {
"prompt": prompt
"webhook": {
"url": webhook_url,
"auth_token": auth_token
}
}
response = requests.post(
f"{BASE_URL}/v1/avatar/async_generate",
headers=headers,
json=payload
)
# read the response like before
Going Next
To generate an avatar that matches your preferences might take some experimentation with different prompts and parameters. Once you have obtained a satisfactory avatar, you can proceed with building it.