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

# Stream Chat

> Send a question and receive a streaming SSE response



## OpenAPI

````yaml POST /v2/chats/stream
openapi: 3.1.0
info:
  title: TextQL v2 API
  version: '2.0'
  description: >
    REST API for TextQL platform operations. All endpoints require Bearer token
    authentication.
servers:
  - url: https://app.textql.com
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Create and manage AI chat sessions
  - name: Connectors
    description: List available data connectors
  - name: Playbooks
    description: Create, configure, and run automated playbooks
  - name: Sandcastles
    description: Manage Python sandbox environments for code execution
  - name: Changes
    description: Review, approve, and deny Context Library changes
paths:
  /v2/chats/stream:
    post:
      tags:
        - Chat
      summary: Stream Chat
      description: >
        Send a question and receive a streaming response via Server-Sent Events.

        Supports the same request format as Create Chat. The stream emits
        metadata,

        text deltas, assets, and a final done event.
      operationId: v2.streamChat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
          multipart/form-data:
            schema:
              type: object
              required:
                - question
              properties:
                question:
                  type: string
                chat_id:
                  type: string
                  format: uuid
                model:
                  type: string
                  description: >-
                    Optional model `id` from `GET /v2/models` (e.g.
                    `gemini_3_5_flash`). Omit for the org default. New chats
                    only.
                  example: gemini_3_5_flash
                connector_ids:
                  type: array
                  items:
                    type: integer
                    format: int32
                files:
                  type: array
                  items:
                    type: string
                    format: binary
                  maxItems: 10
      responses:
        '200':
          description: Server-Sent Events stream
          content:
            text/event-stream:
              schema:
                type: string
                description: >
                  SSE stream with JSON data payloads. Event types:

                  -
                  `{"type":"metadata","id":"...","created_at":"...","model":"...","chat_id":"...","is_continuation":bool}`

                  - `{"type":"text","text":"..."}`

                  - `{"type":"asset","asset":{...}}`

                  - `{"type":"done","status":"completed|failed","error":"..."}`
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    ChatRequest:
      type: object
      required:
        - question
      properties:
        question:
          type: string
          description: The question to ask
        chat_id:
          type: string
          format: uuid
          description: Existing chat ID to continue a conversation
        model:
          type: string
          description: >-
            Optional model to run this chat on, as an `id` from `GET /v2/models`
            (e.g. `gemini_3_5_flash`). Omit to use the organization's default
            model. Only valid on new chats — supplying it together with
            `chat_id` returns 400, and a model the caller's org/role does not
            permit returns 403.
          example: gemini_3_5_flash
        tools:
          type: object
          description: Tool configuration. Enable specific tools for this chat session.
          properties:
            connector_ids:
              type: array
              items:
                type: integer
                format: int32
              description: Connector IDs to query
            sql_enabled:
              type: boolean
              description: Enable SQL query generation
            python_enabled:
              type: boolean
              description: Enable Python code execution
            web_search_enabled:
              type: boolean
              description: Enable web search
            ontology_enabled:
              type: boolean
              description: Enable ontology-based queries
            tableau_enabled:
              type: boolean
              description: Enable Tableau integration
            powerbi_enabled:
              type: boolean
              description: Enable Power BI integration
            google_drive_enabled:
              type: boolean
              description: Enable Google Drive integration
        connector_ids:
          type: array
          items:
            type: integer
            format: int32
          description: Connector IDs to query (shorthand for tools.connector_ids)
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
              enum:
                - invalid_request
                - unauthenticated
                - permission_denied
                - not_found
                - conflict
                - rate_limit_exceeded
                - internal
                - timeout
                - cancelled
                - execution_failed
                - no_report
            message:
              type: string
              description: Human-readable error message
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: invalid_request
              message: Invalid request body
    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthenticated
              message: Authentication required
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: permission_denied
              message: Insufficient permissions
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: internal
              message: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key or JWT token

````