Skip to main content

Add Chunk

Add a chunk 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": "Bailian Knowledge Studio supports parsing multiple document formats.",
      "title": "Document Parsing and Chunking",
      "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 (document), data query (table), and image Q&A (image) knowledge bases; does not support audio/video search (multimedia). Data query and image Q&A knowledge bases only support the spreadsheet connector (Excel) data source. This API is idempotent. Frequent calls will be rate-limited; do not exceed 10 calls per second.

Authorizations

string
header
required

DashScope API Key, obtained from the API Key page in the console.

Body

application/json
string
required

Knowledge base ID, returned as data.id from the createIndex API.

object
required

Chunk content as key-value pairs. Structure varies by knowledge base type, see details below.

Document search (document) uses fixed keys:

  • content (String, required): Chunk body text, max length 6000
  • title (String, optional): Chunk title, max length 50
  • image_urls (Array, optional): Image URLs included in the chunk, max 10

Data query (table), Image Q&A (image) keys are not fixed, determined by the KB's spreadsheet data source. Keys are Excel column headers, values are the corresponding cell values. Fields used for retrieval or reply are required. Value type requirements:

  • String: max length 6000
  • Time: 13-digit timestamp (milliseconds)
  • Long: integer, max 2147483647
  • Double: supports decimals
  • image_url: max 5 images, multiple values comma-separated as a single string
string

File ID, returned as fileId from the addFile API. For document search KBs, specifies the parent document of the chunk.

Response

200-application/json
string

Response code. Success on success.

integer

HTTP status code.

boolean

Whether the API call succeeded.

string

Response message. success on success.

string

Unique request identifier. Include this ID when reporting an issue.

string

Response status. SUCCESS on success.