Creates a model service in EAS.
Operation description
**Before you call this operation, read the EAS billing information.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
eas:CreateService |
create |
*All Resource
|
None | None |
Request syntax
POST /api/v2/services HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| body |
string |
No |
The request body. Key parameters are listed in Table 1. Request body parameters and Table 2. Metadata parameters. For the full parameter list, see Parameters of model services. |
Image deployment service: { "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" } ] } Image deployment AI-Web application: { "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" } ] } Model + processor deployment service: { "metadata": { "instance": 1, "memory": 7000, "cpu": 4 }, "name": "foo", "model_config": {}, "processor_type": "python", "processor_path": "oss://****", "processor_entry": "a.py", "model_path": "oss://****" } |
| Develop |
string |
No |
Specifies whether to enter development mode. Valid values:
Valid values:
|
true |
| Labels |
object |
No |
The custom label. |
|
|
string |
No |
The label. |
{"key":"value"} |
|
| WorkspaceId |
string |
No |
The workspace ID. |
123456 |
Table 1. Request body parameters
| Parameter | Type | Required | Description |
| name | String | Yes | The service name. Must be unique within a region. |
| token | String | No | The authentication token. Auto-generated if omitted and generate_token is set to true. |
| model_path | String | No | The model file path. Supports HTTP URLs (must be publicly accessible) or OSS paths (directory or file). .tar.gz, .tar.bz2, and .zip files are automatically decompressed. |
| role_arn | string | No | The RAM role ARN for accessing OSS. Required when model_path or processor_path uses an OSS address. |
| oss_endpoint | String | No | The OSS bucket endpoint. Required when model_path or processor_path uses an OSS path. |
| model_entry | String | No | The model entry file. Defaults to model_path if not specified. The path is passed to the processor's Load() function. |
| processor_path | String | Yes | The processor file path. Supports local files or HTTP URLs. .tar.gz, .tar.bz2, and .zip files are automatically decompressed. |
| processor_entry | String | No | Required if processor_type is C, C++, or Python. The processor entry file containing the Load() and Process() function implementations. |
| processor_mainclass | String | No | Required if processor_type is Java. The main class in the processor JAR package. |
| processor_type | String | Yes | The language that is used to implement the processor. Valid values: C, C++, Java, and Python. |
| metadata | Dict | No | The service metadata. See Table 2. |
| cloud | Dict | No | The cloud computing configuration. Required when deploying with a specified instance type. Format: "cloud":{"computing":{"instance_type": "ecs.gxxxxxx.large"}}. |
| containers | List | No | The custom image container configuration. Use this when the built-in processor does not meet your requirements. Deploy a model service by using a custom image. |
Description The model_path and processor_path parameters accept HTTP URLs or OSS paths. For local debugging, you can specify local files and directories.
-
HTTP URLs: compress files into .tar.gz, .tar.bz2, or .zip format and upload to OSS to generate the URL.
-
OSS paths: specify a directory or file name.
Table 2. Metadata parameters
| Parameter | Type | Required | Description | Example |
| instance | Int | No | The number of workers to start. | 1 |
| cpu | Int | No | The number of CPUs per worker. | 1 |
| gpu | Int | No | The number of GPUs per worker. | 0 |
| memory | Int | No | The memory per worker, in MB. | 1000 |
| resource | String | No | The resource group for the service. | eas-r-aaabbbccc |
| rpc.worker_threads | Int | No | The number of concurrent request-processing threads per instance. | 5 |
| rpc.max_queue_size | Int | No | The maximum request queue size. Excess requests return HTTP 450. | 64 |
| rpc.keepalive | Int | No | The request timeout, in milliseconds. | 5000 |
| rpc.rate_limit | Int | No | The per-instance QPS throttling limit. Excess requests return HTTP 429. | 0 |
| release | Bool | No | Specifies whether to enable canary release for the service. Valid values: true and false. | false |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response parameters. |
||
| RequestId |
string |
The request ID. |
40325405-579C-4D82**** |
| ServiceId |
string |
The ID of the created service. |
eas-m-aaxxxddf |
| ServiceName |
string |
The name of the created service. |
yourname |
| Status |
string |
The service state. |
Creating |
| Region |
string |
The region ID of the created service. |
cn-shanghai |
| InternetEndpoint |
string |
The public endpoint of the created service. |
http://pai-eas.vpc.cn-shanghai.**** |
| IntranetEndpoint |
string |
The internal endpoint of the created service. |
http://pai-eas.cn-shanghai.**** |
Examples
Success response
JSON format
{
"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
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.