Save an LLM session message¶
Save one message record in the current user’s session.
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/llm/sessions/{session_id}/messages
Before you call this API¶
Set BASE_URL to the product API prefix https://api.moi.matrixorigin.cn/v5. For private deployments, use the corresponding product API URL.
Configure Workspace identity and variables in the same environment.
Request¶
curl --request POST \
"$BASE_URL/workspaces/$WORKSPACE_ID/llm/sessions/$SESSION_ID/messages" \
--header "X-API-Key: $MOI_KEY" \
--header "X-Workspace-ID: $WORKSPACE_ID" \
--header "Content-Type: application/json" \
--data-raw '{"source":"moi","role":0,"content":"保存这条消息"}'
Parameter |
Location |
Type |
Required |
Description |
|---|---|---|---|---|
|
Path |
string |
Yes |
Target Workspace, matching X-Workspace-ID. |
|
Path |
integer |
Yes |
Positive integer ID returned by this service. |
|
Body |
string |
No |
Application source string, saved independently of the session source. |
|
Body |
integer |
No |
Message role: 0=user, 1=system, 2=assistant, 3=agent_tool. Defaults to 0. |
|
Body |
string |
No |
Original content text. |
|
Body |
string |
No |
Message content text; currently accepts an empty string. |
|
Body |
string |
No |
Model name saved in the message record; does not trigger a model call. |
|
Body |
string |
No |
Record status. Empty string, null, or omission becomes pending. |
|
Body |
string |
No |
Saved response text. |
|
Body |
string |
No |
Saved modified response text. |
|
Body |
string |
No |
Configuration stored as text. |
Success means the record was saved, not that model execution or an answer completed. This API has no business request_id deduplication. Query messages first for an unknown outcome to avoid duplicate saves. Written status is a storage field, not runtime task status.
Successful response¶
{
"code": 0,
"data": {
"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
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
0 on success; HTTP status is 201. |
|
object |
Error responses¶
Error formats and read scope explains differing identity, parameter, resource-read, and storage-failure outcomes.