Skip to main content

List Chunks

Paginate through the chunks in a Knowledge Base.

Prerequisites

Configure the endpoint and authentication first. See API overview and Authentication.

Endpoint

POST /api/v1/indices/rag/index/chunklist Paginate through the chunks in a specified knowledge base. In the response, data.nodes is the chunk array and data.total is the total chunk count.
docId filters chunks by document. Required for document-search and audio/video-search knowledge bases; not needed for data-query or image-QA knowledge bases.

Request body

FieldRequiredTypeDescription
indexIdYesstringKnowledge base ID, the data.id returned by the createIndex API.
pageNumNointegerPage number, starting from 1. Default: 1.
pageSizeNointegerNumber of chunks returned per page. Default: 20. Maximum: 100.
docIdNostringFilter by document ID, returning only the chunks under that document. Document IDs can be obtained from the List Documents API.

Request example

curl -X POST "$BASE_URL/api/v1/indices/rag/index/chunklist" \
  -H "Authorization: Bearer $BAILIAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "indexId": "your_index_id",
    "pageNum": 1,
    "pageSize": 10
  }'
BASE_URL is https://{workspace_id}.cn-beijing.maas.aliyuncs.com ({workspace_id} is the workspace ID), and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API key.

Response example

Returns 200 on success.
{
  "code": "Success",
  "status_code": 200,
  "data": {
    "total": 106,
    "nodes": [
      {
        "score": 0.0,
        "text": "这是切片的文本内容示例...",
        "metadata": {
          "_id": "llm-xxxxxxxxxxxx_your_kb_id_file_xxxxxxxx_0_0",
          "doc_id": "file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx",
          "doc_name": "sample_document",
          "title": "产品概述",
          "content": "这是切片的文本内容示例...",
          "hier_title": "产品概述|功能介绍",
          "doc_url": "https://oss-example.aliyuncs.com/...",
          "file_path": "https://oss-example.aliyuncs.com/.../docJson/sample.json",
          "image_url": [],
          "_chunk_id": 0,
          "_block_id": 0,
          "pipeline_id": "your_kb_id",
          "workspace_id": "llm-xxxxxxxxxxxx",
          "_chunk_status": 0,
          "_chunk_status_message": "成功",
          "is_displayed_chunk_content": true
        }
      }
    ],
    "isDowngrade": false
  },
  "success": true,
  "message": "success",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "status": "SUCCESS"
}

Response fields

FieldTypeDescription
codestringResponse code. Success on success.
status_codeintegerHTTP status code.
dataobjectBusiness data. Sub-fields: total (integer, total chunk count), nodes (array<object>, chunk node list. Element fields: score (number, relevance score, usually 0 for list queries), text (string, chunk text content), metadata (object, chunk metadata. Sub-fields: _id (string, globally unique chunk identifier), doc_id (string, ID of the document the chunk belongs to), doc_name (string, name of the document), title (string, chunk title), hier_title (string, hierarchical title — the title path separated by |), content (string, chunk content), doc_url (string, original document access URL), file_path (string, OSS path of the chunk parsing output), image_url (array<string>, image URLs associated with the chunk), _chunk_id (integer, chunk sequence number within the document), _block_id (integer, block sequence number), pipeline_id (string, ID of the knowledge base), workspace_id (string, ID of the workspace), _chunk_status (integer, chunk processing status code; 0 indicates success), _chunk_status_message (string, chunk processing status description), is_displayed_chunk_content (boolean, whether the chunk participates in knowledge base retrieval), nid (string, unique chunk number in the knowledge base), source (integer, chunk source type))), isDowngrade (boolean, whether retrieval downgrade occurred).
successbooleanWhether the request succeeded.
messagestringResponse message.
request_idstringUnique request identifier. Provide this ID when troubleshooting.
statusstringRequest status. SUCCESS on success.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration