Updated on 2025-05-29 GMT+08:00

API Configuration

Description

After enabling this function, you can edit RESTful APIs to define the input and output formats of a model. Ensure the API configurations comply with Specifications for Editing a Model Configuration File.
Table 1 API parameters

Parameter

Mandatory

Type

Description

url

No

String

Request path. The default value is /. For a custom image model, set this parameter to the actual request path exposed in the image. For a non-custom image model, the value of url can only be /.

method

No

String

Request method. The default value is POST.

request

No

Object

Request body. It contains two parameters:

  • Content-type: specifies the type of the content to be sent. The default value is application/json.
    The options are as follows:
    • application/json: JSON data is uploaded.
    • multipart/form-data: A file is uploaded.

    Machine learning supports only application/json.

  • data: structure of the data to be sent, which is described in JSON schema. For details about the JSON schema, see the official guide.

response

No

Object

Response body. It contains two parameters:

  • Content-type: specifies the type of the content to be received. The default value is application/json.
  • data: structure of the data to be received, which is described in JSON schema. For details about the JSON schema, see the official guide.

Code example of API parameters

[{
    "url": "/",
    "method": "post",
    "request": {
        "Content-type": "multipart/form-data",
        "data": {
            "type": "object",
            "properties": {
                "images": {
                    "type": "file"
                }
            }
        }
    },
    "response": {
        "Content-type": "applicaton/json",
        "data": {
            "type": "object",
            "properties": {
                "mnist_result": {
                    "type": "array",
                    "item": [
                        {
                            "type": "string"
                        }
                    ]
                }
            }
        }
    }
}]