Create a calculation instance

Create a computing instance in the current workspace.

HTTP
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.

Shell
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

name

string

Yes

Compute instance name.

spec_id

string

Yes

Calculate the spec ID.

kind

string

No

Compatibility Tips. Instance types are subject to specifications.

description

string

No

Instructions for use.

cpu

integer

No

Compatible input. The actual capacity is determined by the corresponding specifications of spec_id.

memory_gib

integer

No

Compatible input. The actual capacity is determined by the corresponding specifications of spec_id.

gpu

integer

No

Compatible input. The actual capacity is determined by the corresponding specifications of spec_id.

min_replicas

integer

No

Serverless instances only accept 0, or 0 when omitted.

max_replicas

integer

No

Copy limit. Omission or any non-positive number is assigned to 1.

auto_suspend_minutes

integer

No

Number of minutes to wait for automatic pause. It cannot be negative. When it exceeds 60, press 60 to save.

go_worker_image_id

string

No

Compatible Go Worker image ID.

python_worker_image_id

string

No

Compatible Python Worker image ID.

platform

string

No

Compatible operating platforms.

worker_images

array of object

Yes

Worker image selection must cover all currently active worker_type in the image list.

worker_images[].worker_type

string

Yes

Worker type, taken from worker_type in the image list.

worker_images[].image_id

string

Yes

Image ID, id taken from the image list.

worker_images[].platform

string

Yes

Image running platform, taken from platform in the image list.

worker_images[].kind

string

No

Compatible with aliases. When passed in, it should be consistent with worker_type.

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

JSON
{
  "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

code

string

success code.

msg

string

Response information.

data

object

The data returned by this operation.

data.id

string

ID of the new compute instance.

data.workspace_id

string

The workspace ID to which it belongs.

data.name

string

Compute instance name.

data.description

string

Example description.

data.kind

string

Instance type. The values are task, query

data.spec_id

string

The compute specification ID to use.

data.cpu

integer

CPU configuration value.

data.memory_gib

integer

Configuration value in GiB of memory.

data.gpu

integer

GPU configuration values.

data.cpu_milli

integer

CPU configuration value in millicores.

data.memory_mib

integer

Configuration value in MiB of memory.

data.gpu_count

integer

Number of GPUs.

data.gpu_memory_mib

integer

MiB of video memory for a single GPU.

data.gpu_cores

integer

Number of GPU cores.

data.min_replicas

integer

Serverless instance is fixed to 0

data.max_replicas

integer

Maximum number of copies.

data.current_replicas

integer

The current number of replicas.

data.desired_replicas

integer

Target number of copies.

data.go_worker_image_id

string

Go Worker image ID.

data.python_worker_image_id

string

Python Worker image ID.

data.worker_images

array of object

Worker image selection.

data.worker_images[].worker_type

string

Worker type.

data.worker_images[].kind

string

Resource type.

data.worker_images[].image_id

string

Image ID.

data.worker_images[].platform

string

Run the platform.

data.platform

string

Instance running platform.

data.auto_suspend_minutes

integer

Automatic pause waiting time.

data.scale_reason

string

The scaling reason provided by the server.

data.is_default

boolean

Whether it is the default computing instance of the workspace.

data.status

string

Current life cycle status. The value is IAM_CREATE_PENDING, IDLE, DEPLOYING, SCALING, ACTIVE , DRAINING, SUSPENDED, TERMINATING, ERROR, DELETED

data.status_message

string

Supplementary status information.

data.created_by

string

Creator ID.

data.allowed_actions

array of string

Operation hints available for the current read identity.

data.last_activation_at

string or null

Last activation time.

data.last_active_at

string or null

Last active time.

data.created_at

string

Creation time. In RFC 3339 format.

data.updated_at

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.

JSON
{
  "code": "CREATE_FAILED",
  "msg": "创建计算资源失败",
  "data": null
}

Field

Type

Description

code

string

error code.

msg

string

Error description.

data

null

Empty on error.

Common HTTP errors

HTTP status

Error code

Common cause

Recommended action

400

INVALID_PARAMS

Invalid request field, workspace, or operation precondition.

Fix the request parameters and submit again.

401

Unauthorized

Missing or invalid authentication credentials.

Check the credential type, expiration, and authentication header.

403

ErrForbidden

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

COMPUTE_RESOURCE_NAME_EXISTS

Conflict in resource state, request payload, or concurrent modification.

Re-read the current state and version, then handle according to the latest result.

500

CREATE_FAILED

Internal processing failed; write operations may have been partially applied.

Retain request and trace details, and verify the current state before retrying.

503

CREATE_UNAVAILABLE, ErrServiceUnavailable

A business, runtime, or authorization dependency is temporarily unavailable.

After the dependency recovers, check existing results first instead of blindly repeating writes.

Last updated on