Hairgen.ai API Documentation
Table of Contents
Authentication
All endpoints require an API key provided in the Authorization
header.
Endpoints
POST /v1/render
This endpoint processes a form-data request to render an image with specified settings.
Request
- URL:
/v1/render
- Method:
POST
- Headers:
Authorization
: API key for authenticationContent-Type
:multipart/form-data
- Body:
mask
(file): The mask image file.photo
(file): The photo image file.format
(string): The format of the output image (default:jpeg
). Accepted values arejpeg
,png
,webp
.renderSettings
(JSON string): The render settings including:density
(number): Density value (0-100). (Default: 100)male
(boolean): Gender indicator. (Default:true
)widowsPeak
(boolean): Widows peak indicator. (Default:false
)hairstyle
(string): Hairstyle. (Default: automatic)color
(string): Hair color. (Default: automatic)
Response
- Status:
200 OK
on success.400 Bad Request
if input validation fails.
- Body:
- On success:
{ "url": "URL to the rendered image" }
- On error:
{ "error": "Error message here" }
- On success:
Example
curl -X POST https://api.hairgen.ai/v1/render \
-H "Authorization: your_api_key" \
-F "mask=@/path/to/mask.jpg" \
-F "photo=@/path/to/photo.jpg" \
-F "format=jpeg" \
-F "renderSettings={\"density\": 100, \"male\": true, \"widowsPeak\": false, \"hairstyle\": \"automatic\", \"color\": \"automatic\"}"
GET /v1/galleries
This endpoint retrieves a list of galleries for the authenticated user.
Request
- URL:
/v1/galleries
- Method:
GET
- Headers:
Authorization
: API key for authentication
- Query Parameters:
uuid
(optional): Specific gallery UUID to filter.apiKey
(optional): API key to filter by a specific api key among the ones you own.
Response
- Status:
200 OK
on success.403 Forbidden
if API key is invalid.
- Body:
- On success:
[ { "data": [ { "photo": "URL to processed photo", "mask": "URL to mask image", "render": "URL to rendered image", "renderSettings": { "hairstyle": "curly", "hair_color": "black", "density": 100, "widows_peak": true, "male": true } } ], "uuid": "gallery-uuid" } ]
- On error:
{ "error": "Error message here" }
- On success:
Example
curl -X GET https://api.hairgen.ai/v1/galleries \
-H "Authorization: your_api_key"