Two AIs. One topic. A video in minutes.
Debatr (the AI Debates studio) is a full-stack service that orchestrates structured debates between AI personas and turns them into content. Powered by OpenRouter, it lets you pit hundreds of LLMs against each other with custom roles, personalities and stances, watch the debate stream live, get a judge's verdict, and render a 16:9 YouTube video plus a 9:16 Short right in the browser.
Users sign up, receive welcome credits, buy more with Stripe, keep a library of their debates and can publish them to a public gallery with share links.
π Live Demo Version is Coming Soon!
- π§ 4-step wizard: topic β speakers (model, neural voice, persona per speaker) β voice engine, outputs and quality β review with a cost/length estimate.
- βοΈ LLM vs LLM: Mix and match models. Have Claude debate GPT on philosophy while Gemini moderates.
- β‘ Real-time streaming: watch the debate generate token-by-token, stop it at any moment.
- βοΈ Structured verdict: the judge names a winner (or a draw), with per-debater feedback shown in the UI and on the video end card.
- ποΈ Neural voices: ElevenLabs (premium, emotion tags) or free Edge voices with word timestamps, mixed MP3 and karaoke transcript.
- π¬ Video in the browser: 16:9 episode and 9:16 Shorts (LLM-picked highlights with a hook) rendered with Remotion and WebCodecs β no server encoding.
- π€ Accounts & credits: email sign-up with welcome credits, Stripe top-ups, a ledger of every charge, an optional personal OpenRouter key that bypasses credits.
- π Library & gallery: drafts, filters, search; publish finished debates with a share link (
/d/{slug}) and view counts. - π³ Dockerized: Postgres, Redis, API, workers and a Caddy-served frontend.
- Framework: FastAPI (Python 3.12+, managed with uv)
- Database: PostgreSQL (async SQLAlchemy 2 + Alembic migrations)
- Queue: Redis & RQ (Redis Queue) for reliable task orchestration
- AI Integration: OpenRouter API (streaming, token & cost accounting)
- Voices & media: ElevenLabs / edge-tts, ffmpeg mixing, timeline contract for the browser renderer
- Accounts & payments: session cookie login (bcrypt), encrypted personal keys (Fernet), Stripe Checkout + webhooks
- Quality: ruff, pyright, pytest
- Framework: React 19 + Vite 8 + TypeScript
- Styling: Tailwind CSS 4 with the Debatr design tokens (dark studio theme)
- State/Routing: React Router, Axios
- Streaming: Server-Sent Events (SSE)
- Video: Remotion Player +
@remotion/web-renderer(MP4 encoded in the visitor's browser)
- Containers: Docker Compose (Postgres, Redis, API, worker, Caddy)
- CI: GitHub Actions (lint, type-check, tests, build)
Follow these steps to get a copy up and running locally or on your server.
-
Clone the repository
git clone https://github.com/khoren93/ai-debates.git cd ai-debates -
Configure environment
cp .env.example .env
For local testing you only need to set
OPENROUTER_API_KEY. KeepDOMAIN_NAME=localhost. SetDEV_FAKE_PAYMENTS=trueto top up credits instantly without Stripe while developing. -
Run
docker compose up -d --build
Database migrations run automatically when the API container starts.
-
Open
- Frontend: http://localhost
- API docs: http://localhost/api/docs
- Admin panel: http://localhost/api/admin (
ADMIN_USER/ADMIN_PASSWORD)
Prerequisites: uv, Node.js 20.19+ and Docker.
# 1. Infrastructure only (Postgres on :5432, Redis on :6379)
docker compose -f docker-compose.dev.yml up -d
# 2. Backend API (http://localhost:8000/api/docs)
cd backend
uv sync
uv run alembic upgrade head
uv run uvicorn app.main:app --reload
# 3. Worker (second terminal). SimpleWorker avoids fork issues on macOS.
cd backend
RQ_SIMPLE_WORKER=true uv run python -m app.worker
# 4. Frontend (third terminal, http://localhost:5173 β proxies /api to the backend)
cd frontend
npm install
npm run devLeave DATABASE_URL and REDIS_URL unset in .env: the defaults point at localhost, and
docker compose injects the container addresses itself.
Checks
cd backend && uv run ruff check . && uv run pyright && uv run pytest
cd frontend && npm run check && npm run build- Point your domain (e.g.,
ai-debates.net) to your server IP in Cloudflare/DNS. - SSH into your server and install Docker:
curl -fsSL https://get.docker.com | sh - Clone and Setup:
git clone https://github.com/khoren93/ai-debates.git cd ai-debates cp .env.example .env - Edit
.env:- Set
DOMAIN_NAME=your-domain.com - Set
ACME_EMAIL=your@email.com(for SSL) - Set
OPENROUTER_API_KEY=... - Generate a strong
POSTGRES_PASSWORD.
- Set
- Start everything:
./deploy.sh
deploy.shpulls the latest code, rebuilds the containers (migrations run on start) and prunes old images. In production setENVIRONMENT=productionand replace every placeholder secret in.env(SECRET_KEY,ADMIN_PASSWORD,POSTGRES_PASSWORD).
- Open the web interface at
https://your-domain.com(orhttp://localhost) and create an account (new accounts receiveSIGNUP_BONUS_USDof credits). - Click "+ New debate" and walk through the wizard:
- Topic: type a question or pick one from the library, choose language, rounds and reply length.
- Speakers: a host plus two or more debaters, each with a model, a neural voice and a persona.
- Voice & format: spoken or written style, free Edge or premium ElevenLabs voices, which outputs to produce (audio, 16:9 video, 9:16 Short) and the render quality.
- Review: the estimate shows cost, length, turns and your credits after the run.
- Hit Start the debate and watch it stream live. When it finishes the verdict is scored and the audio track is built automatically; open the debate to render the MP4s in your browser.
- Share: publish the debate to the gallery and copy the share link.
- Account: top up credits (Stripe), see this month's usage, store a personal OpenRouter key so paid models run on your own account instead of credits.
- Every run charges the OpenRouter cost reported for the debate Γ
CREDIT_MARKUPonce it finishes. - Premium voices on the system ElevenLabs key cost
TTS_CREDIT_PRICE_PER_1K_CHARSper 1,000 characters. - Free models and free Edge voices cost nothing; a personal OpenRouter key makes model usage free.
- Top-ups go through Stripe Checkout (
STRIPE_SECRET_KEY, webhook/api/billing/webhookwith thecheckout.session.completedevent andSTRIPE_WEBHOOK_SECRET). Every movement is recorded in thecredit_transactionsledger and visible on the Account page and in the admin panel.
The system uses an event-driven architecture to handle long-running LLM generation tasks without blocking the UI.
- API Layer:
POST /api/debatesvalidates the configuration and saves the debate with statusqueued. A user-supplied OpenRouter key is kept only in Redis for the lifetime of the debate, never in the database. - Queue (RQ): A chain of jobs runs in the worker:
startβ one job per turn βverdictβfinish. - Scheduler: Every round starts with the moderator (introduction, then short transitions) followed by
each debater. Debater turns are typed
opening/rebuttal/closing; the moderator's model then delivers a structured verdict. - Worker: Builds role-specific prompts, streams the OpenRouter response, records token usage and cost per turn, and publishes events to Redis Pub/Sub. A debate can be stopped at any time from the UI.
- Frontend: Subscribes to
GET /api/debates/{id}/stream(SSE) and renders turns token-by-token. Finished debates are served straight from the database. - Verdict & billing: after the judge's turn a cheap model structures the verdict (winner, headline,
feedback). At the terminal state the worker charges the owner's credits and, if the wizard asked for
media, queues the audio build on the
mediaqueue. - Media: the media worker voices every turn (cached by content hash), mixes the track with ffmpeg,
picks highlights for Shorts and writes
timeline.json. The browser renders MP4s from that timeline. - Accounts: the login lives in the signed session cookie; personal OpenRouter keys are stored encrypted and only ever handed to the worker through Redis for the duration of a run.
Configuration (see .env.example): OPENROUTER_API_KEY, ELEVENLABS_API_KEY, ALLOWED_ORIGINS,
SIGNUP_BONUS_USD, CREDIT_MARKUP, TTS_CREDIT_PRICE_PER_1K_CHARS, TOPUP_AMOUNTS_USD,
STRIPE_SECRET_KEY / STRIPE_WEBHOOK_SECRET (or DEV_FAKE_PAYMENTS), DEBATE_CREATE_RATE_LIMIT,
LOGIN_RATE_LIMIT, TURN_JOB_TIMEOUT, MEDIA_JOB_TIMEOUT, ADMIN_USER / ADMIN_PASSWORD, SECRET_KEY.
- Voice Synthesis (TTS): Browser text-to-speech playback.
- Neural TTS: ElevenLabs / Edge voices with word timestamps, karaoke transcript and MP3 export.
- Video: 16:9 debate video and 9:16 shorts rendered in the browser (Remotion).
- User Voting: Let the audience decide the winner.
- Export Transcripts: Save debates as Markdown.
- Accounts & credits: sign-up, Stripe top-ups, ledger, personal OpenRouter key.
- Public gallery: publish debates with share links.
- PDF Export: Nicely formatted transcript downloads.
- Multiplayer Mode: Human vs AI debates.
- Local LLM Support: Integration with Ollama for offline debates.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Project Link: https://github.com/khoren93/ai-debates
