> ## 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.

# Stream a chat reply

> Same request as `POST /api/arena/chat`, but the reply streams back as Server-Sent Events. Each event is a `data:` line with a JSON object: `ai.stream.delta` chunks, then one `ai.stream.done`. Errors arrive as an `ai.error` event.

<Tip>
  The [streaming guide](/api-reference/guides/streaming) has complete readers for JavaScript and Python. Use `curl -N` to watch the raw stream.
</Tip>


## OpenAPI

````yaml POST /api/arena/chat/stream
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/chat/stream:
    post:
      tags:
        - Arena
      summary: Stream a chat reply
      description: >-
        Same request as `POST /api/arena/chat`, but the reply streams back as
        Server-Sent Events. Each event is a `data:` line with a JSON object:
        `ai.stream.delta` chunks, then one `ai.stream.done`. Errors arrive as an
        `ai.error` event.
      operationId: chatStream
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
            example:
              prompt: Write a limerick about latency
              model: auto
      responses:
        '200':
          description: An event stream.
          content:
            text/event-stream:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/StreamDelta'
                  - $ref: '#/components/schemas/StreamDone'
                  - $ref: '#/components/schemas/AiError'
              example: >+
                data:
                {"object":"ai.stream.delta","delta":{"type":"output_text","text":"There
                once"}}


                data:
                {"object":"ai.stream.delta","delta":{"type":"output_text","text":"
                was a packet"}}


                data: {"object":"ai.stream.done","finishReason":"stop"}

        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - bearerAuth: []
components:
  schemas:
    ChatRequest:
      type: object
      required:
        - prompt
      properties:
        prompt:
          type: string
          description: The user prompt. Must not be empty.
          example: Explain TCP vs UDP with a pizza analogy
        model:
          type: string
          default: auto
          description: >-
            Model to use: a `modelName` (or `modelId`) from `GET /api/models`,
            or `auto` to let the Arena pick a random model.
          example: auto
        system:
          type: string
          description: Optional system prompt.
        maxTokens:
          type: integer
          minimum: 1
          default: 4096
          description: Maximum tokens to generate.
        temperature:
          type: number
          minimum: 0
          maximum: 2
          default: 0.7
          description: Sampling temperature.
        threadId:
          type: string
          format: uuid
          description: Save the prompt and reply to this thread. You must own the thread.
    StreamDelta:
      type: object
      description: One chunk of generated text.
      properties:
        object:
          type: string
          const: ai.stream.delta
        delta:
          type: object
          properties:
            type:
              type: string
              const: output_text
            text:
              type: string
    StreamDone:
      type: object
      description: Sent once when generation finishes.
      properties:
        object:
          type: string
          const: ai.stream.done
        finishReason:
          type: string
          example: stop
        usage:
          $ref: '#/components/schemas/Usage'
    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
    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.