Skip to main content
Install and configure Synthra to build your first conversational AI agent.

Installation

npm install @synthra/agent

Initialize the Agent

import { SynthraAgent } from '@synthra/agent';

const agent = new SynthraAgent({
  apiKey: process.env.SYNTHRA_API_KEY,
  endpoint: 'https://api.synthra.ai',
  timeout: 10000
});

Create a Session

const session = agent.createSession('user_abc123def456');

console.log(`Session created: ${session.id}`);
// Output: Session created: session_9f8e7d6c5b4a

Send Your First Message

const response = await agent.sendMessage(
  session.id,
  'Hello, Synthra! What can you help me with?'
);

console.log(response.content);
// Output: Hello! I'm Synthra, your AI assistant...

Configuration Options

const agent = new SynthraAgent({
  apiKey: process.env.SYNTHRA_API_KEY,
  endpoint: 'https://api.synthra.ai',
  timeout: 10000,
  retryAttempts: 3,
  contextConfig: {
    maxTokens: 8192,
    compressionEnabled: true,
    retentionPolicy: 'semantic'
  },
  rateLimits: {
    requestsPerMinute: 100,
    tokensPerMinute: 50000
  }
});

Complete Example

import { SynthraAgent } from '@synthra/agent';

async function main() {
  // Initialize agent
  const agent = new SynthraAgent({
    apiKey: process.env.SYNTHRA_API_KEY
  });

  // Create session
  const session = agent.createSession('user_abc123def456');

  // Send messages
  const response1 = await agent.sendMessage(
    session.id,
    'What is the current price of SOL?'
  );
  console.log(response1.content);

  const response2 = await agent.sendMessage(
    session.id,
    'How has it changed in the last 24 hours?'
  );
  console.log(response2.content);

  // Get session history
  const history = await agent.getHistory(session.id);
  console.log(`Total messages: ${history.length}`);

  // Clean up
  await agent.deleteSession(session.id);
}

main().catch(console.error);

Next Steps

Session Management

Learn about session lifecycle and configuration

Context Compression

Understand context window management

Solana Integration

Integrate blockchain capabilities

API Reference

Explore the complete API
API keys can be generated from the Developer Dashboard. Store keys securely and never expose them in client-side code.