# List Worker images

Lists the Worker images that can be selected when creating or updating a compute instance.

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

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

This interface requires compute instance creation permission.

## Request example

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

## Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `worker_type` | string | No | Filter by Worker type. |
| `type` | string | No | Filter by mirror key. |

## Successful response

When successful, `200` is returned, and `data` is the available mirror array.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": [
    {
      "id": "python-worker:v1",
      "worker_type": "python-worker",
      "image_key": "python-worker",
      "type": "python-worker",
      "platform": "linux/amd64",
      "is_default": true,
      "status": "active"
    }
  ]
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | object[] | Available mirror array. |
| `data[].id` | string | Image ID, passed in as `image_id` when creating or updating. |
| `data[].worker_type` | string | Passed in as `worker_type` when creating or updating. |
| `data[].image_key` | string | The specification key of the image; corresponds to `type`. |
| `data[].type` | string | Mirror key; corresponds to `image_key`. |
| `data[].tag` | string | Mirror label. |
| `data[].repository` | string | Mirror warehouse. |
| `data[].platform` | string | Passed in as `platform` when creating or updating. |
| `data[].description` | string | Mirror description; returned if there is a value. |
| `data[].is_default` | boolean | Whether it is the default image for this Worker type. |
| `data[].status` | string | The current status of the mirror. |
| `data[].registered_at` | string | Registration 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_IMAGES_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
* - `400`
  - `ErrParamInvalid`
  - The value of `worker_type` or `type` cannot be accepted by the server.
  - Check the query parameters and try again.
* - `401`
  - —
  - Missing or invalid access credentials.
  - Check API Key and Workspace Header.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to read available images.
  - Use valid credentials, or contact your administrator for authorization.
* - `500`
  - `LIST_IMAGES_FAILED`
  - The service cannot read the Worker image list.
  - Record the request time and error message and try again.
```

## Follow-up operations

Combine `id`, `worker_type` and `platform` into `worker_images`, then [Create a calculation instance](create-compute-resource.md).
