API For AI Hairstyle
About 2 min
API For AI Hairstyle
AI Hairstyle Describe
AI Hairstyle is a feature that uses artificial intelligence to change hairstyles in photos.
Users simply upload a front-facing photo of their face, choose the desired hairstyle type, and set the hair color to automatically apply the new look to the person in the picture. Whether you’re experimenting with a new style or looking for inspiration for a haircut, this feature quickly delivers the perfect results.
Considerations
- Before using the API, make sure you have obtained the API key. Refer to the link below for instructions on how to obtain it. API For API Key Settings
- All generated images will be automatically deleted after 24 hours. Please make sure to save the images you need to your local storage in a timely manner.
Credits Consumption
Normal mode: each picture needs 6 credits.
Header Attributes
Parameter | Description |
---|---|
Authorization | Your API Key used for request authorization. |
Create Job
Request Url
--request POST https://developer.vmodel.ai/api/vmodel/v1/ai-hairstyle/create-job
Body Attributes
Parameter | Type | Required | Description |
---|---|---|---|
image_files | file[binary] | true | input_image, upload 1~4 frontal face photos (minimum: 1, maximum: 4) |
hair_color | Text | true | Hair color options include 10 choices: black, brown, blonde, red, white, grey, pink, blue, green, and purple. |
hairstyle | Text | true | Hairstyle templates include 12 options, with the default being Braided Crown. |
num_outputs | int | false | Number of output images Default: 2, (minimum: 1, maximum: 4) |
Description of the hairstyle parameter
Braide Crown (Default) | Long Layers | Buzz Cut | Bowl Cut |
![]() | ![]() | ![]() | ![]() |
Dreadlocks | Short Hair | Bombshell Curls | Lowpoly |
![]() | ![]() | ![]() | ![]() |
Long Wave | Short Curly | Mohawk | Crew Cut |
![]() | ![]() | ![]() | ![]() |
demo
import requests
url = "https://developer.vmodel.ai/api/vmodel/v1/ai-hairstyle/create-job"
headers = {
'accept': 'application/json',
'Authorization': 'your token',
}
payload = {
'hair_color': 'pink',
'hairstyle': 'Short Hair',
'num_outputs': 2}
files=[
('image_files',('demo1.png',open('demo1.png','rb'),'image/png')),
('image_files',('demo2.png',open('demo2.png','rb'),'image/png'))
]
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Response
{
"code": 100000,
"result": {
"job_id": "your-job-id"
},
"message": {
"en": "Request Success."
}
}
Fetch Job
Request Url
--request GET https://developer.vmodel.ai/api/vmodel/v1/ai-hairstyle/get-job/your-job-id
Body Attributes
Parameter | Description |
---|---|
job_id | job_id returned by create task |
demo
import requests
url = 'https://developer.vmodel.ai/api/vmodel/v1/ai-hairstyle/get-job/your-job-id'
headers = {
'accept': 'application/json',
'Authorization': 'your token',
}
response = requests.get(url, headers=headers)
print(response.json()) # Print the response content
Response
{
"code": 100000,
"result": {
"output_image_url": [
"https://image.remaker.ai/datarm7/hairstyle/ai_vmodel/2024-09-12/output/your-output-image.png"
],
"input_image_url": [
"https://image.remaker.ai/datarm7/hairstyle/ai_vmodel/2024-09-12/input/your-input-image.png"
],
"job_id": "your-job-id",
"message": ""
},
"message": {
"en": "Image generated successfully."
}
}
Response Code
Code | Description |
---|---|
100000 | Request Success |
200000 | Request Failure |
300101 | system error |
300102 | Image generation in progress |
300103 | Image generated successfully |
300104 | Image generated failed |
400301 | Params error |
400302 | Token is Null |