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

# Send a chat message with file attachments and stream the response via SSE



## OpenAPI

````yaml /api-v2.json post /sessions/{session_id}/chat/stream
openapi: 3.1.0
info:
  title: Meibel AI API
  summary: Meibel Gateway Service
  description: >-
    Our API allows you to interact with our services. Read the
    [docs](https://docs.meibel.ai) to learn how to use it.
  version: 0.6.4
servers:
  - url: https://api.meibel.ai/v2
    description: Meibel API (v2)
  - url: https://api.dev.meibel.ai/v2
    description: Meibel Dev API (v2)
  - url: http://localhost:8000/v2
    description: Local Development
security: []
tags:
  - name: Datasources
    description: v2 datasource management
  - name: Data Elements
    description: v2 data element CRUD and search
  - name: File Upload
    description: Upload files to a datasource and track upload progress
  - name: Ingest
    description: Trigger and monitor datasource ingestion
  - name: Datasource Downloads
    description: Export all datasource content as a zip archive
  - name: Table Descriptions
    description: v2 table and column descriptions
  - name: Metadata Model Catalog
    description: v2 metadata model catalog
  - name: Confidence Scoring
    description: v2 confidence scoring jobs and summaries
  - name: Documents
    description: Parse and transform documents into structured data
  - name: Agents
    description: Agent definition management
  - name: Sessions
    description: Agent session (execution) management and chat
  - name: Artifact Schemas
    description: Agent artifact schema management
paths:
  /sessions/{session_id}/chat/stream:
    post:
      tags:
        - Sessions
      summary: >-
        Send a chat message with file attachments and stream the response via
        SSE
      operationId: sendChatMessageStream
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            title: Session Id
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_sendChatMessageStream'
      responses:
        '200':
          description: Successful Response
          content:
            text/event-stream:
              x-forge-sse-sentinel: '[DONE]'
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ConnectedEvent'
                  - $ref: '#/components/schemas/StatusEvent'
                  - $ref: '#/components/schemas/ToolCallEvent'
                  - $ref: '#/components/schemas/ToolResultEvent'
                  - $ref: '#/components/schemas/PartialResponseEvent'
                  - $ref: '#/components/schemas/CompletionEvent'
                discriminator:
                  propertyName: event
                  mapping:
                    connected:
                      $ref: '#/components/schemas/ConnectedEvent'
                    status:
                      $ref: '#/components/schemas/StatusEvent'
                    tool_call:
                      $ref: '#/components/schemas/ToolCallEvent'
                    tool_result:
                      $ref: '#/components/schemas/ToolResultEvent'
                    partial_response:
                      $ref: '#/components/schemas/PartialResponseEvent'
                    completion:
                      $ref: '#/components/schemas/CompletionEvent'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
      x-codeSamples:
        - lang: Python
          label: Python
          source: |-
            from meibel import MeibelClient

            client = MeibelClient(api_key="your-api-key")

            # Upload a file
            with open("document.pdf", "rb") as f:
                result = client.agents.sessions.send_chat_message_stream("session_id_value", file=f, filename="document.pdf")
                print(result)
        - lang: TypeScript
          label: TypeScript
          source: >-
            import { MeibelClient } from 'meibel';


            const client = new MeibelClient({ apiKey: 'your-api-key' });


            import fs from 'fs';


            // Upload a file

            const file = fs.createReadStream('document.pdf');

            const result = await
            client.agents.sessions.sendChatMessageStream('session_id_value',
            file, 'document.pdf');

            console.log(result);
        - lang: Go
          label: Go
          source: >-
            import v2 "github.com/meibel-ai/meibel-go/v2"


            client := v2.NewClient(v2.WithAPIKey("your-api-key"))

            ctx := context.Background()


            // Upload a file

            f, err := os.Open("document.pdf")

            if err != nil {
                log.Fatal(err)
            }

            defer f.Close()


            result, err := client.Agents.Sessions.SendChatMessageStream(ctx,
            "session_id_value", f, "document.pdf", nil)

            if err != nil {
                log.Fatal(err)
            }

            fmt.Println(result)
components:
  schemas:
    Body_sendChatMessageStream:
      properties:
        user_message:
          anyOf:
            - type: string
            - type: 'null'
          title: User Message
        timeout_seconds:
          anyOf:
            - type: integer
            - type: 'null'
          title: Timeout Seconds
        include_thinking:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Include Thinking
        include_tool_activity:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Include Tool Activity
        files:
          anyOf:
            - items:
                type: string
                contentMediaType: application/octet-stream
              type: array
            - type: 'null'
          title: Files
      type: object
      title: Body_sendChatMessageStream
    ConnectedEvent:
      description: >-
        A server-sent event indicating the stream connection has been
        established
      type: object
      required:
        - event
        - data
      properties:
        event:
          type: string
          const: connected
        data:
          type: object
          required:
            - signal_id
          properties:
            signal_id:
              type: string
              description: Unique identifier for this stream connection
    StatusEvent:
      description: A server-sent event containing an agent status update
      type: object
      required:
        - event
        - data
      properties:
        event:
          type: string
          const: status
        data:
          type: object
          required:
            - type
            - disposition
            - sequence
            - timestamp
            - content
          properties:
            type:
              type: string
            disposition:
              type: string
            sequence:
              type: string
            timestamp:
              type: string
            content:
              type: string
    ToolCallEvent:
      description: A server-sent event indicating the agent is calling a tool
      type: object
      required:
        - event
        - data
      properties:
        event:
          type: string
          const: tool_call
        data:
          type: object
          required:
            - type
            - disposition
            - sequence
            - timestamp
            - tool_id
            - tool_name
            - arguments
          properties:
            type:
              type: string
            disposition:
              type: string
            sequence:
              type: string
            timestamp:
              type: string
            tool_id:
              type: string
            tool_name:
              type: string
            arguments:
              type: object
    ToolResultEvent:
      description: A server-sent event containing the result of a tool call
      type: object
      required:
        - event
        - data
      properties:
        event:
          type: string
          const: tool_result
        data:
          type: object
          required:
            - type
            - disposition
            - sequence
            - timestamp
            - tool_id
            - result
          properties:
            type:
              type: string
            disposition:
              type: string
            sequence:
              type: string
            timestamp:
              type: string
            tool_id:
              type: string
            result:
              type: object
    PartialResponseEvent:
      description: A server-sent event containing an incremental response from the agent
      type: object
      required:
        - event
        - data
      properties:
        event:
          type: string
          const: partial_response
        data:
          type: object
          required:
            - type
            - disposition
            - sequence
            - timestamp
            - data
          properties:
            type:
              type: string
            disposition:
              type: string
            sequence:
              type: string
            timestamp:
              type: string
            data:
              type: object
              required:
                - message
                - clean_message
              properties:
                message:
                  type: string
                clean_message:
                  type: string
                citations:
                  type: array
                  items:
                    type: object
                sources:
                  type: array
                  items:
                    type: object
                follow_up_questions:
                  items:
                    type: string
                  type: array
                call_to_actions:
                  type: array
                  items:
                    type: object
                artifacts:
                  type: array
                  items:
                    type: object
    CompletionEvent:
      description: >-
        A server-sent event containing the final complete response from the
        agent, sent once at the end of the stream
      type: object
      required:
        - event
        - data
      properties:
        event:
          type: string
          const: completion
        data:
          type: object
          required:
            - type
            - disposition
            - sequence
            - timestamp
            - data
          properties:
            type:
              type: string
            disposition:
              type: string
            sequence:
              type: string
            timestamp:
              type: string
            data:
              type: object
              required:
                - message
                - clean_message
              properties:
                message:
                  type: string
                clean_message:
                  type: string
                citations:
                  type: array
                  items:
                    type: object
                    properties:
                      position:
                        type: integer
                      source_ids:
                        type: array
                        items:
                          type: integer
                sources:
                  type: array
                  items:
                    type: object
                    properties:
                      source_id:
                        type: integer
                      data_element_id:
                        type: string
                      title:
                        type: string
                      url:
                        type: string
                        nullable: true
                      snippet:
                        type: string
                      relevance_score:
                        type: number
                      tool_name:
                        type: string
                follow_up_questions:
                  items:
                    type: string
                  type: array
                call_to_actions:
                  type: array
                  items:
                    type: object
                artifacts:
                  type: array
                  items:
                    type: object
    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:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Meibel-API-Key

````