Endpoint
Authentication
Requires valid NextAuth session. Returns401 Unauthorized if not authenticated.
Rate Limiting
Request Body
The debate topic or question. The system will use this to select an appropriate opponent and guide the debate.Example: “Is artificial intelligence beneficial or harmful to society?”
User profile information for the AI agent. The agent will adopt these characteristics during the debate.
Example Request
Response Format
Returns atext/event-stream response with Server-Sent Events. Each event has a type and associated data.
Response Headers
SSE Event Types
All events follow the format:
event: <type>\ndata: <json>\n\ninit
Sent first to initialize the debate session.Unique debate ID (format:
debate_<timestamp>_<random>)The debate topic
User’s profile information
Selected opponent’s profile with personality and stance information
start
Indicates that a participant is about to speak.Either
"user" (user’s agent) or "opponent"Name of the speaker
chunk
Streaming content chunks as the AI generates responses.Either
"user" or "opponent"Partial text content (append to previous chunks)
message
Complete message after all chunks are received.Either
"user" or "opponent"Speaker’s name
Full message content
Unix timestamp in milliseconds
synthesizing
Indicates that the debate has concluded and synthesis is being generated. Example:synthesis
AI-generated debate analysis and evaluation.Points where both parties agreed
Core points of disagreement
Debate winner:
"user", "opponent", or "tie"Explanation for the winner determination
Overall conclusion about the debate topic (max 100 characters)
Recommendations for readers based on the debate
done
Final event indicating debate completion. Contains full debate data.Debate ID
Debate topic
Array of all debate messages (see
message event structure)Complete synthesis object (see
synthesis event structure)error
Sent if an error occurs during the debate.Error description
Debate Configuration
Debate Rounds: 5 rounds (configurable in source code:365)AI Model: Configured via
OPENAI_MODEL environment variable (default: gpt-4o-mini)Message Length: Each participant’s response is controlled to 100-200 charactersTemperature: 0.8 for debate responses, 0.3 for synthesisError Responses
Error message
400 Bad Request
401 Unauthorized
429 Too Many Requests
500 Internal Server Error
Implementation Notes
Database Storage: All debates are automatically saved to MongoDB with status progression:
in_progress: During debatecompleted: After synthesis generation