Generate a new AI avatar by creating a job.
POST /api/v1/projects/{project_id}/jobs/avatars
Requires API key in Authorization header:
Authorization: Bearer sma_your_api_key
{
"style_id": "pixar-3d",
"prompt_template_id": "avatar_spec_v2",
"quality": "standard",
"size": "square",
"parameters": {
"subject": "fox",
"theme": "warrior",
"gender": "female",
"color": "orange"
}
}
| Field | Type | Description |
|---|---|---|
style_id | string | Art style identifier (e.g., pixar-3d) |
parameters | object | Customization parameters |
parameters.subject | string | Subject type (e.g., fox, cat, human) |
parameters.theme | string | Theme/outfit (e.g., warrior, wizard, casual) |
parameters.gender | string | Gender presentation (male, female, neutral) |
parameters.color | string | Primary color (e.g., orange, blue, purple) |
| Field | Type | Default | Description |
|---|---|---|---|
prompt_template_id | string | avatar_spec_v2 | Template for prompt generation |
quality | string | standard | Quality tier: economy, standard, high |
size | string | square | Output size: square, landscape, portrait |
parameters.seed | number | random | Seed for reproducibility |
{
"success": true,
"job": {
"id": "abc123-def456-ghi789",
"job_type": "avatar",
"project_id": "your-project-id",
"style": {
"id": "pixar-3d",
"label": "Pixar 3D"
},
"quality": "standard",
"size": "square",
"status": "pending",
"estimated_token_cost": 50,
"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": 50,
"available_tokens": 25,
"action_type": "avatar.generate.standard.square"
}
}
{
"statusCode": 404,
"message": "Style 'invalid-style' not found or inactive"
}
{
"statusCode": 400,
"message": "Parameter validation failed: subject is required"
}
curl -X POST 'https://api.smavatar.com/api/v1/projects/6229750c-2e90-4dc6-a041-6fedd61d1f66/jobs/avatars' \
-H 'Authorization: Bearer sma_AqNYHpfSLGz51YEzJwqavCw6rTlxnlka' \
-H 'Content-Type: application/json' \
-d '{
"style_id": "pixar-3d",
"quality": "standard",
"size": "square",
"parameters": {
"subject": "fox",
"theme": "warrior",
"gender": "female",
"color": "orange"
}
}'
curl 'https://api.smavatar.com/api/v1/projects/6229750c-2e90-4dc6-a041-6fedd61d1f66/jobs/avatars/abc123-def456-ghi789' \
-H 'Authorization: Bearer sma_AqNYHpfSLGz51YEzJwqavCw6rTlxnlka'
{
"success": true,
"job": {
"id": "abc123-def456-ghi789",
"status": "completed",
"actual_token_cost": 50,
"assets": [
{
"id": "asset-uuid",
"storage_path": "project-id/job-id/avatar.png",
"format": "png",
"width": 1024,
"height": 1024
}
]
}
}
Construct the full image URL from the storage_path:
https://hxqvyxnnppomqqwglxwo.supabase.co/storage/v1/object/public/avatars/{storage_path}
429 Too Many Requests if exceeded