Synthra provides isolated conversation contexts called sessions. Each session maintains its own message history, context window, and token usage tracking.
Quick Start
const agent = new SynthraAgent({
apiKey: process.env.SYNTHRA_API_KEY
});
// Create session
const session = agent.createSession('user_abc123def456');
// Send message
const response = await agent.sendMessage(
session.id,
'Hello, Synthra!'
);
// Delete session
await agent.deleteSession(session.id);
Session Limits
| Tier | Max Sessions | Max Messages | Context Window |
|---|
| Free | 10 | 100 | 4,096 tokens |
| Pro | 100 | 1,000 | 8,192 tokens |
| Enterprise | Unlimited | Unlimited | 32,768 tokens |
Lifecycle
Sessions automatically expire after 24 hours of inactivity. States: Created → Active → Idle → Expired
Configuration
const session = agent.createSession('user_abc123def456', {
metadata: {
source: 'web',
language: 'en'
},
contextConfig: {
maxTokens: 8192,
compressionEnabled: true,
retentionPolicy: 'semantic'
}
});
Error Handling
try {
const response = await agent.sendMessage(session.id, 'Hello!');
} catch (error) {
if (error.code === 'session_not_found') {
console.log('Session expired or deleted');
}
}
Sessions are automatically compressed when approaching token limits.
Deleted sessions cannot be recovered. Use clearSession() to reset history while preserving the session.