Create a calculation instance¶
Create a compute instance in the current workspace.
POST https://moi.matrixorigin.cn/newmoi/compute-resources
Preparation before calling¶
First list the computing specifications to obtain the available spec_id; when you need to specify the image, then list the Worker image]. Prepare a personal access token and target workspace ID that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Workspace ID to create the compute instance, passed through theX-Workspace-IDHeader.$SPEC_ID: The compute spec ID to use, taken from the response of List compute specs, specifying the instance spec in the request body.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/compute-resources" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "data-processing",
"spec_id": "'"$SPEC_ID"'",
"min_replicas": 0,
"max_replicas": 1,
"worker_images": [
{
"worker_type": "go-worker",
"image_id": "$GO_WORKER_IMAGE_ID",
"platform": "linux/amd64"
},
{
"worker_type": "python-worker",
"image_id": "$PYTHON_WORKER_IMAGE_ID",
"platform": "linux/amd64"
},
{
"worker_type": "java-worker",
"image_id": "$JAVA_WORKER_IMAGE_ID",
"platform": "linux/amd64"
},
{
"worker_type": "custom-tool-worker",
"image_id": "$CUSTOM_TOOL_WORKER_IMAGE_ID",
"platform": "linux/amd64"
}
]
}'
Request body¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Compute instance name. |
|
string |
Yes |
Calculated specification ID. |
|
string |
No |
Compatibility prompt; the instance type shall be subject to specifications. |
|
string |
No |
Usage description. |
|
integer |
No |
Compatible input; the actual capacity is determined by the corresponding specifications of |
|
integer |
No |
Compatible input; the actual capacity is determined by the corresponding specifications of |
|
integer |
No |
Compatible input; the actual capacity is determined by the corresponding specifications of |
|
integer |
No |
Serverless instances only accept |
|
integer |
No |
The upper limit of copies, must be greater than |
|
integer |
No |
Automatic pause waiting time. |
|
string |
No |
Compatible Go Worker image ID. |
|
string |
No |
Compatible Python Worker image ID. |
|
string |
No |
Compatible operating platform. |
|
object[] |
Yes |
Worker image selection, must cover all currently active |
|
string |
Yes |
Worker type, taken from |
|
string |
Yes |
Image ID, taken from |
|
string |
Yes |
Image running platform, taken from |
|
string |
No |
Compatible alias; should be consistent with |
In this document, [] after a type means an array; for example, object[] is an array of objects. In field paths, [] means each item in an array; for example, worker_images[].worker_type is the worker_type field of each item in worker_images.
worker_type, image_id and platform in worker_images should come from the mirror list. Each creation requires re-reading the mirror list and submitting one entry for each active Worker type; you cannot submit just one of them or rely on server-side auto-completion.
Successful response¶
Returns 200 on success. Save data.id. The new Serverless instance is initially IDLE, and the Worker will not be deployed immediately; subsequent workload requirements will activate the required Worker type.
{
"code": "OK",
"msg": "OK",
"data": {
"id": "resource-123",
"name": "data-processing",
"spec_id": "task-standard-small",
"status": "IDLE",
"status_message": "",
"min_replicas": 0,
"max_replicas": 1,
"current_replicas": 0
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
ID of the new computing instance. |
|
string |
ID of the workspace to which it belongs. |
|
string |
Compute instance name. |
|
string |
Example description; returned when there is a value. |
|
string |
The compute specification ID to use. |
|
string |
Instance type. |
|
integer |
CPU configuration value. |
|
integer |
Configuration value expressed in GiB of memory. |
|
integer |
GPU configuration value. |
|
integer |
CPU configuration value in millicores. |
|
integer |
Configuration value expressed in MiB of memory. |
|
integer |
Number of GPUs. |
|
integer |
MiB of video memory for a single GPU. |
|
integer |
Number of GPU cores. |
|
integer |
Serverless instances are fixed to |
|
integer |
Maximum number of copies. |
|
integer |
Number of target copies. |
|
integer |
The current number of copies. |
|
string |
Go Worker image ID; returned if there is a value. |
|
string |
Python Worker image ID; returned if there is a value. |
|
object[] |
Worker image selection; returned when there is a value. |
|
string |
Worker type. |
|
string |
Image ID. |
|
string |
Running platform. |
|
string |
Instance running platform; returned if there is a value. |
|
integer |
Automatic pause waiting time. |
|
boolean |
Whether it is the default computing instance of the workspace. |
|
string |
Current life cycle status. |
|
string |
Supplementary status information; returned if there is a value. |
|
string |
The scaling reason provided by the server; returned if there is a value. |
|
string |
Last activation time; returned if there is a value. |
|
string |
Last active time; returned if there is a value. |
|
string |
Creator ID; returned if there is a value. |
|
string |
Creation time; returned if there is a value. |
|
string |
Last updated time; returned if there is a value. |
Error response¶
{
"code": "INVALID_PARAMS",
"msg": "请求参数无效",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body cannot be parsed, or the required |
Check request fields and calculation specifications. |
|
— |
Missing or invalid access credentials. |
Check API Key and Workspace Header. |
|
|
The current identity does not have permission to create instances. |
Use valid credentials, or contact your administrator for authorization. |
|
|
An instance with the same name already exists in the workspace. |
Replace |
|
|
The server failed to create an instance. |
Record the request time and error message and try again. |
Follow-up operations¶
Query calculation instance details until the status meets the task requirements.