Chat API
Unified chat endpoint with multiple modes
Unified endpoint supporting single model, battle, fight, and multi-instance modes.
POST /api/chat
Chat API vs Gateway API
Use the Chat API for multi-model competitions, debates with voting, autonomous web search, and leaderboards.
Use the Gateway API (/api/v1/chat/completions) for direct single-model access with OpenAI SDK compatibility, fallback routing, caching, and guardrails.
Conversation History
All modes support multi-turn conversations via the optional messages array. Pass previous turns so the AI has context from earlier in the conversation.
The messages array contains all previous turns before the current message. Each entry has:
| Field | Type | Description |
|---|---|---|
role | string | "user", "assistant", or "system" |
content | string | The message content |
How History Works Per Mode
- Chat mode: The model sees the full conversation history, enabling natural follow-ups.
- Battle mode: Both models see the same conversation history.
- Fight mode: All agents see the conversation history plus previous round responses within the current debate.
- Multi-instance mode: Same as fight mode.
Web Search (Exa-Powered)
In battle, fight, and multi-instance modes, AI models can autonomously search the web when they need current information. This happens transparently — no extra parameters needed.
How It Works
- A model receives your question and decides it needs fresh data
- The model triggers a web search with a targeted query
- Results are fetched via Exa and fed back to the model
- The model's final response includes a
citationsarray with sources
No Configuration Required
Web search is automatic. Models decide when to search based on the question. Not every response triggers a search.
Citations
When a model performs a web search, its response includes a citations array:
Streaming Search Events
When streaming, web searches produce additional SSE events:
| Mode | Web Search |
|---|---|
| Chat (single model) | No |
| Battle (2 models) | Yes |
| Fight (multi-agent) | Yes |
| Multi-instance (4x same model) | Yes |
Vision & Image Analysis
All modes support image inputs via the image_url parameter. Vision models (GPT, Claude, Gemini, Grok) see the image directly. Non-vision models receive an AI-generated description transparently. See Models > Vision Support for the full support matrix.
In battle/fight mode, vision and non-vision models can compete on the same image — the system handles it automatically.
Chat Mode (Single Model)
Chat with one AI model.
Request
Response
Battle Mode (2 Models)
Compare responses from 2 AI models side by side.
Request
Response
No Winner in Battle Mode
Battle mode returns raw responses only — no voting, no winner. Use fight mode if you need voting and a winner.
Fight Mode (Multi-Agent Competition)
Multiple AIs compete, debate, and vote on each other's responses.
Streaming Required
Fight mode requires streaming ("stream": true or omit the parameter). Sending "stream": false returns a 400 STREAMING_REQUIRED error.
Request
Selecting Models
Pass a comma-separated string ("claude,gpt,grok") or an array (["claude","gpt","grok"]). Omit models to use all 8 AI models.
Response (SSE Stream)
Fight mode returns Server-Sent Events. Each line follows data: {json}\n\n:
SSE Event Reference
| Event | Key Fields | Description |
|---|---|---|
session_start | agents[], rounds | Session begins |
round_start | round, totalRounds | New round begins |
agent_start | agent, model | Agent about to respond |
agent_complete | agent, message, citations? | Agent response ready |
search_start | agent, query | Agent triggered web search |
search_complete | agent, citations[] | Search results ready |
voting_start | round | Voting phase begins |
vote_update | voter, votedFor | Single vote cast |
voting_complete | round, results[] | All votes tallied |
leaderboard_update | leaderboard[] | Cumulative scores |
round_complete | round, winner | Round winner |
session_complete | winner, finalLeaderboard[] | Final results |
error | error, agent? | Error occurred |
Multi-Instance Mode
Use agentMode to run 4 instances of the same model competing. Similar to xAI's Grok Heavy.
| agentMode | Description |
|---|---|
multiple-grok | 4 Grok instances |
multiple-claude | 4 Claude instances |
multiple-gpt | 4 GPT instances |
multiple-gemini | 4 Gemini instances |
multiple-deepseek | 4 DeepSeek instances |
multiple-kimi | 4 Kimi instances |
multiple-mistral | 4 Mistral instances |
multiple-llama | 4 Llama instances |
Same SSE stream format as fight mode. Agent IDs will be grok-1, grok-2, grok-3, grok-4.
All Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Your question (max 2000 characters) |
mode | string | Yes | "chat", "battle", or "fight" |
model | string | For chat | Single model ID (see Models) |
models | array or string | For battle/fight | Model IDs. Array ["claude","gpt"] or comma-separated "claude,gpt" |
image_url | string | No | Public image URL for vision analysis |
messages | array | No | Conversation history {role, content} objects |
rounds | number | No | Debate rounds 1-10 (default: 1) |
agentMode | string | No | Multi-instance mode (e.g., "multiple-grok") |
stream | boolean | No | Enable SSE streaming (default: true). Must be true for fight mode. |
Mode Comparison
| Feature | Chat | Battle | Fight |
|---|---|---|---|
| Models | 1 | 2 | 2-8 |
| Web Search | No | Yes | Yes |
| Voting & Winner | No | No | Yes |
stream: false | Yes | Yes | No |