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

# Send a message (SSE)

> The response is a `text/event-stream`. OpenAPI cannot describe the event framing:

- `event: chunk` — `data` is a `ChatChunkEvent`. One text delta. Repeats.
- `event: done` — `data` is a `ChatDoneEvent`. The full text and the reactions. Terminal.
- `event: error` — `data` is a `ChatErrorEvent`. Terminal. The status stays 200.

The stream emits exactly one terminal event: `done` or `error`. A model failure is an
`error` event, not an HTTP status. The 4xx responses below occur before the stream only.



## OpenAPI

````yaml /api-reference/openapi.json post /api/chat/send
openapi: 3.1.0
info:
  title: Lala Client API
  description: >-
    The HTTP API behind Lala, the AI study companion for Turkish YKS and LGS
    students. This document is generated from the Zod schemas that validate each
    request at runtime. Do not hand-edit openapi.json. Student-visible text is
    Turkish. All identifiers are English.
  version: 1.0.0
servers:
  - url: https://client-api.lala.ist
    description: production
  - url: http://localhost:3000
    description: local dev
security:
  - supabaseJwt: []
tags:
  - name: chat
    description: The chat stream and the message history
  - name: profile
    description: The student profile and onboarding
  - name: system
    description: Health check
paths:
  /api/chat/send:
    post:
      tags:
        - chat
      summary: Send a message (SSE)
      description: >-
        The response is a `text/event-stream`. OpenAPI cannot describe the event
        framing:


        - `event: chunk` — `data` is a `ChatChunkEvent`. One text delta.
        Repeats.

        - `event: done` — `data` is a `ChatDoneEvent`. The full text and the
        reactions. Terminal.

        - `event: error` — `data` is a `ChatErrorEvent`. Terminal. The status
        stays 200.


        The stream emits exactly one terminal event: `done` or `error`. A model
        failure is an

        `error` event, not an HTTP status. The 4xx responses below occur before
        the stream only.
      operationId: postApiChatSend
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatSendBody'
      responses:
        '200':
          description: The event stream
          content:
            text/event-stream:
              schema:
                type: string
        '400':
          description: The body had no text and no image
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The token is missing, expired, or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ChatSendBody:
      type: object
      properties:
        message:
          default: ''
          type: string
          maxLength: 8000
        image:
          type: object
          properties:
            data:
              type: string
            mimeType:
              type: string
          required:
            - data
            - mimeType
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
      description: Error body. `error` is a short English string.
  securitySchemes:
    supabaseJwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Supabase access token: `Authorization: Bearer <token>`'

````