Create calculation specification¶
Create a calculation specification.
POST https://moi.matrixorigin.cn/newmoi/compute-resource-specs
Preparation before calling¶
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: ID of the workspace where the calculation specification is to be created, passed via theX-Workspace-IDHeader.
First Query the calculation specification management permission. A specification can only be created if the result is true. Specifications will affect the compute instances that can be created, please confirm the capacity and resource type before submitting.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/compute-resource-specs" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"id": "task-standard-small",
"kind": "task",
"family": "standard",
"family_name": "标准",
"family_name_en": "Standard",
"cpu_milli": 2000,
"memory_mib": 4096,
"gpu_count": 0,
"gpu_memory_mib": 0,
"gpu_cores": 0,
"credit_per_hour": 1,
"enabled": true
}'
Request body¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Spec ID. |
|
string |
Yes |
Computing resource type, can only be |
|
string |
Yes |
Spec family identifier. |
|
string |
Yes |
Specification family name. |
|
string |
Yes |
English name of the specification family; cannot be empty. |
|
integer |
Yes |
CPU capacity, in millicore, must be greater than |
|
integer |
Yes |
Memory capacity, in MiB, must be greater than |
|
integer |
No |
Number of GPUs. |
|
integer |
No |
GPU memory defined by a single card or specification, in MiB. |
|
integer |
No |
Number of GPU cores. |
|
number |
No |
Credit usage per hour. |
|
string |
No |
Specification. |
|
object |
No |
Node scheduling configuration. |
|
boolean |
No |
Whether to allow the use of this specification; when omitted, it is |
Successful response¶
Returns 200 on success. data returns the specification object after creation; save data.id for subsequent updates or to switch the enabled state.
{
"code": "OK",
"msg": "OK",
"data": {
"id": "task-standard-small",
"kind": "task",
"family": "standard",
"family_name": "标准",
"family_name_en": "Standard",
"cpu_milli": 2000,
"memory_mib": 4096,
"gpu_count": 0,
"gpu_memory_mib": 0,
"gpu_cores": 0,
"credit_per_hour": 1,
"description": "用于常规任务",
"node_placement": {},
"enabled": true
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
Specification ID after creation. |
|
string |
Resource type. |
|
string |
Specification family identifier. |
|
string |
Specification family name. |
|
string |
English name of the specification family. |
|
integer |
CPU capacity in millicore. |
|
integer |
Memory capacity in MiB. |
|
integer |
Number of GPUs. |
|
integer |
GPU memory, unit is MiB. |
|
integer |
Number of GPU cores. |
|
number |
Credit usage per hour. |
|
string |
Specification. |
|
string |
English specifications; system specifications can be returned. |
|
object |
Node scheduling configuration. |
|
boolean |
Enabled status after creation. |
|
boolean |
Whether it is a built-in specification of the system. |
|
string |
Creator ID. |
|
string |
The last updater ID. |
|
string |
Creation time. |
|
string |
Last updated time. |
Error response¶
{
"code": "INVALID_PARAMS",
"msg": "family_name_en is required",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body could not be parsed or |
Check JSON format and provide non-empty |
|
— |
Missing, invalid or expired access credentials. |
Check API Key. |
|
|
The current identity does not have specification management rights. |
Try again using an identity with appropriate permissions. |
|
— |
The spec ID or name conflicts with an existing spec. |
Replace the conflicting logo, or check the existing specifications first. |
|
|
The server failed to create the specification. |
Retain the error message and try again later; if failure persists, contact support. |
Follow-up operations¶
List calculation specifications After confirming that the specifications are visible, then Create a calculation instance.