Prerequisites
Before storing messages, you need:- A running Acontext server (run locally)
- An Acontext API key (default is
sk-ac-your-root-api-bearer-token)
Messages are stored within sessions. Create a session first, then store messages to it.
Storing messages
Create a session first
Before storing messages, create a session:Store a single message
Store messages in OpenAI, Anthropic, or Gemini format:- OpenAI Format
- Anthropic Format
- Gemini Format
Store multiple messages
You can store multiple messages sequentially to build a conversation:Each message receives a unique ID upon creation. You can use these IDs to reference specific messages later.
Retrieving messages
Get all messages from a session
Retrieve messages from a session:Session observability
Acontext provides built-in observability features to help you monitor and analyze your message sessions in real-time.
Message Observing Status
Monitor the processing status of messages in your session: observed, in_process, and pending counts.
Session Tasks
View all tasks and agent operations associated with a session for debugging and analysis.
Dashboard Visualization
Access the Acontext dashboard to visualize message flows, traces, and session analytics.
Disable Task Tracking
Disable automatic task tracking for sessions that don’t need task analysis or monitoring.
Message format compatibility
Acontext supports three message formats for maximum compatibility:OpenAI Format
Compatible with OpenAI’s Chat Completion API format. Use for GPT-3.5, GPT-4, and similar models.
Anthropic Format
Compatible with Anthropic’s Messages API format. Use for Claude models.
Gemini Format
Compatible with Google’s Gemini API format. Use for Gemini Pro, Gemini Flash, and other Gemini models.
Complete workflow example
Here’s a complete example showing how to store and retrieve a conversation:Managing sessions
Delete a session
When you’re done with a conversation or workflow, you can delete the session to clean up storage:List and clean up old sessions
You can list sessions and delete the ones you no longer need:Best practices
Organize messages with sessions
Organize messages with sessions
- Use sessions to group related messages (e.g., one conversation, one task)
- Create a new session for each distinct conversation or workflow
Choose the right message format
Choose the right message format
- Use OpenAI format if you’re working with OpenAI models or want broad compatibility
- Use Anthropic format if you’re primarily using Claude models
- Use Gemini format if you’re working with Google Gemini models (Gemini Pro, Gemini Flash, etc.)
- You can convert between formats when retrieving messages
Monitor session health and performance
Monitor session health and performance
- Use message observing status to track message processing states in real-time
- Monitor token counts to stay within context limits and manage API costs
- Review session tasks to understand agent behavior and debug issues
- Leverage the dashboard for visual insights into message flows and patterns