Skip to main content
切片管理

新增切片

向指定知识库添加切片内容

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"
}
支持文档搜索类(document)、数据查询类(table)、图片问答类(image)知识库;不支持音视频搜索类(multimedia)。数据查询和图片问答类知识库仅支持表格连接器(Excel)数据源。本接口具有幂等性,频繁调用会被限流,频率请勿超过 10 次/秒。

Authorizations

string
header
required

DashScope API Key,在控制台 API Key 页面(https://bailian.console.aliyun.com/settings/apikey)获取。

Body

application/json
string
required

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

object
required

切片内容信息,以键值对形式传入。结构因知识库类型而异,详见下方说明。

文档搜索类(document) 使用固定 key:

  • content(String,必填):切片正文内容,最大长度 6000
  • title(String,选填):切片标题,最大长度 50
  • image_urls(Array,选填):切片包含的图片链接,最多 10 张

数据查询类(table)、图片问答类(image) key 不固定,由知识库的数据源表格决定,key 为 Excel 列标题,value 为对应列的值。参与检索或回复的表头为必填。各类型取值要求:

  • String 类型:最大长度 6000
  • 时间类型:13 位时间戳(毫秒)
  • Long 类型:整数,最大 2147483647
  • Double 类型:支持小数
  • image_url 类型:最多 5 张,多张用英文逗号拼接为一个字符串
string

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

Response

200-application/json
string

响应码,成功时为 Success

integer

HTTP 状态码。

boolean

接口调用是否成功。

string

响应消息,成功时为 success

string

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

string

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

Managed Agent API
RAG API
Connector API
Memory API
框架集成
  • 框架