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

# get session analytics

> Returns per-turn latency analytics for a session — where time was spent in the transcription → LLM → TTS → first-audio path for each conversational turn, plus session-level summary metrics. Analytics become available once the session has ended and the engine has delivered its session report; until then this endpoint returns 404. Analytics exist only for sessions where Anam runs the conversational pipeline (turnkey, custom LLM and ElevenLabs agent sessions) — LiveKit and audio-passthrough sessions never produce them. Message text is omitted unless `includeMessages=true` is passed and transcripts were enabled for the session.



## OpenAPI

````yaml https://api.anam.ai/swagger.json get /v1/sessions/{id}/analytics
openapi: 3.1.0
info:
  title: Anam AI API
  version: '1.0'
servers:
  - url: https://api.anam.ai
    description: Anam API
security:
  - BearerAuth: []
tags:
  - name: Sessions
  - name: Personas
  - name: Avatars
  - name: Voices
  - name: LLMs
  - name: Knowledge
  - name: Tools
  - name: Share Links
  - name: Engine
paths:
  /v1/sessions/{id}/analytics:
    get:
      tags:
        - Sessions
      summary: get session analytics
      description: >-
        Returns per-turn latency analytics for a session — where time was spent
        in the transcription → LLM → TTS → first-audio path for each
        conversational turn, plus session-level summary metrics. Analytics
        become available once the session has ended and the engine has delivered
        its session report; until then this endpoint returns 404. Analytics
        exist only for sessions where Anam runs the conversational pipeline
        (turnkey, custom LLM and ElevenLabs agent sessions) — LiveKit and
        audio-passthrough sessions never produce them. Message text is omitted
        unless `includeMessages=true` is passed and transcripts were enabled for
        the session.
      operationId: getSessionAnalytics
      parameters:
        - in: path
          name: id
          schema:
            type: string
            format: uuid
          required: true
          description: Session ID
        - in: query
          name: includeMessages
          schema:
            type: boolean
            default: false
          description: >-
            When true, include the user/assistant message text on each turn.
            Only honoured when transcripts were enabled for the session and the
            session is not zero-data-retention; timing metrics are always
            returned.
      responses:
        '200':
          description: Successfully retrieved session analytics
          content:
            application/json:
              schema:
                type: object
                properties:
                  sessionId:
                    type: string
                    format: uuid
                  startTime:
                    type: string
                    format: date-time
                  endTime:
                    type:
                      - string
                      - 'null'
                    format: date-time
                  durationSeconds:
                    type:
                      - number
                      - 'null'
                  sessionType:
                    type:
                      - string
                      - 'null'
                    enum:
                      - turnkey
                      - custom_llm_server
                      - custom_llm_client
                      - livekit
                      - elevenlabs_agent
                      - null
                  exitStatus:
                    type:
                      - string
                      - 'null'
                  clientLabel:
                    type:
                      - string
                      - 'null'
                  clientMetadata:
                    type:
                      - object
                      - 'null'
                  personaId:
                    type:
                      - string
                      - 'null'
                    format: uuid
                  apiKeyId:
                    type:
                      - string
                      - 'null'
                    format: uuid
                  config:
                    type: object
                    description: Snapshot of the configuration the session ran with.
                    properties:
                      llmProvider:
                        type:
                          - string
                          - 'null'
                      llmModel:
                        type:
                          - string
                          - 'null'
                      ttsProvider:
                        type:
                          - string
                          - 'null'
                      ttsVoice:
                        type:
                          - string
                          - 'null'
                      avatarKey:
                        type:
                          - string
                          - 'null'
                      personaName:
                        type:
                          - string
                          - 'null'
                      languageCode:
                        type:
                          - string
                          - 'null'
                      transcriptsEnabled:
                        type: boolean
                  summary:
                    type: object
                    properties:
                      totalTurns:
                        type: integer
                        description: Number of entries in `turns`.
                      completedTurns:
                        type: integer
                        description: Turns whose assistant response completed.
                      interruptedTurns:
                        type: integer
                        description: Turns whose assistant response was interrupted.
                      interruptionRate:
                        type:
                          - number
                          - 'null'
                        description: interruptedTurns / turns with an assistant response.
                      totalUserSpeechDurationSeconds:
                        type:
                          - number
                          - 'null'
                      totalUserWords:
                        type:
                          - integer
                          - 'null'
                      totalAssistantWords:
                        type:
                          - integer
                          - 'null'
                      totalWarnings:
                        type: integer
                      totalErrors:
                        type: integer
                      toolCalls:
                        type: object
                        properties:
                          total:
                            type: integer
                          succeeded:
                            type: integer
                          failed:
                            type: integer
                          byName:
                            type: object
                            additionalProperties:
                              type: integer
                      averageLatencies:
                        type: object
                        description: Engine-computed per-session averages.
                        properties:
                          transcriptionLatencySeconds:
                            type:
                              - number
                              - 'null'
                          llmTimeToFirstOutputSeconds:
                            type:
                              - number
                              - 'null'
                          ttsGenerationDurationSeconds:
                            type:
                              - number
                              - 'null'
                          firstAudioLatencySeconds:
                            type:
                              - number
                              - 'null'
                  turns:
                    type: array
                    items:
                      $ref: '#/components/schemas/SessionAnalyticsTurn'
              examples:
                default:
                  $ref: '#/components/examples/SessionAnalyticsResponse'
        '400':
          description: Bad request - Invalid session ID or query parameters
        '401':
          description: Unauthorized - Invalid or missing API key
        '404':
          description: >-
            Not Found - Session not found, still in progress, of a session type
            that does not produce analytics (e.g. livekit), or its report was
            never received. The error message says which.
        '500':
          description: Server error
components:
  schemas:
    SessionAnalyticsTurn:
      type: object
      description: >-
        One conversational turn — a user utterance paired with the assistant
        response it triggered. Assistant-initiated turns (e.g. the greeting)
        have null user-side fields; user utterances that never received a
        response have null assistant-side fields. Timing fields are null when
        the engine did not record the underlying timestamps.
      properties:
        turnIndex:
          type: integer
        correlationId:
          type:
            - string
            - 'null'
          description: The user action correlation ID shared by SDK events for this turn.
        userSpeechStartTime:
          type:
            - string
            - 'null'
          format: date-time
        userSpeechEndTime:
          type:
            - string
            - 'null'
          format: date-time
        userSpeechDurationSeconds:
          type:
            - number
            - 'null'
        userTranscriptionTime:
          type:
            - string
            - 'null'
          format: date-time
          description: When the user's speech transcript was finalised.
        transcriptionLatencySeconds:
          type:
            - number
            - 'null'
          description: User speech end → transcript complete.
        llmFirstOutputTime:
          type:
            - string
            - 'null'
          format: date-time
        llmFinalOutputTime:
          type:
            - string
            - 'null'
          format: date-time
        llmTimeToFirstOutputSeconds:
          type:
            - number
            - 'null'
          description: Transcript complete → first LLM output.
        llmGenerationDurationSeconds:
          type:
            - number
            - 'null'
          description: First LLM output → final LLM output.
        ttsStartTime:
          type:
            - string
            - 'null'
          format: date-time
        ttsEndTime:
          type:
            - string
            - 'null'
          format: date-time
        ttsGenerationDurationSeconds:
          type:
            - number
            - 'null'
        ttsTimeToFirstAudioSeconds:
          type:
            - number
            - 'null'
          description: TTS start → persona starts speaking.
        personaStartSpeakingTime:
          type:
            - string
            - 'null'
          format: date-time
        personaStopSpeakingTime:
          type:
            - string
            - 'null'
          format: date-time
        firstAudioLatencySeconds:
          type:
            - number
            - 'null'
          description: >-
            User speech end → persona starts speaking. The end-to-end latency
            the user experienced.
        speakingDurationSeconds:
          type:
            - number
            - 'null'
        finishReason:
          type:
            - string
            - 'null'
          enum:
            - completed
            - interrupted
            - null
        wasInterrupted:
          type: boolean
        interruptedStage:
          type:
            - string
            - 'null'
          enum:
            - before_llm_output
            - during_llm_generation
            - before_audio
            - while_speaking
            - null
          description: >-
            Best-effort classification of when the interruption happened,
            derived from which pipeline timestamps were recorded.
        toolCalls:
          type: array
          items:
            $ref: '#/components/schemas/SessionAnalyticsToolCall'
        userMessage:
          type: string
          description: Only present with includeMessages=true and transcripts enabled.
        assistantMessage:
          type: string
          description: Only present with includeMessages=true and transcripts enabled.
    SessionAnalyticsToolCall:
      type: object
      description: >-
        Timing and outcome of a tool call made during the turn. Tool call
        arguments and results are never exposed by this endpoint.
      properties:
        toolCallId:
          type:
            - string
            - 'null'
          description: >-
            The engine's ID for this tool call, matching the ID surfaced in SDK
            tool events.
        toolName:
          type:
            - string
            - 'null'
        toolType:
          type:
            - string
            - 'null'
        status:
          type:
            - string
            - 'null'
          enum:
            - started
            - completed
            - failed
            - null
        startedAt:
          type:
            - string
            - 'null'
          format: date-time
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
        durationSeconds:
          type:
            - number
            - 'null'
        errorMessage:
          type:
            - string
            - 'null'
  examples:
    SessionAnalyticsResponse:
      summary: Per-turn latency analytics for a completed session
      value:
        sessionId: 00000000-0000-0000-0000-000000000000
        startTime: '2026-04-20T09:00:00.000Z'
        endTime: '2026-04-20T09:12:34.000Z'
        durationSeconds: 754
        sessionType: turnkey
        exitStatus: CLOSED_BY_ENGINE
        clientLabel: js-sdk-api-key
        clientMetadata: null
        personaId: null
        apiKeyId: 00000000-0000-0000-0000-000000000000
        config:
          llmProvider: openai
          llmModel: gpt-4o
          ttsProvider: ELEVENLABS
          ttsVoice: lcMyyd2HUfFzxdCaC4Ta
          avatarKey: cara_home
          personaName: Cara
          languageCode: en
          transcriptsEnabled: true
        summary:
          totalTurns: 4
          completedTurns: 1
          interruptedTurns: 1
          interruptionRate: 0.5
          totalUserSpeechDurationSeconds: 9.4
          totalUserWords: 24
          totalAssistantWords: 61
          totalWarnings: 0
          totalErrors: 0
          toolCalls:
            total: 1
            succeeded: 1
            failed: 0
            byName:
              lookup_order: 1
          averageLatencies:
            transcriptionLatencySeconds: 0.31
            llmTimeToFirstOutputSeconds: 0.58
            ttsGenerationDurationSeconds: 1.12
            firstAudioLatencySeconds: 1.24
        turns:
          - turnIndex: 0
            correlationId: corr-0000
            userSpeechStartTime: null
            userSpeechEndTime: null
            userSpeechDurationSeconds: null
            userTranscriptionTime: null
            transcriptionLatencySeconds: null
            llmFirstOutputTime: '2026-04-20T09:00:02.100Z'
            llmFinalOutputTime: '2026-04-20T09:00:03.400Z'
            llmTimeToFirstOutputSeconds: null
            llmGenerationDurationSeconds: 1.3
            ttsStartTime: '2026-04-20T09:00:02.200Z'
            ttsEndTime: '2026-04-20T09:00:03.900Z'
            ttsGenerationDurationSeconds: 1.7
            ttsTimeToFirstAudioSeconds: 0.42
            personaStartSpeakingTime: '2026-04-20T09:00:02.620Z'
            personaStopSpeakingTime: '2026-04-20T09:00:07.100Z'
            firstAudioLatencySeconds: null
            speakingDurationSeconds: 4.48
            finishReason: completed
            wasInterrupted: false
            interruptedStage: null
            toolCalls: []
          - turnIndex: 1
            correlationId: corr-0001
            userSpeechStartTime: '2026-04-20T09:00:09.000Z'
            userSpeechEndTime: '2026-04-20T09:00:11.300Z'
            userSpeechDurationSeconds: 2.3
            userTranscriptionTime: '2026-04-20T09:00:11.640Z'
            transcriptionLatencySeconds: 0.34
            llmFirstOutputTime: '2026-04-20T09:00:12.210Z'
            llmFinalOutputTime: '2026-04-20T09:00:13.760Z'
            llmTimeToFirstOutputSeconds: 0.57
            llmGenerationDurationSeconds: 1.55
            ttsStartTime: '2026-04-20T09:00:12.300Z'
            ttsEndTime: '2026-04-20T09:00:14.100Z'
            ttsGenerationDurationSeconds: 1.8
            ttsTimeToFirstAudioSeconds: 0.39
            personaStartSpeakingTime: '2026-04-20T09:00:12.690Z'
            personaStopSpeakingTime: '2026-04-20T09:00:16.200Z'
            firstAudioLatencySeconds: 1.39
            speakingDurationSeconds: 3.51
            finishReason: interrupted
            wasInterrupted: true
            interruptedStage: while_speaking
            toolCalls:
              - toolCallId: tool-0001
                toolName: lookup_order
                toolType: SERVER_WEBHOOK
                status: completed
                startedAt: '2026-04-20T09:00:12.400Z'
                completedAt: '2026-04-20T09:00:13.100Z'
                durationSeconds: 0.7
                errorMessage: null
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````