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

# Stream a chat run over server-sent events.

> Expects the full message history and executes against the latest non-empty
user message.



## OpenAPI

````yaml api/openapi.json post /api/chat/stream
openapi: 3.0.2
info:
  contact:
    name: OpenAgents
    url: https://openagents.com
  description: >-
    OpenAgents REST API (Laravel). Primary auth is Sanctum bearer tokens for
    /api endpoints.
  title: OpenAgents API
  version: 1.0.0
servers:
  - description: Primary production server
    url: https://openagents.com
security:
  - SanctumToken: []
tags:
  - description: Authentication context and token lifecycle endpoints.
    name: Auth
  - description: Conversation, run, and stream endpoints.
    name: Chat
  - description: Autopilot resources, thread scoping, and stream alias routes.
    name: Autopilot
  - description: Authenticated profile management endpoints.
    name: Profile
  - description: Global public broadcast messages, optionally scoped by zone.
    name: Shouts
  - description: Direct messages between two users, inbox and thread retrieval.
    name: Whispers
  - description: Lightning L402 wallet, receipts, and deployment telemetry endpoints.
    name: L402
  - description: >-
      Per-user Spark wallet lifecycle and payment APIs (invoice + pay + spark
      transfers).
    name: Agent Payments
paths:
  /api/chat/stream:
    post:
      tags:
        - Chat
      summary: Stream a chat run over server-sent events.
      description: >-
        Expects the full message history and executes against the latest
        non-empty

        user message.
      requestBody:
        content:
          application/json:
            schema:
              properties:
                messages:
                  items:
                    properties:
                      content:
                        nullable: true
                        type: string
                      id:
                        nullable: true
                        type: string
                      parts:
                        items:
                          properties:
                            text:
                              nullable: true
                              type: string
                            type:
                              nullable: true
                              type: string
                          type: object
                        nullable: true
                        type: array
                      role:
                        example: user
                        type: string
                    type: object
                  type: array
              required:
                - messages
              type: object
        description: >-
          Full client-side message history; backend executes using the latest
          user message. L402 tool contract: `maxSpendMsats` is canonical
          (`maxSpendSats` temporary alias) and `requireApproval` is canonical
          (`approvalRequired` temporary alias).
        required: true
      responses:
        '200':
          content:
            text/event-stream:
              schema:
                example: |+
                  data: {"type":"start"}

                  data: [DONE]

                type: string
          description: Server-sent event stream (Vercel AI data stream protocol)
        '401':
          content:
            application/json:
              schema:
                properties:
                  message:
                    example: Unauthenticated.
                    type: string
                type: object
          description: Authentication required
        '404':
          content:
            application/json:
              schema:
                properties:
                  message:
                    example: Not found.
                    type: string
                type: object
          description: Not found
        '422':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    additionalProperties:
                      items:
                        type: string
                      type: array
                    type: object
                  message:
                    example: The given data was invalid.
                    type: string
                type: object
          description: Validation error
components:
  securitySchemes:
    SanctumToken:
      bearerFormat: Sanctum PAT
      scheme: bearer
      type: http

````