List LLM conversation messages

Read the current user’s conversation messages using a message ID cursor.

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

Before you call this API

BASE_URL uses the product API prefix https://api.moi.matrixorigin.cn/v5. For a dedicated deployment, use its corresponding product API address.

Configure Workspace identity and variables in the same environment.

Request

curl --request GET \
  "$BASE_URL/workspaces/$WORKSPACE_ID/llm/sessions/$SESSION_ID/messages?after=0&limit=50" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID"

Save the last message id from the preceding page as AFTER_MESSAGE_ID, then read the next page:

curl --request GET \
  "$BASE_URL/workspaces/$WORKSPACE_ID/llm/sessions/$SESSION_ID/messages?after=$AFTER_MESSAGE_ID&limit=50" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID"

Parameter

Location

Type

Required

Description

workspace_id

Path

string

Yes

Target Workspace, matching X-Workspace-ID.

session_id

Path

integer

Yes

Positive integer ID returned by this service.

after

Query

integer

No

Returns IDs greater than this value. Defaults to 0; nonpositive values become0.

limit

Query

integer

No

Maximum messages per request, default 50. Values<=0 or>100 use 50.

role

Query

integer

No

Single role filter:0=user,1=system,2=assistant. The current service treats3 as no filtering.

status

Query

string

No

Filter by stored state; surrounding whitespace is trimmed.

Messages sort by ascending ID. Set next after to the preceding page’s last message id, retain filters, and continue until messages=[]. There is no next_cursor. total is the total after role/status filters and does not shrink with after. role must be one integer parseable as0–3. Repeated, empty, or out-of-range values return 400; omission means no filter. source/model currently do not filter results.

Successful response

{
  "code": 0,
  "data": {
    "messages": [
      {
        "id": 71,
        "user_id": "user-example",
        "session_id": 41,
        "source": "moi",
        "role": 0,
        "original_content": "",
        "content": "保存这条消息",
        "model": "",
        "status": "pending",
        "response": "",
        "modified_response": "",
        "config": "",
        "created_at": 1794445200,
        "updated_at": 1794445200
      }
    ],
    "total": 1
  }
}

Field

Type

Description

code

integer

0 on success; HTTP status is 200.

data.messages

array (array of objects)

Message records on this page.

data.total

integer

Total matching role/state filters, independent of after.

Error response

Error formats and read scope explains differing identity, parameter, resource-read, and storage-failure outcomes.

Last updated on