# Get a compute resource

Retrieve the configuration, capacity, and current status of a compute resource.

```text
GET $CLOUDSIGMA_API_BASE/compute-resources/{resource_id}
```

## Before you call this API

1. Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.
2. Obtain the compute resource ID from [List compute resources](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/list-compute-resources.html.md) or from the response returned when you [create a compute resource](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/create-compute-resource.html.md).
3. Store the compute resource ID in an environment variable:

```bash
export RESOURCE_ID="<compute-resource-id>"
```

## Request example

```bash
curl "$CLOUDSIGMA_API_BASE/compute-resources/$RESOURCE_ID" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | Yes | ID of the compute resource to retrieve. |

## Successful response

The API returns HTTP `200` and the compute resource in `data`.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": "cr-001",
    "name": "data-processing",
    "kind": "task",
    "spec_id": "task-standard-small",
    "status": "ACTIVE",
    "status_message": "",
    "min_replicas": 0,
    "max_replicas": 2,
    "current_replicas": 1
  }
}
```

### Response envelope

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | Human-readable result message. |
| `data` | object | Retrieved compute resource. |

### Identity and configuration

| Field | Type | Description |
| --- | --- | --- |
| `data.id` | string | Compute resource ID. |
| `data.workspace_id` | string | ID of the workspace that owns the resource. |
| `data.name` | string | Compute resource name. |
| `data.description` | string | Compute resource description, when provided. |
| `data.spec_id` | string | Compute specification ID. |
| `data.kind` | string | Compute resource type. |
| `data.cpu` | integer | Allocated CPU capacity. |
| `data.memory_gib` | integer | Allocated memory in GiB. |
| `data.gpu` | integer | Allocated GPU capacity. |
| `data.cpu_milli` | integer | Allocated CPU capacity in millicores. |
| `data.memory_mib` | integer | Allocated memory in MiB. |
| `data.gpu_count` | integer | Number of allocated GPUs. |
| `data.gpu_memory_mib` | integer | Memory per GPU in MiB. |
| `data.gpu_cores` | integer | Number of GPU cores. |
| `data.go_worker_image_id` | string | Go worker image ID, when configured. |
| `data.python_worker_image_id` | string | Python worker image ID, when configured. |
| `data.worker_images` | object[] | Worker images assigned to the resource. |
| `data.worker_images[].worker_type` | string | Worker type. |
| `data.worker_images[].image_id` | string | Image ID. |
| `data.worker_images[].platform` | string | Worker image platform. |
| `data.platform` | string | Runtime platform, when provided. |

### Capacity and status

| Field | Type | Description |
| --- | --- | --- |
| `data.min_replicas` | integer | Minimum number of replicas. A serverless resource uses `0`. |
| `data.max_replicas` | integer | Maximum number of replicas. |
| `data.desired_replicas` | integer | Requested number of replicas. |
| `data.current_replicas` | integer | Current number of replicas. |
| `data.auto_suspend_minutes` | integer | Inactivity period, in minutes, before automatic suspension. |
| `data.is_default` | boolean | Whether this is the workspace's default compute resource. |
| `data.status` | string | Current lifecycle state, such as `IDLE`, `ACTIVE`, `SUSPENDED`, or `ERROR`. |
| `data.status_message` | string | Additional status information. |
| `data.scale_reason` | string | Reason for the most recent scaling decision, when provided. |
| `data.last_activation_at` | string | Time of the most recent activation, when available. |
| `data.last_active_at` | string | Time the resource was most recently active, when available. |
| `data.created_by` | string | Creator ID; returned if there is a value. |
| `data.created_at` | string | Creation time. |
| `data.updated_at` | string | Last update time. |

In a field path, `[]` represents each item in an array. For example, `data.worker_images[].worker_type` is the `worker_type` of each object in `data.worker_images`.

## Error response

```json
{
  "code": "NOT_FOUND",
  "msg": "对象不存在",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status
  - Error code
  - Common cause
  - Recommended action
* - `401`
  - —
  - Missing or invalid access credentials.
  - Check the regional endpoint and API key.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to read the compute resource.
  - Ask a workspace administrator to grant the required permission.
* - `404`
  - `NOT_FOUND`
  - The compute resource does not exist in the selected workspace.
  - Check `RESOURCE_ID`, `WORKSPACE_ID`, and the regional endpoint.
```

## Follow-up operations

After retrieving the resource, you can:

- [Get its worker runtime](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/get-worker-runtime.html.md).
- [Update its configuration](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/update-compute-resource.html.md).
- [Suspend](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/suspend-compute-resource.html.md), [resume](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/resume-compute-resource.html.md), or [retry](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/compute-resources/retry-compute-resource.html.md) the resource according to its current `status`.
