Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Comprehensive error handling with automatic retry logic
try { await agent.sendMessage(session.id, 'Hello'); } catch (error) { if (error instanceof ValidationError) { console.log('Invalid parameters'); } else if (error instanceof AuthenticationError) { console.log('Invalid API key'); } else if (error instanceof RateLimitError) { console.log(`Retry after ${error.retryAfter}s`); } else if (error instanceof SessionError) { console.log('Session not found or expired'); } }
validation_error
invalid_token
session_not_found
context_overflow
rate_limit_exceeded
internal_error
const agent = new SynthraAgent({ apiKey: process.env.SYNTHRA_API_KEY, retryConfig: { maxRetries: 3, initialDelay: 1000, backoffMultiplier: 2 } });
console.log(error.code); // Error code console.log(error.message); // Human-readable message console.log(error.statusCode); // HTTP status console.log(error.requestId); // Request ID for support
async function sendWithRecovery(sessionId, message, userId) { try { return await agent.sendMessage(sessionId, message); } catch (error) { if (error instanceof SessionError) { const newSession = agent.createSession(userId); return await agent.sendMessage(newSession.id, message); } throw error; } }
requestId