> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dualmindlab.tech/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> DualMind Arena API base URL: https://api.dualmindlab.tech. Public endpoints only; admin routes are not part of this API.
> Authenticate with the access token from an Arena session (a Supabase JWT) as `Authorization: Bearer <token>`. There are no API keys yet; never invent one.
> For battles call POST /api/arena/dualchat, then vote with POST /api/arena/model-vote using the returned comparisonId. Keep model names hidden from voters until they vote.
> GET /api/arena/model-stats (leaderboard) and GET /health need no token.

# Start a battle

> Send one prompt to two models in parallel and get both answers plus a `comparisonId` to vote with. Leave `model1`/`model2` empty for a blind Battle (`random` or `topper`), or set both for Side by Side.

<Info>
  **Keep it blind.** The response includes `agent1.model`, `agent2.model` and `arena.models` so you can reveal names after a vote. Keep them hidden from voters until they vote, as the Arena does. See [Run a battle](/api-reference/guides/run-a-battle).
</Info>

| You want | Send |
| :- | :- |
| A blind random battle | `prompt` only (or `selectionMode: "random"`) |
| The leader vs a challenger | `selectionMode: "topper"` |
| Two models you choose (Side by Side) | `model1` **and** `model2` |
| To save it in a thread | `threadId` of a thread you own |

<Note>
  Both models run in parallel with a 60 second limit each. A model that fails or times out is replaced by a fallback model, and its `message` starts with `[System Note]`. Use a client timeout of at least 120 seconds.
</Note>


## OpenAPI

````yaml POST /api/arena/dualchat
openapi: 3.1.0
info:
  title: DualMind Arena API
  version: 1.0.0
  description: >-
    The REST API behind DualMind Arena: blind battles, votes, the leaderboard,
    models and threads.
  contact:
    name: DualMind Labs
    email: support@dualmindlab.tech
    url: https://dualmindlab.tech
servers:
  - url: https://api.dualmindlab.tech
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Arena
    description: Battles and chat.
  - name: Voting
    description: Votes and the leaderboard.
  - name: Models
    description: Available models.
  - name: Threads
    description: Saved conversations and sharing.
  - name: Utilities
    description: Health and feature flags.
paths:
  /api/arena/dualchat:
    post:
      tags:
        - Arena
      summary: Start a battle
      description: >-
        Send one prompt to two models in parallel and get both answers plus a
        `comparisonId` to vote with. Leave `model1`/`model2` empty for a blind
        Battle (`random` or `topper`), or set both for Side by Side.
      operationId: startBattle
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BattleRequest'
            example:
              prompt: Write a haiku about distributed systems
              selectionMode: random
      responses:
        '200':
          description: Both responses and the comparison ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BattleResponse'
              example:
                success: true
                agent1:
                  object: ai.response
                  output:
                    type: message
                    content:
                      - type: output_text
                        text: >-
                          Packets cross the sea / two clocks disagree on now /
                          quorum settles it
                  success: true
                  message: >-
                    Packets cross the sea / two clocks disagree on now / quorum
                    settles it
                  model:
                    name: llama-3.3-70b-versatile
                    displayName: Llama 3.3 70B Versatile
                    provider: groq
                  prompt: Write a haiku about distributed systems
                  selectionMode: random
                  responseTimeMs: 1880
                  usage:
                    promptTokens: 9
                    completionTokens: 19
                    totalTokens: 28
                  timestamp: '2026-10-17T12:00:00Z'
                agent2:
                  object: ai.response
                  output:
                    type: message
                    content:
                      - type: output_text
                        text: >-
                          Nodes drift apart / consensus is a rumour / the log
                          remembers
                  success: true
                  message: >-
                    Nodes drift apart / consensus is a rumour / the log
                    remembers
                  model:
                    name: gemini-2.5-flash
                    displayName: Gemini 2.5 Flash
                    provider: google
                  prompt: Write a haiku about distributed systems
                  selectionMode: random
                  responseTimeMs: 1880
                  usage:
                    promptTokens: 9
                    completionTokens: 17
                    totalTokens: 26
                  timestamp: '2026-10-17T12:00:00Z'
                comparisonId: 3f6c1a2b-9d4e-4f7a-8b1c-0e2d3f4a5b6c
                arena:
                  comparison:
                    winnerByLength: agent1
                    winnerByTokens: agent1
                    verdict: Agent 1 produced the longer, more token-heavy answer.
                    agent1MessageLength: 70
                    agent2MessageLength: 61
                    agent1Tokens: 28
                    agent2Tokens: 26
                  models:
                    agent1: llama-3.3-70b-versatile
                    agent2: gemini-2.5-flash
                timestamp: '2026-10-17T12:00:02Z'
                totalResponseTimeMs: 1880
        '400':
          description: Missing prompt, or only one of `model1`/`model2` set.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiError'
              example:
                object: ai.error
                code: INVALID_REQUEST
                message: Prompt is required and cannot be empty
                timestamp: '2026-10-17T12:00:00Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiError'
      security:
        - bearerAuth: []
components:
  schemas:
    BattleRequest:
      type: object
      required:
        - prompt
      properties:
        prompt:
          type: string
          description: The prompt both models answer. Must not be empty.
          example: Write a haiku about distributed systems
        selectionMode:
          type: string
          enum:
            - random
            - topper
          default: random
          description: >-
            How the two models are picked when `model1` and `model2` are not
            set. `random`: two different random models. `topper`: the model with
            the best win rate against a random challenger.
        model1:
          type: string
          description: >-
            Left model (`modelName` or `modelId`). Set both `model1` and
            `model2` for a Side by Side comparison; setting only one is an
            error.
        model2:
          type: string
          description: Right model (`modelName` or `modelId`).
        system:
          type: string
          description: Optional system prompt sent to both models.
        maxTokens:
          type: integer
          minimum: 1
          default: 4096
          description: Maximum tokens per response.
        temperature:
          type: number
          minimum: 0
          maximum: 2
          default: 0.7
          description: Sampling temperature for both models.
        threadId:
          type: string
          format: uuid
          description: Save this battle to a thread you own.
    BattleResponse:
      type: object
      properties:
        success:
          type: boolean
        comparisonId:
          type: string
          format: uuid
          description: Pass this to `POST /api/arena/model-vote`.
        agent1:
          $ref: '#/components/schemas/ChatResponse'
          description: Left response (vote `left`).
        agent2:
          $ref: '#/components/schemas/ChatResponse'
          description: Right response (vote `right`).
        arena:
          type: object
          description: >-
            Simple length and token heuristics plus the model names. Clients
            that want a blind experience should keep model names hidden until
            the user votes, as the Arena does.
          properties:
            comparison:
              type: object
              properties:
                winnerByLength:
                  type: string
                  enum:
                    - agent1
                    - agent2
                    - tie
                winnerByTokens:
                  type: string
                  enum:
                    - agent1
                    - agent2
                    - tie
                verdict:
                  type: string
                userWinner:
                  type:
                    - string
                    - 'null'
                  description: Always `null` here; votes are submitted separately.
                agent1MessageLength:
                  type: integer
                agent2MessageLength:
                  type: integer
                agent1Tokens:
                  type: integer
                agent2Tokens:
                  type: integer
            models:
              type: object
              properties:
                agent1:
                  type: string
                agent2:
                  type: string
        timestamp:
          type: string
          format: date-time
        totalResponseTimeMs:
          type: integer
    AiError:
      type: object
      description: >-
        Error envelope used by the chat endpoints (and as an SSE event on the
        stream).
      properties:
        object:
          type: string
          const: ai.error
        code:
          type: string
          enum:
            - INVALID_REQUEST
            - API_ERROR
            - STREAM_ERROR
        message:
          type: string
        timestamp:
          type: string
          format: date-time
    ChatResponse:
      type: object
      properties:
        object:
          type: string
          const: ai.response
        success:
          type: boolean
        message:
          type: string
          description: The model's reply as plain text (Markdown).
        output:
          type: object
          description: The same reply in a structured content envelope.
          properties:
            type:
              type: string
              const: message
            content:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    const: output_text
                  text:
                    type: string
        model:
          $ref: '#/components/schemas/ModelInfo'
        prompt:
          type: string
        selectionMode:
          type: string
          enum:
            - automatic
            - manual
            - random
            - topper
          description: >-
            `automatic`/`manual` for single chat; `random`/`topper`/`manual` for
            battles.
        responseTimeMs:
          type: integer
          description: >-
            Wall-clock time of the request in milliseconds. In a battle both
            models run in parallel, so this is the time until both finished.
        usage:
          $ref: '#/components/schemas/Usage'
        timestamp:
          type: string
          format: date-time
    ModelInfo:
      type: object
      properties:
        name:
          type: string
          description: >-
            Provider model name, e.g. `llama-3.3-70b-versatile` or
            `@cf/meta/llama-3.1-8b-instruct`.
        displayName:
          type: string
          description: Human-friendly name.
        provider:
          type: string
          enum:
            - groq
            - google
            - cloudflare
          description: Inference provider.
    Usage:
      type: object
      properties:
        promptTokens:
          type: integer
        completionTokens:
          type: integer
        totalTokens:
          type: integer
  responses:
    Unauthorized:
      description: >-
        Missing, invalid or expired token. The body is empty; the
        `WWW-Authenticate` header explains why.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        The access token from your DualMind Arena session (a Supabase JWT). See
        Authentication.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.