API For AI Portrait
June 18, 2024About 2 min
API For AI Portrait
AI Portrait Describe
Using AI Portrait Generator, with prompt and pre-made styles, you can generate exclusive portrait photos for you, you only need to upload your photos.
AI Portrait Generator can change the overall look of a portrait, such as makeup, clothing, color scheme and lighting. At the same time, your facial features are preserved,
and professional portfolios such as half-length photos and full-body photos are generated for you.
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.
- Tips: The phrase 'img' is the trigger word. The trigger word can only appear once in the prompt.
Credits Consumption
Normal mode: each picture needs 4 credits.
Advanced mode: each picture needs 8 credits.
Header Attributes
Parameter | Description |
---|---|
Authorization | Your API Key used for request authorization. |
Create Job
Request Url
--request POST https://developer.remaker.ai/api/remaker/v1/ai-portrait/create-job
Body Attributes
Parameter | Type | Required | Description |
---|---|---|---|
image_file | file[binary] | true | input_image, (minimum: 1, maximum: 4) |
style_name | string | false | Style template. The style template will add a style-specific prompt and negative prompt to the user's prompt. Default: "Photographic (Default)" |
prompt | string | true | Prompt. Example: 'a photo of a man/woman img'. The phrase 'img' is the trigger word. |
negative_prompt | string | true | Negative Prompt. The negative prompt should NOT contain the trigger word. Default: "nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry" |
advanced | int | false | Enable advanced mode. After enabling, the output picture will be more beautiful. Normal mode: each picture Advanced mode: each picture Default: 0, (enabled: 1, disabled: 0) |
style_strength_ratio | int | false | Style strength (%) The lower the value, the closer it is to real people. The higher the value, the greater the degree of freedom. Default: 20, (minimum: 15, maximum: 50) |
num_outputs | int | false | Number of output images Default: 1, (minimum: 1, maximum: 4) |
width | int | false | min:256, max:1920(Must be a multiple of 8) |
height | int | false | min:256, max:1920(Must be a multiple of 8) |
Description of the style_name parameter
Cinematic | Disney Charactor | Digital Art | Photographic (Default) | Fantasy art |
Neonpunk | Enhance | Comic book | Lowpoly | Line art |
demo
import requests
url = "https://developer.remaker.ai/api/remaker/v1/ai-portrait/create-job"
headers = {
'accept': 'application/json',
'Authorization': 'your token',
}
payload = {
'style_name': 'Photographic (Default)',
'prompt': 'your prompt',
'negative_prompt': 'your negative prompt',
'advanced': 1,
'style_strength_ratio': 15,
'num_outputs': 2}
files=[
('image_file',('demo1.png',open('demo1.png','rb'),'image/png')),
('image_file',('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.remaker.ai/api/remaker/v1/ai-portrait/your-job-id
Body Attributes
Parameter | Description |
---|---|
job_id | job_id returned by create task |
demo
import requests
url = 'https://developer.remaker.ai/api/remaker/v1/ai-portrait/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/datarm/api/ai-portrait/api/2024-04-10/output/your-output-image.png"
],
"input_image_url": [
"https://image.remaker.ai/datarm/api/ai-portrait/api/2024-04-10/input/your-input-image.png"
],
"job_id": "your-job-id",
"message": ""
},
"message": {
"en": "Image generated successfully."
}
}