Create Profile Schema
Updated at:
Create a user profile schema and define profile fields
Creates a user profile schema, defining the fields and descriptions included in the profile.
Method and endpoint
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas
Replace {WorkspaceId} with your actual workspace ID.
Request parameters
| Parameter | Type | Required | Location | Description |
|---|---|---|---|---|
name | string | Yes | Body | Profile schema name, up to 32 characters |
description | string | No | Body | Profile schema description |
plan_version | string | No | Body | Billing plan: pro or lite |
extract_scene | string | No | Body | Extraction mode: efficient or intelligent; defaults to efficient |
attributes | array | Yes | Body | Profile attribute definitions; the array cannot be empty |
attributes[].name | string | Yes | Body | Attribute name |
attributes[].description | string | No | Body | Attribute description |
memory_library_id | string | No | Body | Memory library ID. If omitted, the default memory library is used |
Code examples
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"name": "Basic user profile",
"description": "User information including age and interests",
"extract_scene": "efficient",
"attributes": [
{"name": "Age", "description": "User age"},
{"name": "Hobbies", "description": "User interests and hobbies"},
{"name": "Occupation", "description": "User occupation"}
]
}'
from agentscope_runtime.tools.modelstudio_memory import (
CreateProfileSchema, CreateProfileSchemaInput, ProfileAttribute,
)
import asyncio
async def main():
create_schema = CreateProfileSchema()
try:
result = await create_schema.arun(CreateProfileSchemaInput(
name="Basic user profile",
description="User information including age and interests",
attributes=[
ProfileAttribute(name="Age", description="User age"),
ProfileAttribute(name="Hobbies", description="User interests and hobbies"),
ProfileAttribute(name="Occupation", description="User occupation"),
]
))
print(f"Schema ID: {result.profile_schema_id}")
finally:
await create_schema.close()
asyncio.run(main())
Response example
{
"profile_schema_id": "50edf54eaa5842e891d959ae115205be",
"request_id": "f190a540-814e-9c1c-873e-0661851c8fca"
}
ImportantAfter creation, pass profile_schema via AddMemory to extract the profile, then use GetUserProfile to retrieve it.
Is this page helpful?