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

# Stream chat response

> Streams a chat response in real-time using server-sent events (SSE). Supports both AI SDK format (with messages array) and custom format (with message object).



## OpenAPI

````yaml /openapi-components.json post /api/v1/chat/stream
openapi: 3.0.0
info:
  title: StudyFetch API
  description: API documentation for StudyFetch
  version: '1.0'
  contact: {}
servers:
  - url: https://studyfetchapi.com
    description: Production API Server
security: []
tags: []
paths:
  /api/v1/chat/stream:
    post:
      tags:
        - Chat
      summary: Stream chat response
      description: >-
        Streams a chat response in real-time using server-sent events (SSE).
        Supports both AI SDK format (with messages array) and custom format
        (with message object).
      operationId: streamChat
      parameters:
        - name: x-component-id
          required: false
          in: header
          description: Optional component ID for component-specific chat context
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamChatDto'
      responses:
        '200':
          description: Successful streaming response (SSE format)
        '400':
          description: Bad request - Invalid message format
        '401':
          description: Unauthorized - Missing or invalid authentication
        '500':
          description: Internal server error
      security:
        - x-api-key: []
components:
  schemas:
    StreamChatDto:
      type: object
      properties:
        messages:
          description: >-
            Messages array for AI SDK format - list of conversation messages
            with roles
          example:
            - role: user
              content: Hello
            - role: assistant
              content: Hi there!
            - role: user
              content:
                - type: text
                  text: What is in this image?
                - type: image
                  image_url:
                    url: https://example.com/image.jpg
          type: array
          items:
            type: string
        message:
          description: Single message for custom format - contains text and optional images
          allOf:
            - $ref: '#/components/schemas/ChatMessage'
        componentId:
          type: string
          description: Component ID
        userId:
          type: string
          description: User ID
        groupIds:
          description: Group IDs for access control
          type: array
          items:
            type: string
        sessionId:
          type: string
          description: Session ID
        id:
          type: string
          description: Session ID (AI SDK uses "id")
        context:
          type: object
          description: Additional context
    ChatMessage:
      type: object
      properties:
        text:
          type: string
          description: Text content of the message
        images:
          description: Images attached to the message
          type: array
          items:
            $ref: '#/components/schemas/ImageInput'
    ImageInput:
      type: object
      properties:
        url:
          type: string
          description: URL of the image
        base64:
          type: string
          description: Base64 encoded image data
        mimeType:
          type: string
          description: MIME type of the image
        caption:
          type: string
          description: Caption for the image
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API Key for server-to-server authentication. Resolves to the owning
        organization.

````