Skip to main content

Add Chunk

Add chunk content to a specified knowledge base

POST
/api/v1/indices/rag/index/chunk/create
cURL
curl -X POST "https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/chunk/create" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pipelineId": "your_index_id",
    "dataId": "file_xxx",
    "field": {
      "content": "阿里云百炼 Knowledge Studio 支持多种文档格式的解析。",
      "title": "文档解析与切片",
      "image_urls": ["https://example.com/images/chunk-flow.png"]
    }
  }'
{
  "code": "Success",
  "status_code": 200,
  "success": true,
  "message": "success",
  "request_id": "56b54481-d259-9ff9-93c1-712897e5d8eb",
  "status": "SUCCESS"
}
Supports document search-type (document), data query-type (table), and image Q&A-type (image) knowledge bases; does not support multimedia search-type (multimedia) knowledge bases. Data query-type and image Q&A-type knowledge bases support only Excel table datasets as data sources. This API is idempotent; frequent calls will be rate-limited—do not exceed 10 requests per second.

field structure

Chunk content is passed as key-value pairs; the structure varies by knowledge base type. Document search-type (document) uses fixed keys:
keyTypeRequiredDescription
contentStringYesChunk body, max 6000 characters
titleStringNoChunk title, max 50 characters
image_urlsArrayNoImage links for the chunk, up to 10
Data query-type (table) and image Q&A-type (image) have no fixed keys — keys are determined by the knowledge base's data-source table: the key is the Excel column header and the value is the corresponding cell value; headers that participate in retrieval or answering are required. Value requirements by type:
TypeRequirement
StringMax 6000 characters
Time13-digit timestamp (milliseconds)
LongInteger, max 2147483647
DoubleDecimals supported
image_urlUp to 5 images; multiple images joined into one string with commas

Authorizations

string
header
required

DashScope API Key,在控制台 API Key 页面 获取。

Body

application/json
string
required

知识库 ID,即 createIndex 接口返回的 data.id。

object
required

切片内容信息(键值对),结构因知识库类型而异,详见 field 结构

string

文件 ID,即 addFile 接口返回的 fileId。文档搜索类知识库用于指定切片所属文档。

Response

200-application/json
string

响应码,成功时为 Success。

integer

HTTP 状态码。

boolean

接口调用是否成功。

string

响应消息,成功时为 success。

string

请求唯一标识,排查问题时请提供此 ID。

string

接口返回的状态,成功时为 SUCCESS。