Skip to content

创建知识库 ​

接口说明 ​

创建知识库,并返回后续上传、已上传文件状态、可读取文件和删除接口使用的 knowledgeBaseId。

接口信息 ​

字段值
方法POST
路径/openapi/v2/knowledge-bases
Operation IDcreateKnowledgeBase
鉴权Bearer OpenAPI key

入参 ​

这个接口没有路径参数或查询参数。

请求体 ​

application/json ​

字段必填类型示例说明
name是stringProduct Docs资源名称,最多 255 个 UTF-8 字节。
description否string | nullProduct documentation可选描述,最多 16384 个 UTF-8 字节。

请求示例 ​

bash
curl -X POST "https://openapi.example.com/openapi/v2/knowledge-bases" \
  -H "Authorization: Bearer <openapi-key>" \
  -H "Content-Type: application/json" \
  --data '{
  "name": "Product Docs",
  "description": "Product documentation"
}'

成功响应 ​

201 ​

返回刚刚创建的知识库。

字段必填类型说明
knowledgeBase是object知识库记录。

成功响应示例 ​

json
{
  "knowledgeBase": {
    "knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
    "name": "Product Docs",
    "description": "Product documentation",
    "activeContentRevision": 0,
    "resourceRevision": 1,
    "createdAt": "2026-06-17T00:00:00.000Z",
    "updatedAt": "2026-06-17T00:00:00.000Z"
  }
}

错误码 ​

下表列出这个接口已声明的全部错误响应。

HTTP 状态错误码说明
401UNAUTHORIZEDBearer API key 缺失、格式错误、未知、已撤销或已删除。
413PAYLOAD_TOO_LARGE请求体或待读取文件超过当前接口允许的大小。
422VALIDATION_ERROR请求未通过校验。
429RATE_LIMITED请求超过当前配置的速率限制。
500INTERNAL_ERRORAPI 遇到内部错误。
503DATABASE_REPOSITORY_UNAVAILABLE当前接口所需的数据暂时不可用。

后续操作 ​