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

# Rag Stream

> SSE endpoint streaming RAG indexation progress for an agent's sources.

Opens a server-sent event stream that:
- Sends current source statuses on connect.
- Pushes real-time updates from th2llm webhooks.
- Falls back to polling every 10s if webhooks are slow.
- Sends keep-alive comments every 2s.
- Auto-closes when all sources are complete or after 5 minutes.

Requires authentication (JWT via current_user).



## OpenAPI

````yaml /api-reference/openapi.json get /api/rag/stream/{agent_id}
openapi: 3.1.0
info:
  title: apowerb API
  description: REST API of the apowerb agentic framework (open-source edition).
  version: 0.1.2
  license:
    name: MIT
    url: https://github.com/apowerb/apowerb/blob/main/LICENSE
servers:
  - url: https://api.example.com
    description: Your apowerb instance
  - url: http://localhost:8000
    description: Local stack
security: []
paths:
  /api/rag/stream/{agent_id}:
    get:
      tags:
        - rag
      summary: Rag Stream
      description: |-
        SSE endpoint streaming RAG indexation progress for an agent's sources.

        Opens a server-sent event stream that:
        - Sends current source statuses on connect.
        - Pushes real-time updates from th2llm webhooks.
        - Falls back to polling every 10s if webhooks are slow.
        - Sends keep-alive comments every 2s.
        - Auto-closes when all sources are complete or after 5 minutes.

        Requires authentication (JWT via current_user).
      operationId: rag_stream_api_rag_stream__agent_id__get
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
        - name: session_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Session Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    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

````

## Related topics

- [RAG](/guides/rag.md)
- [SSE streaming](/guides/streaming.md)
- [Notification Stream](/api-reference/notifications/notification-stream.md)
- [Rag Webhook](/api-reference/rag/rag-webhook.md)
- [Configuration](/configuration.md)
