Generate an AI avatar by creating a job.
POST /api/v1/projects/{project_id}/jobs/avatars
curl -X POST 'https://api.smavatar.com/api/v1/projects/{project_id}/jobs/avatars' \
-H 'Authorization: Bearer sma_your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"style_id": "cartoon_flat_modern",
"quality": "standard",
"size": "square",
"parameters": {
"subject": "fox",
"theme": "astronaut",
"gender": "neutral",
"color": "orange"
}
}'
| Field | Type | Description |
|---|---|---|
style_id | string | Art style ID (see Styles) |
parameters.subject | string | Character type: fox, cat, dog, owl, bear, robot, etc. |
parameters.theme | string | Role/costume: astronaut, scientist, chef, detective, etc. |
parameters.gender | string | male, female, or neutral |
parameters.color | string | Primary color: orange, blue, purple, green, etc. |
| Field | Type | Default | Description |
|---|---|---|---|
quality | string | standard | economy, standard, or high |
size | string | square | square, landscape, or portrait |
{
"success": true,
"job": {
"id": "abc123-def456-ghi789",
"job_type": "avatar",
"project_id": "your-project-id",
"style": {
"id": "cartoon_flat_modern",
"label": "Cartoon (Flat Modern)"
},
"quality": "standard",
"size": "square",
"status": "pending",
"estimated_token_cost": 2,
"created_at": "2024-01-15T10:30:00Z"
},
"message": "Avatar job created successfully. It will be processed shortly."
}
{
"statusCode": 402,
"statusMessage": "Insufficient Tokens",
"message": "Not enough tokens",
"data": {
"required_tokens": 2,
"available_tokens": 1,
"action_type": "avatar.generate.standard.square"
}
}
{
"statusCode": 404,
"message": "Style 'invalid-style' not found or inactive"
}
curl 'https://api.smavatar.com/api/v1/projects/{project_id}/jobs/avatars/{job_id}' \
-H 'Authorization: Bearer sma_your_api_key'
{
"success": true,
"job": {
"id": "abc123-def456-ghi789",
"status": "completed",
"actual_token_cost": 2,
"assets": [
{
"id": "asset-uuid",
"storage_path": "project-id/job-id/avatar.png",
"format": "png",
"width": 1024,
"height": 1024
}
]
}
}
Construct the URL from storage_path:
https://hxqvyxnnppomqqwglxwo.supabase.co/storage/v1/object/public/avatars/{storage_path}
429 Too Many RequestsSee Pricing for token costs by quality and size.