LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmith_openapi_clientresourcesthreadsAsyncThreadsResourcestats
Method●Since v0.10

stats

Copy
stats(
  self,
  thread_id: str,
  *,
  selects: List[Literal
View source on GitHub
[
'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'
,
'FEEDBACK_STATS'
]
]
,
session_id
:
str
,
filter
:
str
|
Omit
=
omit
,
extra_headers
:
Headers
|
None
=
None
,
extra_query
:
Query
|
None
=
None
,
extra_body
:
Body
|
None
=
None
,
timeout
:
float
|
httpx
.
Timeout
|
None
|
NotGiven
=
not_given
)
->
ThreadStats

Parameters

NameTypeDescription
selects*List[Literal['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', 'FEEDBACK_STATS']]

selects lists which aggregate stats to compute and return (repeatable query parameter). At least one value is required. Accepts any value of SingleThreadStatsSelectField.

session_id*str
filterstr | Omit
Default:omit
extra_headersHeaders | None
Default:None
extra_queryQuery | None
Default:None
extra_bodyBody | None
Default:None
timeoutfloat | httpx.Timeout | None | NotGiven
Default:not_given

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.

session_id is the tracing project (session) UUID (required).

filter narrows which of the thread's traces are aggregated, using a LangSmith filter expression. For example: lt(start_time, "2025-01-01T00:00:00Z") or eq(trace_id, "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"). See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

Send extra headers

Add additional query parameters to the request

Add additional JSON properties to the request

Override the client-level default timeout for this request, in seconds