# 知识库管理接口

# POST /api/v1/knowledge-bases

功能: 创建知识库

请求参数:

{
    "name": "测试知识库_1772692357",
    "type": "document",
    "is_temporary": false,
    "description": "用于API测试的知识库",
    "tenant_id": 10001,
    "chunking_config": {
        "chunk_size": 512,
        "chunk_overlap": 100,
        "separators": ["\\n\\n","\\n","。","!","?",";",";"]
    }
}

响应示例:

{
    "data": {
        "id": "b38fc7f4-1fa3-4e9a-a2a4-9408f713a198",
        "name": "测试知识库_1772692357",
        "type": "document",
        "is_temporary": false,
        "description": "用于API测试的知识库",
        "tenant_id": 10001,
        "chunking_config": {
            "chunk_size": 512,
            "chunk_overlap": 100,
            "separators": ["\\n\\n","\\n","。","!","?",";",";"]
        },
        "image_processing_config": {
            "model_id": ""
        },
        "embedding_model_id": "model_id",
        "summary_model_id": "model_id",
        "vlm_config": {
            "enabled": false,
            "model_id": "",
            "model_name": "",
            "base_url": "",
            "api_key": "",
            "interface_type": ""
        },
        "cos_config": {
            "secret_id": "",
            "secret_key": "",
            "region": "",
            "bucket_name": "",
            "app_id": "",
            "path_prefix": "",
            "provider": ""
        },
        "extract_config": null,
        "faq_config": null,
        "question_generation_config": null,
        "created_at": "2026-03-05T14:32:37.990973279+08:00",
        "updated_at": "2026-03-05T14:32:37.99097341+08:00",
        "deleted_at": null,
        "knowledge_count": 0,
        "chunk_count": 0,
        "is_processing": false,
        "processing_count": 0,
        "share_count": 0
    },
    "success": true
}
# GET /api/v1/knowledge-bases

功能: 获取知识库列表

请求参数:

  • page: 页码,默认为1 (查询参数)
  • page_size: 每页数量,默认为20 (查询参数)
  • order_by: 排序字段,默认为created_at (查询参数)
  • order_direction: 排序方向,默认为desc (查询参数)

响应示例:

{
    "data": [],
    "success": true
}
# GET /api/v1/knowledge-bases/:id

功能: 获取知识库详情

请求参数:

  • id: 知识库ID (路径参数)

响应示例:

{
    "success": true,
    "data": {
        "id": "d648307d-ca53-4fb0-9761-5526c26f8dc3",
        "name": "测试知识库_1772267347",
        "type": "document",
        "is_temporary": false,
        "description": "用于API测试的知识库",
        "tenant_id": 10001,
        "chunking_config": {
            "chunk_size": 512,
            "chunk_overlap": 100,
            "separators": ["\\n\\n","\\n","。","!","?",";",";"]
        },
        "image_processing_config": {
            "model_id": ""
        },
        "embedding_model_id": "model_id",
        "summary_model_id": "model_id",
        "vlm_config": {
            "enabled": false,
            "model_id": "",
            "model_name": "",
            "base_url": "",
            "api_key": "",
            "interface_type": ""
        },
        "cos_config": {
            "secret_id": "",
            "secret_key": "",
            "region": "",
            "bucket_name": "",
            "app_id": "",
            "path_prefix": "",
            "provider": ""
        },
        "extract_config": null,
        "faq_config": null,
        "question_generation_config": null,
        "is_pinned": false,
        "created_at": "2026-02-28T16:29:08+08:00",
        "updated_at": "2026-02-28T16:29:08+08:00",
        "deleted_at": null,
        "knowledge_count": 11,
        "chunk_count": 0,
        "is_processing": false,
        "processing_count": 0,
        "share_count": 0
    }
}
# GET /api/v1/knowledge-bases/counts

功能: 获取知识库统计信息

请求参数: 无

响应示例:

{
    "success": true,
    "data": {
        "knowledge_base_count": 4,
        "knowledge_count": 2
    }
}

响应格式说明:

字段名 类型 说明
success boolean 请求是否成功
data object 统计数据
data.knowledge_base_count integer 知识库总数
data.knowledge_count integer 知识文件总数
# PUT /api/v1/knowledge-bases/:id

功能: 更新知识库

请求参数:

  • id: 知识库ID (路径参数)

请求体参数:

{
    "name": "更新后的知识库名称",
    "description": "更新后的描述信息",
    "config": { //这里参考创建知识库时的参数
      "chunking_config": {
          "chunk_size": 1024,
          "chunk_overlap": 200
      }
    }
}

响应示例:

{
    "success": true,
    "data": {
        "id": "knowledge_base_id_1",
        "name": "更新后的知识库名称",
        "description": "更新后的描述信息",
        "updated_at": "2026-03-02T13:15:00+08:00"
    }
}
# DELETE /api/v1/knowledge-bases/:id

功能: 删除知识库

请求参数:

  • id: 知识库ID (路径参数)

响应示例:

{
    "message": "Knowledge base deleted successfully",
    "success": true
}
# PUT /api/v1/knowledge-bases/:id/pin

功能: 置顶/取消置顶知识库

请求参数:

  • id: 知识库ID (路径参数)

响应示例:

{
    "success": true,
    "data": {
        "id": "knowledge_base_id_1",
        "name": "知识库名称",
        "description": "知识库描述",
        "is_pinned": true,
        "pinned_at": "2026-03-10T16:00:00+08:00",
        "updated_at": "2026-03-10T16:00:00+08:00"
    }
}

参数说明:

参数名 类型 必填 说明
id string 知识库ID (路径参数)

响应格式说明:

字段名 类型 说明
id string 知识库ID
name string 知识库名称
description string 知识库描述
is_pinned boolean 是否置顶
pinned_at string 置顶时间
updated_at string 更新时间
data.updated_at string 更新时间