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 | |||
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 |