API:会话
Halo HTTP API 会话接口:发起一轮任务、停止运行、查看进行中的会话,列出、读取、重命名、星标和删除会话。
会话是工作区里你和 Halo 助手之间的对话线程。API 按工作区组织会话,路径里的工作区写作 spaces。用这些接口在会话中发起任务、跟进和停止运行,并管理会话列表。与数字人的聊天在 API:数字人 页。
所有路径都相对于你的 Halo 地址,每个请求都要带上访问密码。示例中的 $HALO_URL 和 $HALO_TOKEN 按快速上手设置;地址、鉴权和错误约定见 HTTP API 概览。
| 操作 | 端点 |
|---|---|
| 查询 Halo 是否仍在某个会话中生成回复 | GET /api/agent/generating/:conversationId |
| 在会话中发起一轮新任务 | POST /api/agent/message |
| 列出 Halo 正在处理的会话 | GET /api/agent/sessions |
| 停止 Halo 在会话中正在做的事 | POST /api/agent/stop |
| 列出会话可用的按需能力 | POST /api/agent/toolsets/list |
| 列出工作区中的会话 | GET /api/spaces/:spaceId/conversations |
| 新建空会话 | POST /api/spaces/:spaceId/conversations |
| 读取会话及其消息 | GET /api/spaces/:spaceId/conversations/:conversationId |
| 修改会话标题或元数据 | PUT /api/spaces/:spaceId/conversations/:conversationId |
| 删除会话 不可撤销 | DELETE /api/spaces/:spaceId/conversations/:conversationId |
| 读取一条消息背后的思考过程和工具调用 | GET /api/spaces/:spaceId/conversations/:conversationId/messages/:messageId/thoughts |
| 星标或取消星标会话 | POST /api/spaces/:spaceId/conversations/:conversationId/star |
查询 Halo 是否仍在某个会话中生成回复
GET /api/agent/generating/:conversationId 助手可调用
- Pairs with
POST /api/agent/stop— check this before deciding whether there is anything to stop
路径参数
| 名称 | 说明 |
|---|---|
conversationId | 会话 ID,来自 GET /api/spaces/:spaceId/conversations。 |
响应
{success:true,data:boolean}示例
curl -s "$HALO_URL/api/agent/generating/<conversationId>" \
-H "Authorization: Bearer $HALO_TOKEN"在会话中发起一轮新任务
POST /api/agent/message 助手可调用
- Starts Halo working in the conversation and returns as soon as the turn is accepted:
success: truemeans accepted, not answered. The reply is written afterwards. - Follow the reply over the WebSocket after subscribing to the conversation, or poll
GET /api/agent/generating/:conversationIdwith a growing interval (2 s, then double) and read the conversation when it is done. - Optional body fields:
resumeSessionId,thinkingEnabled(boolean),reasoningEffort(off,minimal,low,medium,high,xhighormax; overridesthinkingEnabled, but a level the user chose for this conversation wins),knowledgeBaseId,images(base64 attachments; the whole JSON body must stay under 100 KB). - Start work in a conversation you created with
POST /api/spaces/:spaceId/conversations, so your turn never interrupts one the user is having. - A turn can stop to ask the user a question. The user answers it in the Halo app, and the turn waits until then.
请求体
{
"spaceId": "<spaceId>",
"conversationId": "<conversationId>",
"message": "Summarize the activity log"
}响应
{success:true} // no data — the turn runs after the call returns示例
curl -sX POST "$HALO_URL/api/agent/message" \
-H "Authorization: Bearer $HALO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"spaceId":"<spaceId>","conversationId":"<conversationId>","message":"Summarize the activity log"}'列出 Halo 正在处理的会话
GET /api/agent/sessions 助手可调用
响应
{success:true,data:string[]} // array of conversationId, each one currently generating a reply示例
curl -s "$HALO_URL/api/agent/sessions" \
-H "Authorization: Bearer $HALO_TOKEN"停止 Halo 在会话中正在做的事
POST /api/agent/stop 助手可调用
conversationIdis optional. Leave it out (or send{}) to stop everything Halo is doing.
请求体
{
"conversationId": "<conversationId>"
}响应
{success:true}示例
curl -sX POST "$HALO_URL/api/agent/stop" \
-H "Authorization: Bearer $HALO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"conversationId":"<conversationId>"}'列出会话可用的按需能力
POST /api/agent/toolsets/list 助手可调用
- Read-only: lists the on-demand capabilities (toolsets in the API) a conversation can use and whether each is open. The user opens and closes them in the composer under + › Capabilities.
请求体
{
"spaceId": "<spaceId>",
"conversationId": "<conversationId>"
}响应
{success:true,data:[{id:string,displayName:string,summary:string,open:boolean}]}示例
curl -sX POST "$HALO_URL/api/agent/toolsets/list" \
-H "Authorization: Bearer $HALO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"spaceId":"<spaceId>","conversationId":"<conversationId>"}'列出工作区中的会话
GET /api/spaces/:spaceId/conversations 助手可调用
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
响应
{
"success": true,
"data": [
{
"id": "<uuid>",
"title": "…",
"starred": false
}
]
}示例
curl -s "$HALO_URL/api/spaces/<spaceId>/conversations" \
-H "Authorization: Bearer $HALO_TOKEN"新建空会话
POST /api/spaces/:spaceId/conversations 助手可调用
- Creates an empty conversation. To make Halo work in it, call
POST /api/agent/messagewith its id. - Optional body field
reasoningEffort:off,minimal,low,medium,high,xhighormax— how hard the model thinks. Leave it out to follow the model's configured effort. - Optional body field
ephemeral(boolean): for a view that shows the transcript itself. The conversation is left out of every list and search, and deleted at the next start of Halo unless deleted before. Leave it out for a conversation the user should see.
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
请求体
{
"title": "Weekly report"
}响应
{
"success": true,
"data": {
"id": "<uuid>",
"title": "Weekly report"
}
}示例
curl -sX POST "$HALO_URL/api/spaces/<spaceId>/conversations" \
-H "Authorization: Bearer $HALO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Weekly report"}'读取会话及其消息
GET /api/spaces/:spaceId/conversations/:conversationId 助手可调用
- Long conversations return a lot of text. To read only what is new, pass
?from=<messageId>: messages start at that message (inclusive) and the response carriesmessagesFrom. An unknown id returns the whole conversation. - Each message has its own
id; it is themessageIdthatGET /api/spaces/:spaceId/conversations/:conversationId/messages/:messageId/thoughtstakes.
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
conversationId | 会话 ID,来自 GET /api/spaces/:spaceId/conversations。 |
查询参数:from
响应
{
"success": true,
"data": {
"id": "<uuid>",
"messages": [
{
"id": "<uuid>",
"role": "user",
"content": "…"
}
]
}
}示例
curl -s "$HALO_URL/api/spaces/<spaceId>/conversations/<conversationId>" \
-H "Authorization: Bearer $HALO_TOKEN"修改会话标题或元数据
PUT /api/spaces/:spaceId/conversations/:conversationId 可撤销 助手可调用
- modelSourceId + modelId (always both; sourceId is a uuid from
GET /api/config) pin the account and model the conversation runs on. A pin naming an account that no longer exists is not rejected: the conversation runs on the current global account until it is pinned again.
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
conversationId | 会话 ID,来自 GET /api/spaces/:spaceId/conversations。 |
请求体
{
"title": "Renamed conversation"
}响应
{"success":true,"data":{...updated conversation}}示例
curl -sX PUT "$HALO_URL/api/spaces/<spaceId>/conversations/<conversationId>" \
-H "Authorization: Bearer $HALO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Renamed conversation"}'删除会话
DELETE /api/spaces/:spaceId/conversations/:conversationId 不可撤销 助手可调用
不可撤销
执行后无法撤销,数据也不会进入回收站。调用前请确认这是用户想要的结果。
- Removes the conversation file and its reasoning history from disk. There is no backup.
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
conversationId | 会话 ID,来自 GET /api/spaces/:spaceId/conversations。 |
响应
{
"success": true
}示例
curl -sX DELETE "$HALO_URL/api/spaces/<spaceId>/conversations/<conversationId>" \
-H "Authorization: Bearer $HALO_TOKEN"读取一条消息背后的思考过程和工具调用
GET /api/spaces/:spaceId/conversations/:conversationId/messages/:messageId/thoughts 助手可调用
- Wrong ids return an empty array, not a 404 — an empty result does not prove the message had no thoughts.
- toolInput and toolOutput are the raw arguments and results of that turn, so this gets long fast. Read it to diagnose what Halo actually did, not as a way to read a conversation.
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
conversationId | 会话 ID,来自 GET /api/spaces/:spaceId/conversations。 |
messageId | 消息 ID,来自 GET /api/spaces/:spaceId/conversations/:conversationId 返回的消息列表。 |
响应
{
"success": true,
"data": [
{
"id": "…",
"type": "…",
"content": "…",
"timestamp": "…",
"toolName": "…",
"toolInput": {},
"toolOutput": "…"
}
]
}示例
curl -s "$HALO_URL/api/spaces/<spaceId>/conversations/<conversationId>/messages/<messageId>/thoughts" \
-H "Authorization: Bearer $HALO_TOKEN"星标或取消星标会话
POST /api/spaces/:spaceId/conversations/:conversationId/star 可撤销 助手可调用
路径参数
| 名称 | 说明 |
|---|---|
spaceId | 工作区 ID,来自 GET /api/spaces。Halo 工作区的 ID 固定为 halo-temp。 |
conversationId | 会话 ID,来自 GET /api/spaces/:spaceId/conversations。 |
请求体
{
"starred": true
}响应
{
"success": true
}示例
curl -sX POST "$HALO_URL/api/spaces/<spaceId>/conversations/<conversationId>/star" \
-H "Authorization: Bearer $HALO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"starred":true}'