Agent Class

The main class for creating AI streaming agents. Handles TTS, LLM, and streaming functionality.

new Agent(options) constructor
Creates a new AI agent instance with the specified configuration.
options.id
string
Unique identifier for the agent
options.persona
object
Agent personality configuration (name, bio, etc.)
options.defaults
object
Default settings for streaming (resolution, framerate)

Example

const agent = new Agent({ id: 'my-bot', persona: { name: 'AI Assistant', bio: 'Helpful AI agent' }, defaults: { resolution: '1920x1080', framerate: 30 } });
speak(text, options) async method
Converts text to speech using the configured TTS provider.
text
string
Text to convert to speech
options
object (optional)
TTS-specific options (voice, speed, etc.)

Example

const audioPath = await agent.speak('Hello, world!'); console.log('Audio generated:', audioPath);
think(prompt, options) async method
Generates an AI response using the configured LLM provider.
prompt
string
Input prompt for the AI
options
object (optional)
LLM generation options (maxTokens, temperature)

Example

const response = await agent.think('What should I talk about today?', { maxTokens: 150, temperature: 0.7 }); console.log('AI response:', response);
startStream(options) async method
Starts streaming audio and video to an RTMP endpoint.
options.imagePath
string
Path to the image file to display
options.text
string
Text to convert to speech and stream
options.rtmpUrl
string
RTMP streaming endpoint URL

Example

const ffmpegProcess = await agent.startStream({ imagePath: '/path/to/image.png', text: 'Welcome to my stream!', rtmpUrl: 'rtmp://live.twitch.tv/app/YOUR_KEY' });
startAIStream(options) async method
Starts AI-powered streaming with generated content.
options.imagePath
string
Path to the image file to display
options.prompt
string
AI prompt for content generation
options.rtmpUrl
string
RTMP streaming endpoint URL
options.llmOptions
object (optional)
LLM generation options

Example

await agent.startAIStream({ imagePath: '/path/to/image.png', prompt: 'Give a 30-second introduction about AI', rtmpUrl: 'rtmp://live.twitch.tv/app/YOUR_KEY', llmOptions: { maxTokens: 200, temperature: 0.8 } });

TTS Adapters

Text-to-Speech adapters for different voice providers.

ElevenLabs TTS adapter
High-quality AI voice synthesis using ElevenLabs API.

Setup

export ELEVENLABS_API_KEY="sk-your-key-here" export ELEVENLABS_VOICE_ID="alloy" # optional export TTS_PROVIDER="elevenlabs"
OpenAI TTS adapter
Text-to-speech using OpenAI's TTS API.

Setup

export OPENAI_API_KEY="sk-your-key-here" export OPENAI_MODEL="tts-1" # or tts-1-hd export TTS_PROVIDER="openai"

LLM Adapters

Large Language Model adapters for AI intelligence.

OpenAI LLM adapter
AI intelligence using OpenAI's GPT models.

Setup

export OPENAI_API_KEY="sk-your-key-here" export LLM_PROVIDER="openai"
Claude LLM adapter
AI intelligence using Anthropic's Claude models.

Setup

export ANTHROPIC_API_KEY="sk-ant-your-key-here" export LLM_PROVIDER="claude"