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

# Chat Streaming V2

> Streaming chat endpoint with paragraph-level citations.

    **Event Format:**
    The response is a stream of newline-delimited JSON events with type discriminators.

    **Event Types:**
    1. `metadata`: Sent once at start with conversation/message/response IDs
    2. `paragraph`: Response paragraphs with inline citations (sent as generated)
    3. `thinking`: Thinking steps (only if report_progress=true)
    4. `done`: Completion marker

    **Example Stream:**
    ```
    metadata: {"type":"metadata","conversation_id":"...","message_id":"...","response_id":"..."}


    thinking: {"type":"thinking","step":"Searching for relevant documents..."}


    paragraph: {"type":"paragraph","text":"Alice is 32 years old.","citations":[...],"links":[]}


    paragraph: {"type":"paragraph","text":"She works at AODocs.","citations":[...],"links":[...]}


    done: {"type":"done"}


    ```

    **Client Implementation:**
    Parse each line by splitting on the prefix (`metadata:`, `paragraph:`, etc.) and
    parsing the JSON. Use the `type` field for type-safe handling.

    **Progressive Rendering:**
    Paragraphs are sent as soon as they're generated, enabling progressive UI updates
    with inline citations.



## OpenAPI

````yaml https://document-assistant.us.aodocs.app/openapi.json post /assistant/api/v2/tenants/{tenant}/chat:streamingResponse
openapi: 3.1.0
info:
  title: Document Assistant API
  description: |
    <p>
      The Document Assistant API enables developers to integrate document-based assistant
      functionalities into their applications using AODocs.
    </p>
    <p>
      The first step is to enable AIDA (AODocs Intelligent Document Assistant) in your tenant.
      The support team will provide you with the necessary information on how to get started.
    </p>
    <p>
      The second step is to enable AIDA on libraries. You need to be an administrator of the
      library to do this.<br />
      AIDA can answer questions only from those documents that are in an AIDA enabled
      library.<br />
      We create a vector store index for these documents. This can take some time. The get
      library API provides the status of the indexation and an estimate of the time
      remaining.<br />
      The content of the index is automatically kept up-to-date near real time with the
      content changes.
    </p>
    <p>
      The third step is to ask questions based on the AODocs documents.<br />
      AIDA automatically filters the results based on the user's permissions.
    </p>
    <p>
      <strong>Authentication:</strong> All API endpoints require a valid OAuth2 token in the
      Authorization header. Ensure the client ID of the OAuth2 token is whitelisted in AODocs.
    </p>
  version: 1.1.0
servers:
  - url: https://document-assistant.us.aodocs.app
    description: Production US
  - url: https://document-assistant.eu.aodocs.app
    description: Production EU
security: []
paths:
  /assistant/api/v2/tenants/{tenant}/chat:streamingResponse:
    post:
      tags:
        - chat-v2
      summary: Chat Streaming V2
      description: |-
        Streaming chat endpoint with paragraph-level citations.

            **Event Format:**
            The response is a stream of newline-delimited JSON events with type discriminators.

            **Event Types:**
            1. `metadata`: Sent once at start with conversation/message/response IDs
            2. `paragraph`: Response paragraphs with inline citations (sent as generated)
            3. `thinking`: Thinking steps (only if report_progress=true)
            4. `done`: Completion marker

            **Example Stream:**
            ```
            metadata: {"type":"metadata","conversation_id":"...","message_id":"...","response_id":"..."}


            thinking: {"type":"thinking","step":"Searching for relevant documents..."}


            paragraph: {"type":"paragraph","text":"Alice is 32 years old.","citations":[...],"links":[]}


            paragraph: {"type":"paragraph","text":"She works at AODocs.","citations":[...],"links":[...]}


            done: {"type":"done"}


            ```

            **Client Implementation:**
            Parse each line by splitting on the prefix (`metadata:`, `paragraph:`, etc.) and
            parsing the JSON. Use the `type` field for type-safe handling.

            **Progressive Rendering:**
            Paragraphs are sent as soon as they're generated, enabling progressive UI updates
            with inline citations.
      operationId: >-
        chat_streaming_v2_assistant_api_v2_tenants__tenant__chat_streamingResponse_post
      parameters:
        - name: tenant
          in: path
          required: true
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The domain of the customer
            examples:
              - example.com
            title: Tenant
          description: The domain of the customer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequestV2'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: No answer was generated by the agent
      security:
        - HTTPBearer: []
components:
  schemas:
    ChatRequestV2:
      properties:
        message:
          type: string
          title: Message
          description: The message to be sent to the assistant
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: The id of the agent to scope this chat request
        conversation_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Conversation Id
          description: >-
            The conversation ID of the chat message. If not provided, a new
            conversation will be created.
        library_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Library Ids
          description: Answer the question in the context of these libraries
        document_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Document Ids
          description: Answer the question in the context of these documents
        view_id:
          anyOf:
            - type: string
            - type: 'null'
          title: View Id
          description: Answer the question in the context of the view
        timezone:
          type: integer
          title: Timezone
          description: >-
            Timezone of the user. If not provided we use UTC timezone. Format:
            offset from UTC, in minutes (JavaScript getTimezoneOffset)
          default: 0
        read_only:
          type: boolean
          title: Read Only
          description: Disable tools that can modify documents for this request
          default: false
      type: object
      required:
        - message
      title: ChatRequestV2
      description: |-
        V2 Chat request model with deprecated fields removed.

        Changes from V1:
        - Removed library_id (use library_ids)
        - Removed document_id (use document_ids)
        - Removed view_params (not needed in v2)
        - Removed filters (handled internally)
        - Removed use_header_prefix (streaming format changed)
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````