> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ariacompute.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 基于文档问答 - POST /v1/workspaces/:workspace_id/chat

> 通过 POST /v1/workspaces/:workspace_id/chat 在工作空间知识库上做检索增强问答，SSE 流式返回。最小角色 viewer。

在工作空间的知识库上做检索增强问答（RAG）。接口以 **SSE（Server-Sent Events）** 流式返回答案与引用，内容类型 `text/event-stream`。

## 接口

```http theme={null}
POST /v1/workspaces/:workspace_id/chat
```

## 认证

`Authorization: Bearer <jwt>` 或 `X-API-Key <sk_...>`。最小角色：**viewer**。

## 路径参数

<ParamField path="workspace_id" type="string" required>
  工作空间 id。
</ParamField>

## 请求体

<ParamField body="query" type="string" required>
  用户提问。
</ParamField>

<ParamField body="k" type="integer">
  检索召回的文档块数量，省略时由服务端取默认。
</ParamField>

## 响应（流式）

`Content-Type: text/event-stream`。每个 `data:` 行是一段增量文本；结束时追加「引用」段落，列出命中的文档与片段。客户端按 SSE 逐行读取即可。

## 示例

<RequestExample>
  ```bash cURL theme={null}
  curl -N -X POST https://memo.ariacompute.cn/v1/workspaces/ws_01a2b3c4d5e6/chat \
    -H "Authorization: Bearer <jwt>" \
    -H "Content-Type: application/json" \
    -d '{"query":"AriaMem 支持哪些转换？","k":4}'
  ```
</RequestExample>

<ResponseExample>
  ```text stream theme={null}
  data: AriaMem 支持
  data: 知识库到记忆
  data: 以及记忆到知识库的
  data: 双向转换。

  data: 引用： [1] 文档:doc_01a2b3c4d5e6 片段:AriaMem 支持知识库与记忆的双向转换。
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.