创建知识库

通过 OpenAPI 创建通义灵码知识库。

适用版本

企业专属版、企业标准版

服务接入点

获取服务接入点,替换 API 请求语法中的 {domain}

授权信息

产品

资源

所需权限

通义灵码

知识库

读写

请求语法

POST https://{domain}/oapi/v1/lingma/organizations/{organizationId}/knowledgeBases

请求说明

企业标准版

创建知识库

curl -X 'POST' \
  'https://openapi-rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "accessLevel": 0,
        "creatorId": "66a6f60e368d88cff5a5****",
        "description": "this is a kb",
        "name": "灵码知识库",
        "organizationId": "6826e1d0516a9f85a08c****",
        "sceneType": "answer"
    }'

企业专属版

创建知识库

curl -X 'POST' \
  'https://test-domain-***.rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "accessLevel": 0,
        "creatorId": "66a6f60e368d88cff5a5****",
        "description": "this is a kb",
        "name": "灵码知识库",
        "organizationId": "6826e1d0516a9f85a08c****",
        "sceneType": "answer"
    }'

请求头(Headers)

x-yunxiao-token string (必选)

个人访问令牌。您可参考个人访问令牌获取。

示例:pt-0fh3****0fbG_35af****0484。

请求参数

organizationId string (必选)

所属组织ID。您可以前往组织管理后台基本信息页面获取organizationId

name string (必选)

知识库名称,长度小于100。

sceneType string (必选)

知识库场景类型目前包含以下两种:

  • chat:智能问答场景。

  • complement:行间生成场景。

accessLevel integer (必选)

知识库可见性,目前包含以下两种:

  • 0:私有知识库。

  • 10:公开知识库。

creatorId string (必选)

知识库创建者 ID。请参见查询成员列表获取知识库创建者 ID。

organizationId string (必选)

知识库所属组织 id。您可以前往组织管理后台基本信息页面获取organizationId

description string (可选)

知识库描述,长度小于200。

返回参数

返回示例

{
    "kbId": "b15aef8442c0fc45492b****"
}

kbId string

知识库 ID。

错误码

访问错误码中心查看 API 相关错误码。