# List calculation instances

Lists the compute instances in the current workspace that the caller has read access to.

```text
GET https://moi.matrixorigin.cn/newmoi/compute-resources
```

## 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 the `X-API-Key` Header.
- `$WORKSPACE_ID`: The workspace ID to be queried is passed through the `X-Workspace-ID` Header.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/compute-resources" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Successful response

When successful, `200` is returned. `data` is the calculation instance array.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": [
    {
      "id": "cr-001",
      "name": "data-processing",
      "spec_id": "task-standard-small",
      "status": "IDLE",
      "current_replicas": 0,
      "max_replicas": 1
    }
  ]
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | object[] | List of calculation instances. |
| `data[].id` | string | Calculated instance ID, used for details and subsequent operations. |
| `data[].workspace_id` | string | ID of the workspace to which it belongs. |
| `data[].name` | string | Compute instance name. |
| `data[].description` | string | Example description; returned when there is a value. |
| `data[].spec_id` | string | Selected compute specification ID. |
| `data[].kind` | string | Instance type. |
| `data[].cpu` | integer | CPU configuration value. |
| `data[].memory_gib` | integer | Configuration value expressed in GiB of memory. |
| `data[].gpu` | integer | GPU configuration value. |
| `data[].cpu_milli` | integer | CPU configuration value in millicores. |
| `data[].memory_mib` | integer | Configuration value expressed 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 instances are fixed to `0`. |
| `data[].max_replicas` | integer | Maximum number of copies. |
| `data[].desired_replicas` | integer | Number of target copies. |
| `data[].status` | string | Current life cycle status. |
| `data[].current_replicas` | integer | The number of currently running replicas. |
| `data[].go_worker_image_id` | string | Go Worker image ID; returned if there is a value. |
| `data[].python_worker_image_id` | string | Python Worker image ID; returned if there is a value. |
| `data[].worker_images` | object[] | Worker image selection; returned when there is a value. |
| `data[].worker_images[].worker_type` | string | Worker type. |
| `data[].worker_images[].image_id` | string | Image ID. |
| `data[].worker_images[].platform` | string | Running platform. |
| `data[].platform` | string | Instance running platform; returned if there is a value. |
| `data[].auto_suspend_minutes` | integer | Automatic pause waiting time. |
| `data[].is_default` | boolean | Whether it is the default computing instance of the workspace. |
| `data[].status_message` | string | Supplementary status information; returned if there is a value. |
| `data[].scale_reason` | string | The scaling reason provided by the server; returned if there is a value. |
| `data[].last_activation_at` | string | Last activation time; returned if there is a value. |
| `data[].last_active_at` | string | Last active time; returned if there is a value. |
| `data[].created_by` | string | Creator ID; returned if there is a value. |
| `data[].created_at` | string | Creation time; returned if there is a value. |
| `data[].updated_at` | string | Last updated time; returned if there is a value. |

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, `data[].id` is the `id` field of each item in `data`.

## Error response

```json
{
  "code": "LIST_FAILED",
  "msg": "服务端错误",
  "data": null
}
```

### Common HTTP errors

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

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `401`
  - —
  - Missing or invalid access credentials.
  - Check API Key and Workspace Header.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to query computing resources.
  - Use valid credentials, or contact your administrator for authorization.
* - `500`
  - `LIST_FAILED`
  - The service cannot read the list of computing resources.
  - Record the request time and error message and try again.
```

## Follow-up operations

Save `data[].id`, and then [Query calculation instance details](get-compute-resource.md) or [Create a calculation instance](create-compute-resource.md).
