<span id="查询-llm-会话记录"></span>

# List LLM session records

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Read the current user's session records with page-number pagination.


```http
GET https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/llm/sessions
```

<span id="调用前准备"></span>

## Before you call this API

Set `BASE_URL` to the product API prefix `https://api.moi.matrixorigin.cn/v5`; use the corresponding product API URL for a dedicated deployment.

[Configure workspace identity and variables in the same environment](objects.md#request-prerequisites).

<span id="请求"></span>

## Request

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --request GET \
  "$BASE_URL/workspaces/$WORKSPACE_ID/llm/sessions?page=1&page_size=20" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID"
```

If total exceeds 20 and the first page used page_size=20, request the next page as follows:

```bash
curl --request GET \
  "$BASE_URL/workspaces/$WORKSPACE_ID/llm/sessions?page=2&page_size=20" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameters

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | Path | string | Yes | Target workspace, matching X-Workspace-ID. |
| `page` | Queries | integer | No | Page number, default 1. Invalid integers use the default; nonpositive values use 1. |
| `page_size` | Queries | integer | No | Page size, default 20. Nonpositive values or values above 100 use 20. |
| `source` | Queries | string | No | Exact application-source filter after trimming whitespace. |
| `keyword` | Queries | string | No | Title keyword filter after trimming whitespace. |
| `tag` | Queries | string | No | Filter by session tag name without simultaneously restricting tag source. |

Sorts by creation time descending, then ID descending. Keep filters and page_size fixed and increase page until page × page_size >= total. Responses contain only sessions/total and do not return normalized page/page size. Requests do not share a frozen snapshot.

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": 0,
  "data": {
    "sessions": [
      {
        "id": 41,
        "title": "临时会话",
        "source": "moi",
        "user_id": "user-example",
        "config": "{}",
        "created_at": 1794445200,
        "updated_at": 1794445200
      }
    ],
    "total": 1
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success; HTTP status 200. |
| `data.sessions` | array (objects) | [Session records](objects.md#session-object) on this page. |
| `data.total` | integer | Total sessions matching the filters. |

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error responses

[Error formats and read scope](objects.md#error-contract) describes distinct identity, parameter, resource-read, and storage failure outcomes.
