Quickstart
Get started with Agent History in 5 minutes. Create an agent, store memories, and search them.
1. Create an Agent
First, create an agent to get your API credentials. You can do this via the API or using tempo request.
import { AgentHistoryClient } from '@agenthistory/sdk'
// Create a client (no credentials needed for agent creation)
const client = new AgentHistoryClient({ mode: 'cloud' })
// Create a new agent
const agent = await client.createAgent({
name: 'MyAssistant',
mode: 'cloud',
tags: ['assistant', 'coding'],
})
// Save these credentials securely!
console.log('Agent Key:', agent.agentKey) // aht_live_...
console.log('Record ID:', agent.recordId) // rec_01jx8a7qz2...
console.log('Wallet:', agent.walletAddress) // 0x...Important: Save your agentKeysecurely. It's used to authenticate all future API calls.2. Store a Memory
Use the remember endpoint to store memories. Memories are automatically embedded for semantic search.
const client = new AgentHistoryClient({
agentKey: 'aht_live_...',
mode: 'cloud',
})
// Store a fact about user preferences
await client.remember(recordId, {
content: 'User prefers dark mode and concise responses',
type: 'fact',
})
// Store a relationship
await client.remember(recordId, {
content: 'John Smith is the user\'s manager. Prefers morning meetings.',
type: 'relationship',
path: 'relationships/john-smith',
})3. Search Memories
Use semantic search to find relevant memories based on natural language queries.
// Search for user preferences
const results = await client.recall(recordId, {
query: 'what are the user preferences?',
limit: 5,
})
for (const memory of results.memories) {
console.log(memory.summary) // "User prefers dark mode..."
console.log(memory.type) // "fact"
console.log(memory.similarity) // 0.92
}4. Get Full Context
Retrieve all memories organized by type to build full agent context.
// Get all memories organized by type
const context = await client.getContext(recordId)
console.log(context.identity) // Who the agent is
console.log(context.fact) // Known facts
console.log(context.relationship) // People and connections
console.log(context.episode) // Past events
console.log(context.skill) // How-to knowledgeNext Steps
- Learn about Memory Types and when to use each
- See the full API Reference
- Install the TypeScript SDK
- Set up Tempo Integration for payments