Authentication

Updated at:

API Key acquisition and usage

Memory API uses API Key authentication. Pass the key via the Authorization header.

Get credentials

  1. Open the console: Open the Bailian console and log in with your Alibaba Cloud account.

  2. Get API Key: Obtain DASHSCOPE_API_KEY from the console, starting with sk-. See Get API Key.

    WarningAPI keys have account-level permissions. Store them securely and never commit to code repositories.

  3. Get workspace ID: On the Workspace Management page, copy the value in the API Host column. The llm-xxxxxxxxxxxx part is your workspace ID. See Get the workspace-dedicated domain. Replace {WorkspaceId} in the request URL with this ID, and use an API key that belongs to the same workspace.

Usage

Configure as an environment variable:

export DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxx"

Each request carries the Authorization header:

curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/add' \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "user_id": "user_001",
    "custom_content": "The user prefers concise technical examples."
  }'

Permissions

  • Alibaba Cloud primary account: can call all endpoints directly
  • RAM sub-accounts: require appropriate permissions
  • API Key scope is configured in the console

Security best practices

  • Never in repos: use environment variables
  • Per-app keys: use separate keys for each app
  • Rotate regularly: change keys periodically

ImportantView AddMemory to start calling.