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

# Stream LLM Response (v2)

> Send messages using OpenAI-compatible format and receive streaming responses (Server-Sent Events).



## OpenAPI

````yaml /specs/openapi-interactive.json post /api/v1/session/{session_id}/llm/v2/
openapi: 3.0.3
info:
  title: Perso Interactive API
  version: 0.0.0
servers:
  - url: https://platform.perso.ai
security: []
tags:
  - name: Embed
paths:
  /api/v1/session/{session_id}/llm/v2/:
    post:
      tags:
        - Session Operations
      summary: Stream LLM Response (v2)
      description: >-
        Send messages using OpenAI-compatible format and receive streaming
        responses (Server-Sent Events).
      operationId: v1_session_llm_v2_create
      parameters:
        - in: path
          name: session_id
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LLMV2RequestRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/LLMV2RequestRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/LLMV2RequestRequest'
        required: true
      responses:
        '200':
          content:
            text/event-stream:
              schema:
                type: string
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse500'
              examples:
                LLMTypeArgsNotDictionaryException:
                  value:
                    type: client_error
                    errors:
                      - code: llm_type_args_not_dictionary
                        detail: LLMType.args must be a dictionary.
                        attr: null
                SessionInvalidStateException:
                  value:
                    type: client_error
                    errors:
                      - code: session_invalid_state
                        detail: Session is in invalid state.
                        attr: null
          description: LLMType.args must be a dictionary.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse500'
              examples:
                PermissionDenied:
                  value:
                    type: client_error
                    errors:
                      - code: session_does_not_have_capacity
                        detail: Session does not have capacity {cap}.
                        attr: null
                SessionDoesNotHaveCapacityException:
                  value:
                    type: client_error
                    errors:
                      - code: session_does_not_have_capacity
                        detail: Session does not have capacity {cap}.
                        attr: null
          description: Session does not have capacity {cap}.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse500'
              examples:
                LLMAPIException:
                  value:
                    type: server_error
                    errors:
                      - code: llm_api_error
                        detail: Error generating LLM.
                        attr: null
          description: Error generating LLM.
      security:
        - {}
components:
  schemas:
    LLMV2RequestRequest:
      type: object
      properties:
        messages:
          type: array
          items: {}
          description: OpenAI-format chat message array (each with `role` and `content`).
        tools:
          type: array
          items: {}
          description: Optional list of OpenAI-style tool definitions the model may call.
      required:
        - messages
    ErrorResponse500:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ServerErrorEnum'
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error500'
      required:
        - errors
        - type
    ServerErrorEnum:
      enum:
        - server_error
      type: string
      description: '* `server_error` - Server Error'
    Error500:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode500Enum'
        detail:
          type: string
        attr:
          type: string
          nullable: true
      required:
        - attr
        - code
        - detail
    ErrorCode500Enum:
      enum:
        - error
      type: string
      description: '* `error` - Error'

````