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.
Endpoint
POST
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemasReplace {WorkspaceId} with your actual workspace ID.
Request body
namestringRequiredProfile schema name, up to 32 characters
descriptionstringOptionalProfile schema description
plan_versionstringOptionalBilling plan: pro or lite
extract_scenestringOptionalExtraction mode: efficient or intelligent; defaults to efficient
attributesarrayRequiredProfile attribute definitions; the array cannot be empty
attributes[].namestringRequiredAttribute name
attributes[].descriptionstringOptionalAttribute description
memory_library_idstringOptionalMemory library ID. If omitted, the default memory library is used
Request 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?