All Products
Search
Document Center

Platform For AI:CreateService

Last Updated:Nov 22, 2024

Creates a model service in Elastic Algorithm Service (EAS).

Operation description

**Before you call this operation, make sure that you are familiar with the billing of Elastic Algorithm Service (EAS).

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
eas:CreateServicecreate
*Service
acs:eas:{#regionId}:{#accountId}:service/*
    none
none

Request syntax

POST /api/v2/services HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
bodystringNo

The request body. For more information about the key request parameters, see Table 1. Request body parameters and Table 2. Metadata parameters. For more information about all related parameters, see Parameters of model services.

Service deployment by using an image: { "name": "foo", "metadata": { "instance": 2, "memory": 7000, "cpu": 4 }, "containers": [ { "image": "****", "script": "**** --listen=0.0.0.0 --server_port=8000 --headless", "port": 8000 } ], "storage": [ { "oss": { "path": "oss://examplebuket/data111/", "readOnly": false }, "properties": { "resource_type": "model" }, "mount_path": "/data" } ] } AI-Web application deployment by using an image: { "name": "foo", "metadata": { "instance": 1, "memory": 7000, "cpu": 4, "enable_webservice": true }, "containers": [ { "image": "****", "script": "**** --listen=0.0.0.0 --server_port=8000 --headless", "port": 8000 } ], "storage": [ { "oss": { "path": "oss://examplebucket/data111/", "readOnly": false }, "properties": { "resource_type": "model" }, "mount_path": "/data" } ] } Service deployment by using models and processors: { "metadata": { "instance": 1, "memory": 7000, "cpu": 4 }, "name": "foo", "model_config": {}, "processor_type": "python", "processor_path": "oss://****", "processor_entry": "a.py", "model_path": "oss://****" }
DevelopstringNo

Specifies whether to enter development mode.

Valid values:

  • true

  • false

true
LabelsobjectNo

The custom label.

stringNo

The label.

{"key":"value"}
WorkspaceIdstringNo

The workspace ID.

123456

Table 1. Request body parameters

ParameterTypeRequiredDescription
nameStringYesThe service name, which must be unique in a region.
tokenStringNoThe token for authentication. If you do not specify a token and generate_token is set to true, the token is automatically generated.
model_pathStringNoThe path of the model file. You can specify an HTTP address or an Object Storage Service (OSS) path. If you specify an HTTP address, the HTTP address must be publicly accessible. If you specify an OSS path, the path can be a directory or file name. If you specify a .tar.gz, .tar.bz2, or .zip file, the system automatically decompresses the file.
role_arnstringNoIf you set model_path or processor_path to an OSS address, you need to specify the role_arn parameter to access OSS and the Role_ARN parameter to obtain the role_arn.
oss_endpointStringNoThe endpoint of the OSS bucket. If you set model_path or processor_path to an OSS path, you must specify this parameter.
model_entryStringNoThe primary file of the model. Any file can be specified as the primary file of the model. If no file is specified, the file specified by model_path is used as the primary file of the model. The path of the primary file is delivered to the Load() function in the processor.
processor_pathStringYesThe path of the processor file. You can specify a local file or an HTTP address. If you specify a .tar.gz, .tar.bz2, or .zip file, the system automatically decompresses the file.
processor_entryStringNoIf you set processor_type to C, C++, or Python, this parameter is required. The main file of the processor. The main file contains the implementations of the Load() and Process() functions that are required for prediction.
processor_mainclassStringNoIf you set processor_type to Java, this parameter is required. The main class in the JAR package of the processor.
processor_typeStringYesThe language that is used to implement the processor. Valid values: C, C++, Java, and Python.
metadataDictNoThe metadata of the service. For more information, see Table 2.
cloudDictNoThe map key. This parameter is required only if you specify an instance type to deploy the service. You must specify this parameter in the following format: "cloud":{"computing":{"instance_type": "ecs.gxxxxxx.large"}}.
containersListNoThe method of container deployment that is implemented by using custom images. If the container that is deployed by using the processor cannot meet your requirements, you can deploy the container by using custom images. For more information, see Deploy a model service by using a custom image.

Description The model_path parameter and the processor_path parameter specify the sources of the model input and the processor input. You can set the paths to HTTP addresses or OSS paths. When you use the test command to debug the model on your on-premises machine, you can set the parameters to local files and directories.

  • If you use an HTTP address, you must compress the relevant files into .tar.gz, .tar.bz2, or .zip files. Then, you can upload the files to OSS to generate an HTTP address.
  • If you use an OSS path, you can enter a directory or file name as the path.

Table 2. Metadata parameters

ParameterTypeRequiredDescriptionExample
instanceIntNoThe number of workers that are required to start the service.1
cpuIntNoThe number of CPUs that are required by each worker.1
gpuIntNoThe number of GPUs that are required by each worker.0
memoryIntNoThe memory size that is required by each worker. Unit: MB.1000
resourceStringNoThe resource group to which the service belongs.eas-r-aaabbbccc
rpc.worker_threadsIntNoThe number of threads that are used to concurrently process requests in each instance.5
rpc.max_queue_sizeIntNoThe maximum size of a queue for processing requests. If the queue is full, new requests are dropped and an HTTP 450 status code is returned.64
rpc.keepaliveIntNoThe timeout period of the request. Unit: milliseconds.5000
rpc.rate_limitIntNoThe queries per second (QPS) value that triggers request throttling for a single instance. If the QPS is exceeded, new requests are dropped and an HTTP 429 status code is returned.0
releaseBoolNoSpecifies whether to create a service for canary release. Valid values: true and false. If you set this parameter to true, you must create a service for canary release.false

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

40325405-579C-4D82****
ServiceIdstring

The ID of the created service.

eas-m-aaxxxddf
ServiceNamestring

The name of the created service.

yourname
Statusstring

The service state.

Creating
Regionstring

The region ID of the created service.

cn-shanghai
InternetEndpointstring

The public endpoint of the created service.

http://pai-eas.vpc.cn-shanghai.****
IntranetEndpointstring

The internal endpoint of the created service.

http://pai-eas.cn-shanghai.****

Examples

Sample success responses

JSONformat

{
  "RequestId": "40325405-579C-4D82****",
  "ServiceId": "eas-m-aaxxxddf",
  "ServiceName": "yourname",
  "Status": "Creating",
  "Region": "cn-shanghai",
  "InternetEndpoint": "http://pai-eas.vpc.cn-shanghai.****",
  "IntranetEndpoint": "http://pai-eas.cn-shanghai.****"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-09-01The request parameters of the API has changedView Change Details
2023-01-04The request parameters of the API has changedView Change Details