from acontext import AcontextClient
client = AcontextClient(api_key='sk_project_token')
# Get messages from session
messages = client.sessions.get_messages(
session_id='session-uuid',
limit=50,
format='acontext',
time_desc=True
)
for message in messages.items:
print(f"{message.role}: {message.parts}"){
"code": 123,
"error": "<string>",
"msg": "<string>",
"data": {
"has_more": true,
"items": [
{
"created_at": "<string>",
"id": "<string>",
"meta": {},
"parent_id": "<string>",
"parts": [
{}
],
"role": "<string>",
"session_id": "<string>",
"session_task_process_status": "<string>",
"task_id": "<string>",
"updated_at": "<string>"
}
],
"next_cursor": "<string>",
"public_urls": {}
}
}Get messages from session. Default format is openai. Can convert to acontext (original), anthropic, or gemini format.
from acontext import AcontextClient
client = AcontextClient(api_key='sk_project_token')
# Get messages from session
messages = client.sessions.get_messages(
session_id='session-uuid',
limit=50,
format='acontext',
time_desc=True
)
for message in messages.items:
print(f"{message.role}: {message.parts}"){
"code": 123,
"error": "<string>",
"msg": "<string>",
"data": {
"has_more": true,
"items": [
{
"created_at": "<string>",
"id": "<string>",
"meta": {},
"parent_id": "<string>",
"parts": [
{}
],
"role": "<string>",
"session_id": "<string>",
"session_task_process_status": "<string>",
"task_id": "<string>",
"updated_at": "<string>"
}
],
"next_cursor": "<string>",
"public_urls": {}
}
}Project Bearer token (e.g., "Bearer sk-ac-xxxx")
Session ID
Limit of messages to return. Max 200. If limit is 0 or not provided, all messages will be returned.
WARNING!
Use limit only for read-only/display purposes (pagination, viewing). Do NOT use limit to truncate messages before sending to LLM as it may cause tool-call and tool-result unpairing issues. Instead, use the token_limit edit strategy in edit_strategies parameter to safely manage message context size.
Cursor for pagination. Use the cursor from the previous response to get the next page.
Whether to return asset public url, default is true
Format to convert messages to: acontext (original), openai (default), anthropic, gemini.
acontext, openai, anthropic, gemini Order by created_at descending if true, ascending if false (default false)
JSON array of edit strategies to apply before format conversion