Skip to main content

Chat History

Manage and retrieve conversation history for context-aware interactions.

Method

Chat Message Format

Properties

string
required
The role of the message sender: user, assistant, or system
string
required
The text content of the message
Date
When the message was created (auto-generated if not provided)
Record<string, any>
Additional metadata associated with the message

Examples

Context Management

Automatic Context

When using chat.send() or chat.stream(), you can include context automatically:

Selective Context

Include only relevant parts of the conversation:

Context Summarization

For long conversations, summarize older messages:

History Export/Import

Export History

Import History

Best Practices

Memory Management

Privacy and Security

Error Handling