Skip to main content
Knowledge base

AddChunk

Adds chunks to a document search (document), data query (table), or image Q&A (image) knowledge base.

Operation description

  • This operation adds chunk content to a specified knowledge base of the document search (document), data query (table), or image Q&A (image) type. Related operations on multimedia search (multimedia) knowledge bases are not supported. For data query and image Q&A knowledge bases, this operation takes effect only when the data source is a spreadsheet connector (excel).
  • Resource Access Management (RAM) users must first obtain API permissions for Model Studio (requiring AliyunBailianDataFullAccess, which includes the sfm:ChunkList permission) and join a workspace before invoking this operation. Alibaba Cloud accounts can invoke this operation directly without authorization. Use the latest Model Studio SDKModel Studio SDK to invoke this operation.
  • Before invoking this operation, make sure that your knowledge base has been created and has not been deleted (that is, the knowledge base ID IndexId is valid).
  • This operation has idempotence.
Throttling: This operation is throttled if called too frequently. Do not exceed 10 calls per second. If throttled, retry later.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage. Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /{WorkspaceId}/chunk/create HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

WorkspaceId

string

Yes

The workspace ID.

llm-19hxxxxx7htdf9lh

Request parameters

Parameter

Type

Required

Description

Example

PipelineId

string

Yes

The knowledge base ID.

79c0alxxxx

dataId

string

No

The file ID.

doc_xxx

field

object

No

The chunk content to insert, passed as key-value pairs. For document search knowledge bases, use the following fixed key list:

  • content (String): Required. The body content of the chunk.

  • title (String): Optional. The title of the chunk.

  • image_urls (Array): Optional. Image URLs included in the chunk. A maximum of 10 images are supported.

For data query and image Q&A knowledge bases, the keys are not fixed and are determined by the data source spreadsheet of the knowledge base. The key is the Excel column header, and the value is the corresponding column value.

{ "content": "The Bailian platform supports parsing multiple document formats including PDF, Word, and PPT.", "title": "Document Parsing and Chunking", "image_urls": [ "https://example.com/images/chunk-flow.png", "https://example.com/images/parsing-result.png" ] }

any

No

The header field information for the inserted chunk. Only data query and image Q&A knowledge bases are supported. Headers that participate in retrieval or response generation are required. Value requirements for each type:

  • String: Maximum length of 6000.

  • Time: 13-digit timestamp (milliseconds).

  • Long: Integer. Maximum value: 2147483647.

  • Double: Decimal values are supported.

  • image_url: A maximum of 5 images. Concatenate multiple URLs into a single string separated by commas.

{"Product Name": "Wireless Bluetooth Headphones", "Publish Time": 1752624000000, "Stock Quantity": 1580, "Unit Price": 299.99, "image_url":"https://example.com/images/headphones-front.jpg,https://example.com/images/headphones-side.jpg,https://example.com/images/headphones-package.jpg" }

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID.

35A267BF-xxxx-54DB-8394-AA3B0742D833

Code

string

The error status code.

Index.InvalidParameter

Message

string

The error message.

Required parameter(%s) missing or invalid, please check the request parameters.

Success

boolean

Indicates whether the operation was successful.

Valid values:

  • true :

    true

  • false :

    false

true

Data

boolean

The business data returned upon a successful request.

Valid values:

  • true :

    true

  • false :

    false

true

Status

string

The status code returned by the operation.

200

Examples

Success response JSON format
{
  "RequestId": "35A267BF-xxxx-54DB-8394-AA3B0742D833",
  "Code": "Index.InvalidParameter",
  "Message": "Required parameter(%s) missing or invalid, please check the request parameters.",
  "Success": true,
  "Data": true,
  "Status": "200"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.