API Reference

API Documentation of Aitubo

Overview

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.

Examples

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
            },
            ...
        ]
    }
}

1. Text2Image

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

2. Image2Image

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.

3. ControlNet

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"
}'

APIS

1. Upload Image

Basic Info

Path: /api/job/upload-image

Method: POST

Request Params

Headers

NameValueRequiredExample
Content-Typemultipart/form-datayes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Body

NameValueRequired
imagefileyes

Response Data

NameTypeRequiredDefaultNoteOthers
codeintegeryescode=0 -> success
infostringnoerror info
dataobjectno
├─pathstringnoimage path of AliYun OSS

2. Create Job

Basic Info

Path: /api/job/create

Method: POST

Request Params

Headers

NameValueRequiredExample
Content-Typeapplication/jsonyes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Body

NameTypeRequiredDefaultNoteOthers
imagePathstringnopath of the uploaded image(url/oss both)
maskImagestringnoAI Editor should pass this field
modelIdstringnoif controlModel is null, this field should be filled
promptstringyesprompt
negativePromptstringnonegative prompt
controlModelstringnocanny / scribble / openpose / mlsd / hed / seg / depth / normal
controlStrengthnumberno1[0, 2]
controlFilterstringnopreprecessor of control image, for example: openpose / openpose_full / openpose_hand / openpose_face / openpose_faceonly
strengthnumberno0.8[0.1, 1]
widthintegerno512
heightintegerno512
stepsintegerno3010 <= value <= 50
guidanceScaleintegerno7.50 < value <= 20
countintegerno4generated image count

Response Data

NameTypeRequiredDefaultNoteOthers
codenumberyes0 -> success;1000 -> no enough credit
infostringnoerror info
dataobjectyes
├─idstringyesjob ID
├─creditintegeryesuser’s total credit
├─consumedCreditintegeryesconsumed credit of the job

3. Get Job

Basic Info

Path: /api/job/get

Method: GET

Request Params

Query

NameRequiredExampleNote
idyes642ba091592245d79a645b39job id

Response Data

NameTypeRequiredDefaultNoteOthers
codeintegeryes0 -> success
infostringnoerror info
dataobjectyes
├─idstringyesjob id
├─createAtstringyescreated time of the job
├─statusintegeryesstatus of the job. 0 -> not ready; 1 -> processing; 2 -> success; 3 -> failure
├─resultobjectno
├─├─infostringno
├─├─dataobjectno
├─├─├─imagesstring []noThe resulting relative path of the image (need to be concatenated with the domain field)item Type:string
├─├─├─artIdsstring []noPicture corresponding artIDitem Type:string
├─├─├─domainstringnooss url, you need to concatenate the relative path of the picture
├─argsobjectno
├─├─promptstringno
├─├─negativePromptstringno
├─├─modelstringno
├─├─strengthintegerno
├─├─widthintegerno
├─├─heightintegerno

4. List ControlNet Model

Basic Info

Path: /api/job/models

Method: GET

Response Data

NameTypeRequiredDefaultNoteOthers
codeintegeryes0 -> success
infostringnoerror info
dataobjectyes
├domainstringyesimage oss domain name, need to concatenate the icon field below
├modelsobject []yesitem Type:object
idstringyesmodel id, The controlModel parameter value is this ID when creating a job
namestringyesEnglish name
cnamestringyesChinese name
iconstringyessample picture. oss relative path, you need to concatenate domains

5. List Histroy Job

Basic Info

Path: /api/job/list

Method: GET

Request Params

Headers

NameValueRequiredExampleNote
Content-Typeapplication/jsonyes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Query

NameRequiredExampleNote
pageIndexyesstart from 1
pageSizeyes

Response Data

NameTypeRequiredDefaultNoteOthers
codeintegeryes0 -> success
infostringnoerror info
dataobjectyes
├─jobsobject []yesjob arrayitem Type:object
├─├─idstringyesjob id
├─├─createdAtstringyes
├─├─argsobjectyes
├─├─├─promptstringyes
├─├─├─negativePromptstringyes
├─├─├─strengthintegeryes
├─├─├─widthintegeryes
├─├─├─heightintegeryes
├─├─├─countintegeryes
├─├─├─stepsintegeryes
├─├─artsobject []yesthe generated array of imagesitem Type:object
├─├─├─idstringyesthe id of the generated image
├─├─├─imagesobject []yesvariety picture arrayitem Type:object
├─├─├─├─specstringyesvariant type. o -> origin; 2x/3x/4x -> 2/3/4 scale image
├─├─├─├─pathstringyesimage path. domain to be concatenated
├─├─├─├─sizeintegeryesimage size. unit: Byte
├─domainstringyesoss image domain

6. List Model

Basic Info

Path: /api/model/list

Method: GET

Request Params

Headers

NameValueRequiredExampleNote
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Query

NameRequiredExampleNote
pageIndexyesstart from 1
pageSizeyes
typenoplatform/community

Response Data

NameTypeRequiredDefaultNoteOthers
codeintegeryes0 -> success
infostringnoerror info
dataobjectyes
├─domainstringyesoss domain
├─totalintegeryesthe total number of models filtered for paging
├─modelsobject []yesitem Type:object
├─├─idstringyesmodel id
├─├─namestringyesmodel name
├─├─usernamestringyesmodel’s author name
├─├─descstringyesmodel description
├─├─coverstringyesmodel cover
├─├─isFavouritebooleanyeswhether the user favorites the model
├─├─controlNetbooleanyeswhether the model supports ControlNet

7. Super Resolution

Basic Info

Path: /api/job/upscale

Method: POST

Request Params

Headers

NameValueRequiredExampleNote
Content-Typeapplication/jsonyes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Body

NameTypeRequiredDefaultNoteOthers
modelstringnoupscale model name.
RealESRGAN _x4plus / RealESRGAN_x4plus_anime_6B
imagePathstringyesimage path
upscaleFactorintegeryes2 <= factor <= 4
beautybooleannowhether to enable face enhancement
artIdstringyesNeed a super point picture artID

Response Data

NameTypeRequiredDefaultNoteOthers
codenumberyes0 -> success;1000 -> no enough credit
infostringnoerror info
dataobjectyes
├─idstringnoupscale job id
├─creditintegeryesuser’s total credit
├─consumedCreditintegeryesconsumed credit of the job

8. Image Segmentation

Basic Info

Path: /api/art/segment

Method: POST

Request Params

Headers

NameValueRequiredExampleNote
Content-Typeapplication/jsonyes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Body

NameTypeRequiredDefaultNoteOthers
imagestringyesimage path. absolute/relative path

Response Data

NameTypeRequiredDefaultNoteOthers
codenumberyes0 -> success
infostringnoerror info
dataobjectyes
├─imagestringyesURL of the image after segmentating

9. GetUserInfo

Basic Info

Path: /api/user/profile

Method: GET

Request Params

Headers

NameValueRequiredExampleNote
Content-Typeapplication/jsonyes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Response Data

NameTypeRequiredDefaultNoteOthers
codenumberyes0 -> success
infostringnoerror info
dataobjectyes
├─namestringyes
├─emailstringyes
├─avatarstringyes
├─phonestringyes
├─creditintegeryestotal credit
├─displayNSFWbooleanyes
├─discordbooleanyes

10. Headshot

10.1 List Templates

Basic Info

Path: api/transform/list

Method: GET

Response Data

NameTypeRequiredDefaultNoteOthers
codenumberyes0 -> success
infostringnoerror info
dataobjectyes
├─domainstringyesimage domain
├─tagsstring[]yestemplate tag
├─transformobjectyes
├─├─tagobject[]yes
├─├─├─idstringyes
├─├─├─namestringyes
├─├─├─imagestringyesorigin image
├─├─├─artstringyesresult image
├─├─├─costnumberyescredit consume
├─├─├─probooleanyesis pro
├─├─├─tagstringyestag

10.2 Create Headshot

Basic Info

Path: api/transform/create-headshot

Method: POST

Headers

NameValueRequiredExampleNote
Content-Typeapplication/jsonyes
AuthorizationBearer {YOUR KEY}yesBearer 37f333a2d5f811edb248acde48001122

Body

NameTypeRequiredDefaultNoteOthers
imagePathstringyesimage path returned when called upload-image api
transformIdstringyes
widthintegerno
heightintegerno
keepHairbooleannofalse
keepPosebooleannotrue

Response Data

NameTypeRequiredDefaultNoteOthers
codenumberyes0 -> success;1000 -> no enough credit
infostringnoerror info
dataobjectyes
├─idstringyesjob ID
├─creditintegeryesuser’s total credit
├─consumedCreditintegeryesconsumed credit of the job

Commercial Service-toB/API

[email protected]