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

# Send a message and stream the reply

> Takes a Vercel AI SDK chat request and streams the assistant's reply as a UI message stream (server-sent events). Only the request's last message is used — the thread's history comes from the server. A last message from the assistant carries your answers to tool-approval requests and resumes the paused turn; only the person who sent that turn can answer them. Tools run as you, with your permissions.



## OpenAPI

````yaml post /api/chat/threads/{thread_id}/stream
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/chat/threads/{thread_id}/stream:
    post:
      tags:
        - Chat
      summary: Send a message and stream the reply
      description: >-
        Takes a Vercel AI SDK chat request and streams the assistant's reply as
        a UI message stream (server-sent events). Only the request's last
        message is used — the thread's history comes from the server. A last
        message from the assistant carries your answers to tool-approval
        requests and resumes the paused turn; only the person who sent that turn
        can answer them. Tools run as you, with your permissions.
      operationId: stream_chat_api_chat_threads__thread_id__stream_post
      parameters:
        - name: thread_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Thread Id
      requestBody:
        required: true
        description: A Vercel AI SDK chat request (UI message stream protocol).
        content:
          application/json:
            schema:
              type: object
              required:
                - trigger
                - id
                - messages
              properties:
                trigger:
                  type: string
                  enum:
                    - submit-message
                    - regenerate-message
                  description: '`regenerate-message` replaces the thread''s last answer.'
                id:
                  type: string
                  description: The thread ID.
                messageId:
                  type: string
                  description: The message being regenerated, when regenerating.
                messages:
                  type: array
                  description: >-
                    AI SDK UI messages (`id`, `role`, `parts`). Only the last is
                    used: a user message starts a turn; an assistant message
                    carrying `approval-responded` tool parts resumes a paused
                    one.
                  items:
                    type: object
      responses:
        '200':
          description: The reply, as a Vercel AI SDK UI message stream.
          content:
            text/event-stream: {}
        '401':
          description: No forwardable credential.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You can't post here, or the approval isn't yours to give.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Thread not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Thread archived, busy, or approvals don't match the pending calls.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Malformed chat request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Chat is not configured.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````

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