This document describes how to use the code to achieve the same results as on the web. After document will only give relative address API, you need to cobble together to the main domain name: https://api.aitubo.ai.
For example, if you want to create a job, you need to call https://api.aitubo.ai/api/job/create
The document is divided into two sections, the first for examples and the second for specific API.
This section describes how to create a job and obtain a job. Our API for creating jobs provides three core functions: Text2Image, Image2Image, and ControlNet(ControlNet is a neural network structure to control diffusion models by adding extra conditions).
Regardless of which of the three features you use, first you have to get a list of the models we support, and then when you create the job, you need to pass in the id field of the model information
curl --request GET \
--url 'https://api.aitubo.ai/api/model/list?type=platform' \
--header 'Authorization: Bearer ced695cfd83811eda5e286850d1dc848'
The result is something like this๏ผ
{
"code": 0,
"data": {
"domain": "https://file.aitubo.ai/",
"total": 10,
"models": [
{
"id": "6426f9c60ca4651b98b91a6d",
"name": "ConceptCanvas",
"username": "Aitubo",
"desc": "A model that creates concept scenes with a European thick paint or CG style.",
"cover": "assets/model/6426f9c60ca4651b98b91a6d/cover.jpg",
"isFavourite": false,
"controlNet": false
},
{
"id": "642b977d2f2842537c09fe41",
"name": "DreamShaper",
"username": "Aitubo",
"desc": "A model that can generate multiple styles of scenes, characters, and game assets.",
"cover": "assets/model/642b977d2f2842537c09fe41/cover.jpg",
"isFavourite": false,
"controlNet": true
},
...
]
}
}
curl --request POST \
--url https://api.aitubo.ai/api/job/create \
--header 'Authorization: Bearer ced695cfd83811eda5e286850d1dc848' \
--header 'content-type: application/json' \
--data '{
"prompt": "A cat sleeps on the plane",
"modelId": "642b977d2f2842537c09fe41"
}
Then, you will get a response like this:
{
"code": 0,
"data": {
"consumedCredit": 40,
"credit": 120,
"id": "64351e4d567bcd86773dc841"
}
}
You can check the status of task creation by polling. Each photo takes about 2 seconds to complete, so please control your query frequency. Finally, you will get like this:
{
"code": 0,
"data": {
"id": "64351e4d567bcd86773dc841",
"args": {
"prompt": "A cat sleeps on the plane",
"negativePrompt": "lowres, bad anatomy, cropped, worst quality, low quality",
"strength": 0.8,
"width": 512,
"height": 512,
"count": 4,
"steps": 30,
"modelId": "642b977d2f2842537c09fe41"
},
"result": {
"info": "Warning: some images may contain NSFW content",
"data": {
"images": [
"images/art/640076a4661aa1c0f81ba2d7/cgqhsljj5mf00080001g.png",
"images/art/640076a4661aa1c0f81ba2d7/cgqhsljj5mf000800020.png",
"images/art/640076a4661aa1c0f81ba2d7/cgqhsljj5mf00080002g.png",
"images/art/640076a4661aa1c0f81ba2d7/cgqhsljj5mf000800030.png"
],
"artIds": [
"64351e56567bcd86773dc842",
"64351e56567bcd86773dc843",
"64351e56567bcd86773dc844",
"64351e56567bcd86773dc845"
],
"domain": "https://file.aitubo.ai/"
}
},
"status": 2,
"createAt": "2023-04-11T08:46:05.55Z"
}
}
To use Image2Image, you can call our Upload Image API to get an imageโs OSS relative address, or you can give an image with an absolute address.
curl --request POST \
--url https://api.aitubo.ai/api/job/create \
--header 'Authorization: Bearer ced695cfd83811eda5e286850d1dc848' \
--header 'content-type: application/json' \
--data '{
"imagePath": "images/tmp/cgqi1jntuq4000800040.png",
"modelId": "642b977d2f2842537c09fe41",
"prompt": "scene",
"guidanceScale": 0.7
}'
You can check the status of task creation by polling just like the Text2Image.
Before using the ControlNet function, you must first call the /job/model/list API to obtain the corresponding ControlNet categories๏ผ
{
"code": 0,
"data": {
"domain": "https://file.aitubo.ai/",
"models": [
{
"id": "canny",
"name": "canny",
"icon": "assets/template/control_canny.jpg"
},
{
"id": "scribble",
"name": "scribble",
"icon": "assets/template/control_scribble.jpg"
},
...
}
}
Then call /job/create API:
curl --request POST \
--url https://api.aitubo.ai/api/job/create \
--header 'Authorization: Bearer ced695cfd83811eda5e286850d1dc848' \
--header 'content-type: application/json' \
--data '{ "imagePath": "https://ichef.bbci.co.uk/news/976/cpsprodpb/17638/production/_124800859_gettyimages-817514614.jpg.webp",
"controlModel": "canny",
"prompt": "a little dog"
}'
You can also pass modelId field(Make sure that the model supports ControlNet):
curl --request POST \
--url https://api.aitubo.ai/api/job/create \
--header 'Authorization: Bearer ced695cfd83811eda5e286850d1dc848' \
--header 'content-type: application/json' \
--data '{
"imagePath": "https://ichef.bbci.co.uk/news/976/cpsprodpb/17638/production/_124800859_gettyimages-817514614.jpg.webp",
"controlModel": "canny",
"prompt": "a little dog",
"modelId": "642b977d2f2842537c09fe41"
}'
Path๏ผ /api/job/upload-image
Method๏ผ POST
Headers
Name | Value | Required | Example |
---|---|---|---|
Content-Type | multipart/form-data | yes | |
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Body
Name | Value | Required |
---|---|---|
image | file | yes |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | integer | yes | code=0 -> success | ||
info | string | no | error info | ||
data | object | no | |||
โโpath | string | no | image path of AliYun OSS |
Path๏ผ /api/job/create
Method๏ผ POST
Headers
Name | Value | Required | Example |
---|---|---|---|
Content-Type | application/json | yes | |
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Body
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
imagePath | string | no | path of the uploaded image(url/oss both) | ||
maskImage | string | no | AI Editor should pass this field | ||
modelId | string | no | if controlModel is null, this field should be filled | ||
prompt | string | yes | prompt | ||
negativePrompt | string | no | negative prompt | ||
controlModel | string | no | canny / scribble / openpose / mlsd / hed / seg / depth / normal | ||
controlStrength | number | no | 1 | [0, 2] | |
controlFilter | string | no | preprecessor of control image, for example: openpose / openpose_full / openpose_hand / openpose_face / openpose_faceonly | ||
strength | number | no | 0.8 | [0.1, 1] | |
width | integer | no | 512 | ||
height | integer | no | 512 | ||
steps | integer | no | 30 | 10 <= value <= 50 | |
guidanceScale | integer | no | 7.5 | 0 < value <= 20 | |
count | integer | no | 4 | generated image count |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | number | yes | 0 -> success;1000 -> no enough credit | ||
info | string | no | error info | ||
data | object | yes | |||
โโid | string | yes | job ID | ||
โโcredit | integer | yes | userโs total credit | ||
โโconsumedCredit | integer | yes | consumed credit of the job |
Path๏ผ /api/job/get
Method๏ผ GET
Query
Name | Required | Example | Note |
---|---|---|---|
id | yes | 642ba091592245d79a645b39 | job id |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | integer | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โโid | string | yes | job id | ||
โโcreateAt | string | yes | created time of the job | ||
โโstatus | integer | yes | status of the job. 0 -> not ready; 1 -> processing; 2 -> success; 3 -> failure | ||
โโresult | object | no | |||
โโโโinfo | string | no | |||
โโโโdata | object | no | |||
โโโโโโimages | string [] | no | The resulting relative path of the image (need to be concatenated with the domain field) | item Type:string | |
โโโโโโartIds | string [] | no | Picture corresponding artID | item Type:string | |
โโโโโโdomain | string | no | oss url, you need to concatenate the relative path of the picture | ||
โโargs | object | no | |||
โโโโprompt | string | no | |||
โโโโnegativePrompt | string | no | |||
โโโโmodel | string | no | |||
โโโโstrength | integer | no | |||
โโโโwidth | integer | no | |||
โโโโheight | integer | no |
Path๏ผ /api/job/models
Method๏ผ GET
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | integer | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โdomain | string | yes | image oss domain name, need to concatenate the icon field below | ||
โmodels | object [] | yes | item Type:object | ||
id | string | yes | model id, The controlModel parameter value is this ID when creating a job | ||
name | string | yes | English name | ||
cname | string | yes | Chinese name | ||
icon | string | yes | sample picture. oss relative path, you need to concatenate domains |
Path๏ผ /api/job/list
Method๏ผ GET
Headers
Name | Value | Required | Example | Note |
---|---|---|---|---|
Content-Type | application/json | yes | ||
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Query
Name | Required | Example | Note |
---|---|---|---|
pageIndex | yes | start from 1 | |
pageSize | yes |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | integer | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โโjobs | object [] | yes | job array | item Type:object | |
โโโโid | string | yes | job id | ||
โโโโcreatedAt | string | yes | |||
โโโโargs | object | yes | |||
โโโโโโprompt | string | yes | |||
โโโโโโnegativePrompt | string | yes | |||
โโโโโโstrength | integer | yes | |||
โโโโโโwidth | integer | yes | |||
โโโโโโheight | integer | yes | |||
โโโโโโcount | integer | yes | |||
โโโโโโsteps | integer | yes | |||
โโโโarts | object [] | yes | the generated array of images | item Type:object | |
โโโโโโid | string | yes | the id of the generated image | ||
โโโโโโimages | object [] | yes | variety picture array | item Type:object | |
โโโโโโโโspec | string | yes | variant type. o -> origin; 2x/3x/4x -> 2/3/4 scale image | ||
โโโโโโโโpath | string | yes | image path. domain to be concatenated | ||
โโโโโโโโsize | integer | yes | image size. unit: Byte | ||
โโdomain | string | yes | oss image domain |
Path๏ผ /api/model/list
Method๏ผ GET
Headers
Name | Value | Required | Example | Note |
---|---|---|---|---|
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Query
Name | Required | Example | Note |
---|---|---|---|
pageIndex | yes | start from 1 | |
pageSize | yes | ||
type | no | platform/community |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | integer | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โโdomain | string | yes | oss domain | ||
โโtotal | integer | yes | the total number of models filtered for paging | ||
โโmodels | object [] | yes | item Type:object | ||
โโโโid | string | yes | model id | ||
โโโโname | string | yes | model name | ||
โโโโusername | string | yes | modelโs author name | ||
โโโโdesc | string | yes | model description | ||
โโโโcover | string | yes | model cover | ||
โโโโisFavourite | boolean | yes | whether the user favorites the model | ||
โโโโcontrolNet | boolean | yes | whether the model supports ControlNet |
Path๏ผ /api/job/upscale
Method๏ผ POST
Headers
Name | Value | Required | Example | Note |
---|---|---|---|---|
Content-Type | application/json | yes | ||
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Body
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
model | string | no | upscale model name. | ||
RealESRGAN _x4plus / RealESRGAN_x4plus_anime_6B | |||||
imagePath | string | yes | image path | ||
upscaleFactor | integer | yes | 2 <= factor <= 4 | ||
beauty | boolean | no | whether to enable face enhancement | ||
artId | string | yes | Need a super point picture artID |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | number | yes | 0 -> success;1000 -> no enough credit | ||
info | string | no | error info | ||
data | object | yes | |||
โโid | string | no | upscale job id | ||
โโcredit | integer | yes | userโs total credit | ||
โโconsumedCredit | integer | yes | consumed credit of the job |
Path๏ผ /api/art/segment
Method๏ผ POST
Headers
Name | Value | Required | Example | Note |
---|---|---|---|---|
Content-Type | application/json | yes | ||
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Body
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
image | string | yes | image path. absolute/relative path |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | number | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โโimage | string | yes | URL of the image after segmentating |
Path๏ผ /api/user/profile
Method๏ผ GET
Headers
Name | Value | Required | Example | Note |
---|---|---|---|---|
Content-Type | application/json | yes | ||
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | number | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โโname | string | yes | |||
โโemail | string | yes | |||
โโavatar | string | yes | |||
โโphone | string | yes | |||
โโcredit | integer | yes | total credit | ||
โโdisplayNSFW | boolean | yes | |||
โโdiscord | boolean | yes |
Path๏ผ api/transform/list
Method๏ผ GET
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | number | yes | 0 -> success | ||
info | string | no | error info | ||
data | object | yes | |||
โโdomain | string | yes | image domain | ||
โโtags | string[] | yes | template tag | ||
โโtransform | object | yes | |||
โโโโtag | object[] | yes | |||
โโโโโโid | string | yes | |||
โโโโโโname | string | yes | |||
โโโโโโimage | string | yes | origin image | ||
โโโโโโart | string | yes | result image | ||
โโโโโโcost | number | yes | credit consume | ||
โโโโโโpro | boolean | yes | is pro | ||
โโโโโโtag | string | yes | tag |
Path๏ผ api/transform/create-headshot
Method๏ผ POST
Headers
Name | Value | Required | Example | Note |
---|---|---|---|---|
Content-Type | application/json | yes | ||
Authorization | Bearer {YOUR KEY} | yes | Bearer 37f333a2d5f811edb248acde48001122 |
Body
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
imagePath | string | yes | image path returned when called upload-image api | ||
transformId | string | yes | |||
width | integer | no | |||
height | integer | no | |||
keepHair | boolean | no | false | ||
keepPose | boolean | no | true |
Name | Type | Required | Default | Note | Others |
---|---|---|---|---|---|
code | number | yes | 0 -> success;1000 -> no enough credit | ||
info | string | no | error info | ||
data | object | yes | |||
โโid | string | yes | job ID | ||
โโcredit | integer | yes | userโs total credit | ||
โโconsumedCredit | integer | yes | consumed credit of the job |