AI Roundtable
Overview
AI Roundtable is a web application designed to explore how multi-model, structured disagreement can improve engineering decision-making. Instead of asking a single AI model for a confident, polished recommendation that hides tradeoffs, the application coordinates a live debate between three large language models (OpenAI, Gemini, and Anthropic) arguing from distinct perspectives.
By casting different models as representatives of competing priorities, such as speed (Optimist), practicality (Mentor), and governance (Bureaucrat), the application surfaces the tradeoffs, assumptions, and risks of a technical choice. Responses stream turn-by-turn via Server-Sent Events, and the resulting transcript can be compiled into a multi-voice audio recording and a symbolic AI-generated illustration.
This application was built using the structured AI-assisted development workflow designed to maintain consistency, safety, and codebase alignment. Furthermore, its serverless endpoints implement the security and reliability patterns detailed in the six rules for autonomous LLM guardrails, utilizing per-IP rate limiting, Cloudflare Turnstile bot defense, and strict input/output constraints.
Participants
Each of the three LLMs is assigned a configurable role:
- OpenAI (gpt-4.1-nano via the OpenAI SDK)
- Gemini (gemini-2.5-flash-lite via Google’s OpenAI-compatible endpoint)
- Anthropic (claude-haiku-4-5 via the native Anthropic SDK)
User Controls
- Conversation starter: Topic or opening statement that kicks off the debate (required)
- Role: One of ten archetypes per AI, including Optimist, Mentor, Bureaucrat, Skeptic, Stoic, and Philosopher, acting as a perspective filter for the model’s arguments
- Conversation length: 1 to 10 rounds (each round is one response from every participant)
- Generate audio: Produce a multi-voice WAV file after the debate
- Generate image: Produce an AI-generated illustration of the debate
System and User Prompts
Each LLM gets a system prompt that encodes its assigned role, instructing it to stay in character without announcing its name or role.
Managing multi-turn state across different providers can quickly get messy if you try to align assistant and user roles across different SDK schemas. Instead, AI Roundtable uses a static prompt context strategy. The debate history is concatenated into a single, structured plain-text string. On each turn, this history is injected into a simple, standardized user prompt template. This unified text block is then sent to each model along with its provider-specific system instructions. This simplifies memory management and ensures that all three models share the exact same view of the debate history.
Turn-by-Turn SSE Streaming
If the application waited for all three models to finish their arguments before returning results, the loading state would take 15 to 20 seconds.
Instead of waiting, a custom Next.js ReadableStream endpoint coordinates the debate turn-by-turn. As soon as a model completes its turn, the orchestrator streams that speaker’s text to the screen via Server-Sent Events (SSE). It then appends the turn text to the prompt history and immediately invokes the next model. This sequential streaming keeps the user engaged, as new contributions appear on the screen every few seconds.
Audio Generation: Concat without FFmpeg
To make the debate feel more real, the app can synthesize a multi-voice audio file of the conversation. Individual speech segments are synthesized per turn, then merged into one WAV file.
- Synthesis: Each turn uses Google Cloud Text-to-Speech (Neural2 voices) requesting LINEAR16 (PCM) audio, which returns the raw samples wrapped in a standard WAV container. Each role maps to a distinct neural voice (e.g., Optimist to
en-US-Neural2-E, Mentor toen-GB-Neural2-B). - Header Stripping: The 44-byte WAV header is sliced off from each synthesized segment (
buffer.subarray(44)) to isolate the raw PCM audio. - Concatenation: The raw PCM chunks are concatenated with an in-memory silence buffer (
Buffer.alloc(14400, 0)for a 0.3-second pause between turns). - RIFF/WAV Header Compiling: A custom 44-byte RIFF/WAV header is written from scratch by writing bytes directly to a new Node.js buffer and prepended to the combined PCM data.
Generating this in a serverless environment (like AWS Lambda) usually requires running an external ffmpeg binary to combine the audio files, which adds latency and bloats the deployment bundle. This pure-JS approach allows the app to stitch a multi-speaker audio file in milliseconds with zero external binaries.
Image Generation
After the debate, a symbolic illustration is generated from the conversation using Gemini (gemini-3.1-flash-image), from a structured prompt derived from the conversation text.
Technology
Next.js (App Router, React, TypeScript), Tailwind CSS, OpenAI SDK with provider base_url overrides for OpenAI and Gemini, native Anthropic SDK for Anthropic; Google Cloud Text-to-Speech for multi-voice audio; Gemini (gemini-3.1-flash-image) for debate imagery. Deployed on AWS Amplify.
Work covered multi-turn prompting and persona consistency, SSE streaming, Cloudflare Turnstile bot protection, structured CloudWatch logging with EMF, TTS segment assembly into WAV, and Gemini-native image generation from the transcript.