Skip to main content

Use the CLI

Manage long-term memory and user profiles from the terminal with the Bailian CLI.

The Bailian CLI provides commands to add and search memory, manage nodes and profile schemas, and export skill memories from the terminal or an Agent.
Memory CLI capabilities are currently available only to China site (aliyun.com) accounts.

Prerequisites

Every Memory command requires a workspace ID. Pass --workspace-id or set the following environment variables:
export DASHSCOPE_API_KEY='<your-api-key>'
export BAILIAN_WORKSPACE_ID='<your-workspace-id>'

Add, list, and search memory

bl memory add --user-id user1 --content "Prefers concise, technical answers" --output json
bl memory list --user-id user1 --output json
bl memory search --user-id user1 --query "answer style preference" --output json
add submits an async extraction task and waits up to 120 seconds by default. With --wait 0, it returns only the submission receipt. Extraction may continue after a timeout, so check the results before deciding whether to resubmit. The returned event_id identifies the event; use memory_node_id from list or search results to show, update, or delete a node. search searches fact memories (observation) by default. Pass --memory-types skill to search skill memories. Use --plan-version to choose pro or lite; --min-score works only with pro. See Billing for pricing differences. list queries the default rule only unless you pass --project-id for another rule.

Available commands

TaskCommandsNotes
Add and searchbl memory add / bl memory searchIdentify the memory owner with --user-id
Node managementbl memory list / bl memory node show / bl memory update / bl memory deletelist paginates by user and rule; the other commands use --node-id. update and delete do not accept --user-id
Profile schema managementbl memory profile create / bl memory profile list / bl memory profile show / bl memory profile update / bl memory profile deleteSchemas define attributes to extract and can be shared by multiple users
Read user profilesbl memory profile getRead extracted values with --schema-id and --user-id; first link the schema with add's --profile-schema
Export skill memorybl memory skill exportExport the skill body or JSON with --node-id; it is not installed into an Agent automatically
For the schema and profile workflow, see Use user profiles.
Deleting a node or schema requires --yes; preview the request with --dry-run first. Deleting a node does not clear user profiles. Deleting a shared schema makes profiles extracted under it unreachable for all users. Attribute deletion with profile update has no --yes confirmation, so check the schema and attribute IDs before applying it.
When upgrading from an older version, replace the memory library flag --memory-library-id with --library-id. See the 2.5.0 changelog for other migration changes. Append --help to any command for full parameter details. See the Memory command reference for flags and examples for all 13 commands.