创建 Client

最近更新时间:2025-09-12 21:41:51

我的收藏
MemoryClient() 用于通过 HTTP I/O 请求方式创建一个 Memory 的客户端对象。
class MemoryClient:
def __init__(self,
endpoint: str,
api_key: str,
memory_id: str,
default_actor_id: Optional[str] = None,
timeout: int = 10,
stub: Optional[Stub] = None):
self.default_memory_id = memory_id
self.default_actor_id = default_actor_id
self.stub = stub or HttpStub(endpoint, api_key, memory_id, timeout)

使用示例

from tdaimemory import MemoryClient

EndPoint = "https://memory.tdai.tencentyun.com"
ApiKey = "***************************"
MemoryId = "tdai-mem-********"
client = MemoryClient(endpoint=EndPoint,
api_key=ApiKey,
memory_id=MemoryId,
default_actor_id="user-sdk-test")

参数名
参数含义
是否必须
获取方式
endpoint
客户端所需连接 Memory 服务端的访问地址。
登录 Memory 智能体控制台,在详情页面的 API 接入区域,可获取 DeepSearch 的访问地址与访问密钥。
api_key
客户端访问 Memory 服务端的 API 密钥,用于进行身份认证。
memory_id
Memory 服务端具有唯一标识的 ID。
登录 Memory 智能体控制台,在 Memory 的卡片上或详情页面,可复制 ID。
timeout
请求超时时间。
单位:秒。
默认值:10。
取值范围:大于等于0。若 timeout 设置为小于0或为 null,系统会自动赋值为默认值。