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

# Query Single Thread Stats

> **Alpha:** The request and response contract may change;
Compute aggregate stats for a single thread (turn count, latency percentiles, token/cost sums, and detail breakdowns) within a project.



## OpenAPI

````yaml /langsmith/langsmith-platform-openapi.json get /v2/threads/{thread_id}/stats
openapi: 3.1.0
info:
  title: LangSmith
  description: >+
    The LangSmith API is used to programmatically create and manage LangSmith
    resources.


    ## Host

    https://api.smith.langchain.com


    ## Authentication

    To authenticate with the LangSmith API, set the `X-Api-Key` header

    to a valid [LangSmith API
    key](https://docs.langchain.com/langsmith/create-account-api-key#create-an-api-key).

  version: 0.1.0
servers:
  - url: /
security: []
tags:
  - name: run
    x-group: Tracing
  - name: runs
    x-group: Tracing
  - name: sessions
    x-group: Tracing
  - name: tracer-sessions
    x-group: Tracing
  - name: datasets
    x-group: Datasets
  - name: examples
    x-group: Datasets
  - name: evaluators
    x-group: Evaluation
  - name: experiment-view-overrides
    x-group: Evaluation
  - name: experiments
    x-group: Evaluation
  - name: annotation-queues
    x-group: Feedback & Annotation
  - name: annotation_queues
    x-group: Feedback & Annotation
  - name: feedback
    x-group: Feedback & Annotation
  - name: feedback-configs
    x-group: Feedback & Annotation
  - name: alert_rules
    x-group: Monitoring
  - name: bulk-exports
    x-group: Monitoring
  - name: charts
    x-group: Monitoring
  - name: commits
    x-group: Prompts & Playground
  - name: directories
    x-group: Prompts & Playground
  - name: hub_environments
    x-group: Prompts & Playground
  - name: playground-settings
    x-group: Prompts & Playground
  - name: prompt-webhooks
    x-group: Prompts & Playground
  - name: prompts
    x-group: Prompts & Playground
  - name: tag-transitions
    x-group: Prompts & Playground
  - name: comments
    x-group: Prompt Hub
  - name: likes
    x-group: Prompt Hub
  - name: optimization-jobs
    x-group: Prompt Hub
  - name: ownerships
    x-group: Prompt Hub
  - name: repos
    x-group: Prompt Hub
  - name: settings
    x-group: Prompt Hub
  - name: tags
    x-group: Prompt Hub
  - name: integrations
    x-group: Integrations & Tools
  - name: mcp
    x-group: Integrations & Tools
  - name: mcp_vendors
    x-group: Integrations & Tools
  - name: oauth
    x-group: Integrations & Tools
  - name: tools
    x-group: Integrations & Tools
  - name: gateway-policies
    x-group: LLM Gateway
  - name: sandboxes
    x-group: Sandboxes
  - name: issues
    x-group: Issues
  - name: issues-agent
    x-group: Issues
  - name: Organizations
    x-group: Administration
  - name: SCIM Tokens
    x-group: Administration
  - name: TTL Settings
    x-group: Administration
  - name: access_policies
    x-group: Administration
  - name: api-key
    x-group: Administration
  - name: audit-logs
    x-group: Administration
  - name: auth
    x-group: Administration
  - name: aws_marketplace
    x-group: Administration
  - name: data_planes
    x-group: Administration
  - name: me
    x-group: Administration
  - name: orgs
    x-group: Administration
  - name: service-accounts
    x-group: Administration
  - name: tenant
    x-group: Administration
  - name: ttl-settings
    x-group: Administration
  - name: usage-limits
    x-group: Administration
  - name: workspaces
    x-group: Administration
  - name: ace
    x-group: System
  - name: backfills
    x-group: System
  - name: features
    x-group: System
  - name: info
    x-group: System
  - name: model-price-map
    x-group: System
  - name: public
    x-group: System
  - name: threads
    x-group: System
  - name: agents
    x-hidden: true
  - name: beacon
    x-hidden: true
  - name: engine-trial
  - name: fleet
  - name: fleet auth
    x-hidden: true
  - name: fleet credentials
    x-hidden: true
  - name: fleet github-app
    x-hidden: true
  - name: fleet integrations
    x-hidden: true
  - name: fleet mcp
    x-hidden: true
  - name: fleet threads
    x-hidden: true
  - name: fleet trigger-templates
    x-hidden: true
  - name: fleet triggers
    x-hidden: true
  - name: fleet usage
    x-hidden: true
  - name: fleet_webhooks
    x-hidden: true
  - name: health
  - name: internal
    x-hidden: true
  - name: metrics
    x-hidden: true
  - name: nps
    x-hidden: true
  - name: sandboxes-internal
    x-hidden: true
  - name: skills
    x-hidden: true
paths:
  /v2/threads/{thread_id}/stats:
    get:
      tags:
        - threads
      summary: Query Single Thread Stats
      description: >-
        **Alpha:** The request and response contract may change;

        Compute aggregate stats for a single thread (turn count, latency
        percentiles, token/cost sums, and detail breakdowns) within a project.
      parameters:
        - description: Thread ID
          name: thread_id
          in: path
          required: true
          schema:
            type: string
        - example:
            - TURNS
            - LATENCY_P50
          description: >-
            `selects` lists which aggregate stats to compute and return
            (repeatable query parameter). At least one value is required.
            Accepts any value of `SingleThreadStatsSelectField`.
          name: selects
          in: query
          style: form
          explode: true
          schema:
            items:
              enum:
                - TURNS
                - FIRST_START_TIME
                - LAST_START_TIME
                - LAST_END_TIME
                - LATENCY_P50
                - LATENCY_P99
                - PROMPT_TOKENS
                - PROMPT_COST
                - COMPLETION_TOKENS
                - COMPLETION_COST
                - TOTAL_TOKENS
                - TOTAL_COST
                - PROMPT_TOKEN_DETAILS
                - COMPLETION_TOKEN_DETAILS
                - PROMPT_COST_DETAILS
                - COMPLETION_COST_DETAILS
              type: string
            type: array
            title: Selects
        - description: '`session_id` is the tracing project (session) UUID (required).'
          name: session_id
          in: query
          required: true
          schema:
            type: string
            format: uuid
            title: Session Id
      responses:
        '200':
          description: aggregate stats for the thread
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/threads.QuerySingleThreadStatsResponseBody
        '400':
          description: bad request (missing or invalid query parameters)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '401':
          description: missing or invalid authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '403':
          description: forbidden (insufficient permission)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '404':
          description: session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '422':
          description: unprocessable entity (e.g. invalid project UUID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '500':
          description: internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '503':
          description: service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
        '504':
          description: gateway timeout or deadline exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/shared.ProblemDetails'
      security:
        - API Key: []
          Tenant ID: []
        - Bearer Auth: []
          Tenant ID: []
components:
  schemas:
    threads.QuerySingleThreadStatsResponseBody:
      type: object
      properties:
        completion_cost:
          description: >-
            `completion_cost` is the sum of per-trace completion costs across
            the thread, in USD. Populated when `COMPLETION_COST` is selected.
          type: number
        completion_cost_details:
          description: >-
            `completion_cost_details` is the per-sub-category sum of completion
            cost details across the thread. Populated when
            `COMPLETION_COST_DETAILS` is selected.
          allOf:
            - $ref: '#/components/schemas/query.RunCompletionCostDetails'
        completion_token_details:
          description: >-
            `completion_token_details` is the per-sub-category sum of completion
            token details across the thread. Populated when
            `COMPLETION_TOKEN_DETAILS` is selected.
          allOf:
            - $ref: '#/components/schemas/query.RunCompletionTokenDetails'
        completion_tokens:
          description: >-
            `completion_tokens` is the sum of per-trace completion token counts
            across the thread. Populated when `COMPLETION_TOKENS` is selected.
          type: integer
        first_start_time:
          description: >-
            `first_start_time` is the earliest trace start time in the thread
            (RFC3339). Populated when `FIRST_START_TIME` is selected.
          type: string
          format: date-time
        last_end_time:
          description: >-
            `last_end_time` is the latest trace end time in the thread
            (RFC3339). Populated when `LAST_END_TIME` is selected.
          type: string
          format: date-time
        last_start_time:
          description: >-
            `last_start_time` is the latest trace start time in the thread
            (RFC3339). Populated when `LAST_START_TIME` is selected.
          type: string
          format: date-time
        latency_p50_seconds:
          description: >-
            `latency_p50_seconds` is the approximate p50 of trace latency across
            the thread, in seconds. Populated when `LATENCY_P50` is selected.
          type: number
        latency_p99_seconds:
          description: >-
            `latency_p99_seconds` is the approximate p99 of trace latency across
            the thread, in seconds. Populated when `LATENCY_P99` is selected.
          type: number
        prompt_cost:
          description: >-
            `prompt_cost` is the sum of per-trace prompt costs across the
            thread, in USD. Populated when `PROMPT_COST` is selected.
          type: number
        prompt_cost_details:
          description: >-
            `prompt_cost_details` is the per-sub-category sum of prompt cost
            details across the thread. Populated when `PROMPT_COST_DETAILS` is
            selected.
          allOf:
            - $ref: '#/components/schemas/query.RunPromptCostDetails'
        prompt_token_details:
          description: >-
            `prompt_token_details` is the per-sub-category sum of prompt token
            details across the thread. Populated when `PROMPT_TOKEN_DETAILS` is
            selected.
          allOf:
            - $ref: '#/components/schemas/query.RunPromptTokenDetails'
        prompt_tokens:
          description: >-
            `prompt_tokens` is the sum of per-trace prompt token counts across
            the thread. Populated when `PROMPT_TOKENS` is selected.
          type: integer
        total_cost:
          description: >-
            `total_cost` is the sum of per-trace total costs across the thread,
            in USD. Populated when `TOTAL_COST` is selected.
          type: number
        total_tokens:
          description: >-
            `total_tokens` is the sum of per-trace total token counts across the
            thread. Populated when `TOTAL_TOKENS` is selected.
          type: integer
        turns:
          description: >-
            `turns` is the number of distinct traces (turns) in the thread.
            Populated when `TURNS` is selected.
          type: integer
    shared.ProblemDetails:
      description: RFC 7807 problem details returned on V2 API errors.
      type: object
      properties:
        detail:
          type: string
        instance:
          type: string
        remedy:
          description: Remedy is a LangSmith extension for user-recoverable errors.
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
    query.RunCompletionCostDetails:
      type: object
      properties:
        raw:
          description: '`raw` maps each category name to its estimated USD cost.'
          type: object
          additionalProperties:
            type: number
            format: float64
    query.RunCompletionTokenDetails:
      type: object
      properties:
        raw:
          description: '`raw` maps each category name to its completion-token count.'
          type: object
          additionalProperties:
            type: integer
            format: int64
    query.RunPromptCostDetails:
      type: object
      properties:
        raw:
          description: '`raw` maps each category name to its estimated USD cost.'
          type: object
          additionalProperties:
            type: number
            format: float64
    query.RunPromptTokenDetails:
      type: object
      properties:
        raw:
          description: '`raw` maps each category name to its prompt-token count.'
          type: object
          additionalProperties:
            type: integer
            format: int64
  securitySchemes:
    API Key:
      type: apiKey
      in: header
      name: X-API-Key
    Tenant ID:
      type: apiKey
      in: header
      name: X-Tenant-Id
    Bearer Auth:
      type: http
      description: >-
        Bearer tokens are used to authenticate from the UI. Must also specify
        x-tenant-id or x-organization-id (for org scoped apis).
      scheme: bearer

````