Create a calculation instance¶
Create a computing instance in the current workspace.
POST $CLOUDSIGMA_API_BASE/compute-resources
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region.
First query the calculation specification list to obtain the available spec_id. When you need to specify a mirror, then query the available Worker mirror. Prepare a personal access token and target workspace ID that can access the target workspace.
Request body¶
The example uses jq to construct the JSON request body. Install jq before running, and set the environment variables in the example. Do not re-encode the JSON generated by jq.
curl -X POST "$CLOUDSIGMA_API_BASE/compute-resources" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
--data-binary "$(jq -n --arg SPEC_ID "$SPEC_ID" --arg GO_WORKER_IMAGE_ID "$GO_WORKER_IMAGE_ID" --arg PYTHON_WORKER_IMAGE_ID "$PYTHON_WORKER_IMAGE_ID" --arg JAVA_WORKER_IMAGE_ID "$JAVA_WORKER_IMAGE_ID" --arg CUSTOM_TOOL_WORKER_IMAGE_ID "$CUSTOM_TOOL_WORKER_IMAGE_ID" '
{
"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"
}
]
}
')"
When max_replicas is omitted or a value not greater than 0 is filled in, 1 is used. The automatic pause time cannot be a negative number. If it exceeds 60 minutes, it will be processed as 60 minutes. When the platform is empty, use linux/amd64.
Actual capacity is taken from selected enabled specifications. Filling in the old capacity fields cpu, memory_gib and gpu when created will not take effect.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Compute instance name. |
|
string |
Yes |
Calculate the spec ID. |
|
string |
No |
Compatibility Tips. Instance types are subject to specifications. |
|
string |
No |
Instructions for use. |
|
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 |
Copy limit. Omission or any non-positive number is assigned to 1. |
|
integer |
No |
Number of minutes to wait for automatic pause. It cannot be negative. When it exceeds 60, press 60 to save. |
|
string |
No |
Compatible Go Worker image ID. |
|
string |
No |
Compatible Python Worker image ID. |
|
string |
No |
Compatible operating platforms. |
|
array of object |
Yes |
Worker image selection must cover all currently active |
|
string |
Yes |
Worker type, taken from |
|
string |
Yes |
Image ID, |
|
string |
Yes |
Image running platform, taken from |
|
string |
No |
Compatible with aliases. When passed in, it should be consistent with |
Before each creation, re-query the image list. Fill in one worker_images for each active Worker type, using worker_type, image_id, and platform from the list. The service does not automatically complete missing types.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"id": "resource-123",
"name": "data-processing",
"spec_id": "task-standard-small",
"min_replicas": 0,
"max_replicas": 1,
"current_replicas": 0,
"status": "IDLE",
"status_message": "",
"workspace_id": "ws_01",
"description": "",
"kind": "task",
"cpu": 0,
"memory_gib": 0,
"gpu": 0,
"cpu_milli": 0,
"memory_mib": 0,
"gpu_count": 0,
"gpu_memory_mib": 0,
"gpu_cores": 0,
"desired_replicas": 0,
"go_worker_image_id": "",
"python_worker_image_id": "",
"platform": "",
"auto_suspend_minutes": 0,
"scale_reason": "",
"is_default": false,
"created_by": "user_01",
"allowed_actions": [],
"created_at": "2026-10-14T00:00:00Z",
"updated_at": "2026-10-14T00:00:00Z"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
success code. |
|
string |
Response information. |
|
object |
The data returned by this operation. |
|
string |
ID of the new compute instance. |
|
string |
The workspace ID to which it belongs. |
|
string |
Compute instance name. |
|
string |
Example description. |
|
string |
Instance type. The values are |
|
string |
The compute specification ID to use. |
|
integer |
CPU configuration value. |
|
integer |
Configuration value in GiB of memory. |
|
integer |
GPU configuration values. |
|
integer |
CPU configuration value in millicores. |
|
integer |
Configuration value in MiB of memory. |
|
integer |
Number of GPUs. |
|
integer |
MiB of video memory for a single GPU. |
|
integer |
Number of GPU cores. |
|
integer |
Serverless instance is fixed to |
|
integer |
Maximum number of copies. |
|
integer |
The current number of replicas. |
|
integer |
Target number of copies. |
|
string |
Go Worker image ID. |
|
string |
Python Worker image ID. |
|
array of object |
Worker image selection. |
|
string |
Worker type. |
|
string |
Resource type. |
|
string |
Image ID. |
|
string |
Run the platform. |
|
string |
Instance running platform. |
|
integer |
Automatic pause waiting time. |
|
string |
The scaling reason provided by the server. |
|
boolean |
Whether it is the default computing instance of the workspace. |
|
string |
Current life cycle status. The value is |
|
string |
Supplementary status information. |
|
string |
Creator ID. |
|
array of string |
Operation hints available for the current read identity. |
|
string or null |
Last activation time. |
|
string or null |
Last active time. |
|
string |
Creation time. In RFC 3339 format. |
|
string |
Last updated. In RFC 3339 format. |
Error response¶
Error responses use code and msg to describe the error, data to null. Authentication error may not contain data. See the table below for error codes and handling methods.
{
"code": "CREATE_FAILED",
"msg": "创建计算资源失败",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
Error description. |
|
null |
Empty on error. |
Common HTTP errors¶
HTTP status |
Error code |
Common cause |
Recommended action |
|---|---|---|---|
400 |
|
Invalid request field, workspace, or operation precondition. |
Fix the request parameters and submit again. |
401 |
|
Missing or invalid authentication credentials. |
Check the credential type, expiration, and authentication header. |
403 |
|
The current identity or active role does not have permission for this operation. |
Use an authorized identity or contact an administrator to grant access. |
409 |
|
Conflict in resource state, request payload, or concurrent modification. |
Re-read the current state and version, then handle according to the latest result. |
500 |
|
Internal processing failed; write operations may have been partially applied. |
Retain request and trace details, and verify the current state before retrying. |
503 |
|
A business, runtime, or authorization dependency is temporarily unavailable. |
After the dependency recovers, check existing results first instead of blindly repeating writes. |