更新时间:2026-06-10 GMT+08:00
分享

创建Space - CreateCoreSpace

功能介绍

创建新的记忆空间,用于存放某一类业务的短长期记忆数据,包括访问方式、抽取策略、密钥绑定等相关配置。

调用方法

请参见如何调用API

URI

POST /v1/core/spaces

请求参数

表1 请求Body参数

参数

是否必选

参数类型

描述

name

String

参数解释:

空间名称。

约束限制:

仅支持字母、数字和中划线。

取值范围:

长度1-48字符。

默认取值:

不涉及。

description

String

参数解释:

空间描述。

约束限制:

不涉及。

取值范围:

不超过1000个字符。

默认取值:

不涉及。

api_key_id

String

参数解释:

空间访问Key。

约束限制:

不涉及。

取值范围:

由英文字母、数字、"-"组成的字符串。

默认取值:

不涉及。

message_ttl_hours

Integer

参数解释:

过期时间(小时)。

约束限制:

不涉及。

取值范围:

1-8760 h。

默认取值:

168。

memory_extract_idle_seconds

Integer

参数解释:

触发记忆抽取的空闲时间(秒

约束限制:

不涉及。

取值范围:

10-86400 s。

默认取值:

不涉及。

memory_extract_max_tokens

Integer

参数解释:

触发记忆抽取最大累计token数。

约束限制:

不涉及。

取值范围:

1000-1073741824 tokens。

默认取值:

不涉及。

memory_extract_max_messages

Integer

参数解释:

触发记忆抽取最大累计message数。

约束限制:

不涉及。

取值范围:

3-10000 条。

默认取值:

不涉及。

tags

Array of CoreSpaceTag objects

参数解释:

库标签列表。

约束限制:

数组长度0-20个;键最大长度36字符,不允许为空;值最大长度43字符,可以为空。

取值范围:

不涉及。

默认取值:

不涉及。

memory_strategies_builtin

Array of strings

参数解释:

内置策略类型列表,与memory_strategies_customized至少选填一项。

约束限制:

数组长度0-10个。

取值范围:

不涉及。

默认取值:

不涉及。

memory_strategies_customized

Array of CreateCoreSpaceMemoryStrategyRequestBody objects

参数解释:

长期记忆自定义策略。

约束限制:

与memory_strategies_builtin至少选填一项;单个记忆空间最多配置10个。

取值范围:

不涉及。

默认取值:

不涉及。

network_access

CreateCoreSpaceNetworkRequestBody object

参数解释:

Space 网络访问配置,公网和私网至少填写一个。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

表2 CoreSpaceTag

参数

是否必选

参数类型

描述

key

String

参数解释:

标签key。

取值范围:

不涉及。

value

String

参数解释:

标签value。

取值范围:

不涉及。

表3 CreateCoreSpaceMemoryStrategyRequestBody

参数

是否必选

参数类型

描述

name

String

参数解释:

策略名。

约束限制:

仅支持字母、数字和中划线。

取值范围:

长度1-48字符。

默认取值:

不涉及。

type

String

参数解释:

策略类型,决定记忆的存储和使用方式。

约束限制:

不涉及。

取值范围:

semantic: 语义记忆

summary: 摘要记忆

user_preference: 用户偏好

episodic: 情景记忆

默认取值:

不涉及。

steps

Array of CoreSpaceMemoryStrategyStepRequestBody objects

参数解释:

策略步骤列表,按 step_order 顺序执行。

约束限制:

数组长度0-20个。

取值范围:

不涉及。

默认取值:

不涉及。

表4 CoreSpaceMemoryStrategyStepRequestBody

参数

是否必选

参数类型

描述

step_order

Integer

参数解释:

步骤执行顺序,从 1 开始。

约束限制:

不涉及。

取值范围:

1-20

默认取值:

不涉及。

instruction

String

参数解释:

步骤指令(Prompt 模板)。

约束限制:

长度不超过50000字符。

取值范围:

长度0-50000字符。

默认取值:

不传使用默认模板。

表5 CreateCoreSpaceNetworkRequestBody

参数

是否必选

参数类型

描述

public_access_enable

Boolean

参数解释:

是否开启公网访问。

约束限制:

不涉及。

取值范围:

  • true: 开启公网访问

  • false: 关闭公网访问

默认取值:

false

private_access_config

CoreSpacePrivateNetworkRequestBody object

参数解释:

内网访问配置,传入此对象表示开启内网访问。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

表6 CoreSpacePrivateNetworkRequestBody

参数

是否必选

参数类型

描述

enable

Boolean

参数解释:

是否开启内网访问。

取值范围:

  • true: 开启内网访问

  • false: 关闭内网访问

vpc_id

String

参数解释:

租户 VPC ID,获取方式:查询VPC列表

取值范围:

不涉及。

subnet_id

String

参数解释:

租户子网 ID,获取方式:查询子网列表

取值范围:

不涉及。

响应参数

状态码:201

Space创建成功

状态码:400

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码,标识错误类型,格式为 AgentArts.XXXXXXXX。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息,描述错误详情,供问题排查使用。

取值范围:

不涉及。

状态码:401

表8 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码,标识错误类型,格式为 AgentArts.XXXXXXXX。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息,描述错误详情,供问题排查使用。

取值范围:

不涉及。

状态码:403

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码,标识错误类型,格式为 AgentArts.XXXXXXXX。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息,描述错误详情,供问题排查使用。

取值范围:

不涉及。

encoded_authorization_message

String

参数解释:

编码后的授权失败信息。

取值范围:

不涉及。

details

Array of CoreSpaceCommonError objects

参数解释:

依赖的下游服务错误信息列表,包含导致当前请求失败的下游服务错误详情。

取值范围:

不涉及。

表10 CoreSpaceCommonError

参数

参数类型

描述

error_code

String

参数解释:

错误码,标识错误类型,格式为 AgentArts.XXXXXXXX。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息,描述错误详情,供问题排查使用。

取值范围:

不涉及。

状态码:429

表11 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码,标识错误类型,格式为 AgentArts.XXXXXXXX。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息,描述错误详情,供问题排查使用。

取值范围:

不涉及。

状态码:500

表12 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码,标识错误类型,格式为 AgentArts.XXXXXXXX。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息,描述错误详情,供问题排查使用。

取值范围:

不涉及。

请求示例

/v1/core/spaces

{
  "name" : "space-01",
  "message_ttl_hours" : 168,
  "api_key_id" : "8ed3e306-0211-4e4d-af24-a9931b0e11d5",
  "description" : "test-environment",
  "memory_extract_idle_seconds" : 60,
  "memory_extract_max_tokens" : 10000,
  "memory_extract_max_messages" : 100,
  "tags" : [ {
    "key" : "Environment",
    "value" : "production"
  } ],
  "memory_strategies_builtin" : [ "semantic", "user_preference" ],
  "memory_strategies_customized" : [ {
    "name" : "summary-memory",
    "type" : "summary",
    "steps" : [ ]
  } ],
  "network_access" : {
    "public_access_enable" : true,
    "private_access_config" : {
      "enable" : true,
      "vpc_id" : "32176dd1-a44a-4c40-99de-5f4359b46d93",
      "subnet_id" : "5d1c6d00-cfbe-42b9-8c9d-1e2c2cea7e19"
    }
  }
}

响应示例

状态码:201

Space创建成功

{
  "id" : "123e4567-e89b-12d3-a456-426614174000",
  "name" : "space-01",
  "description" : "test-environment",
  "message_ttl_hours" : 168,
  "memory_extract_enabled" : true,
  "memory_extract_idle_seconds" : 60,
  "memory_extract_max_tokens" : 10000,
  "memory_extract_max_messages" : 100,
  "memory_strategies_builtin" : [ {
    "name" : "semantic-memory",
    "type" : "semantic",
    "steps" : [ {
      "step_order" : 1,
      "step_type" : "extraction",
      "isolation_level" : null,
      "instruction" : "You are a long-term memory extraction agent supporting a lifelong learning system. Your task is to identify and extract meaningful information about the users from a given list of messages. ...(truncated)",
      "output_schema" : "<schema>{...SemanticMemory schema...}</schema>\n<conversation>\n{messages}\n</conversation>"
    }, {
      "step_order" : 2,
      "step_type" : "consolidation",
      "isolation_level" : "actor",
      "instruction" : "You are a conservative memory manager that preserves existing information while carefully integrating new facts. Operations: AddMemory, UpdateMemory, SkipMemory. ...(truncated)",
      "output_schema" : "<new_content>\n{new_content}\n</new_content>\n<existing_memories>\n{historical_memories}\n</existing_memories>"
    } ]
  } ],
  "memory_strategies_customized" : [ {
    "id" : "456e7890-e89b-12d3-a456-426614174000",
    "name" : "user-preference-strategy",
    "type" : "user_preference",
    "origin_type" : "user",
    "steps" : [ {
      "id" : "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "step_order" : 1,
      "step_type" : "extraction",
      "isolation_level" : "actor",
      "instruction" : "string",
      "output_schema" : "string",
      "enabled" : true,
      "created_at" : "2025-01-18T10:00:00.000Z",
      "updated_at" : "2025-01-18T10:00:00.000Z"
    } ],
    "created_at" : "2025-01-18T10:00:00.000Z",
    "updated_at" : "2025-01-18T10:00:00.000Z"
  } ],
  "vpc_id" : "string",
  "subnet_id" : "string",
  "private_access" : {
    "domain_name" : "123e4567-e89b-12d3-a456-426614174000.cn-north-4.memory.agentarts.myhuawei.com",
    "ip" : "120.46.xxx.xxx"
  },
  "public_access" : {
    "domain_name" : "123e4567-e89b-12d3-a456-426614174000.cn-north-4.memory.agentarts.myhuawei.com",
    "ip" : "120.46.xxx.xxx"
  },
  "api_key" : {
    "id" : "key-uuid",
    "masked_key" : "sk-***1234"
  },
  "tags" : [ {
    "key" : "Environment",
    "value" : "production"
  } ],
  "status" : "creating",
  "created_at" : "2025-01-18T10:00:00.000Z",
  "updated_at" : "2025-01-18T10:00:00.000Z"
}

状态码:400

请求参数错误

{
  "error_code" : "AgentArts.01010001",
  "error_msg" : "Invalid request parameter format"
}

状态码:401

认证失败

{
  "error_code" : "AgentArts.01020002",
  "error_msg" : "Authentication failed"
}

状态码:403

权限不足

{
  "error_code" : "AgentArts.01010002",
  "error_msg" : "Insufficient permissions"
}

状态码:429

请求过于频繁

{
  "error_code" : "AgentArts.01020008",
  "error_msg" : "Too many requests"
}

状态码:500

内部服务错误

{
  "error_code" : "AgentArts.01010008",
  "error_msg" : "Internal service error"
}

状态码

状态码

描述

201

Space创建成功

400

请求参数错误

401

认证失败

403

权限不足

429

请求过于频繁

500

内部服务错误

错误码

请参见错误码

相关文档