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

Chat LangChain

What can I help with?

Enter to send·Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
PythonlangsmithresourcesthreadsstreamingAsyncStreamingResourcequery
Method●Since v0.14

query

Copy
query(
  self,
  *,
  ai_search: str | Omit = omit,
View source on GitHub
cursor
:
str
|
Omit
=
omit
,
filter
:
str
|
Omit
=
omit
,
max_start_time
:
Union
[
str
,
datetime
]
|
Omit
=
omit
,
min_start_time
:
Union
[
str
,
datetime
]
|
Omit
=
omit
,
page_size
:
int
|
Omit
=
omit
,
project_id
:
str
|
Omit
=
omit
,
thread_filter
:
str
|
Omit
=
omit
,
trace_filter
:
str
|
Omit
=
omit
,
tree_filter
:
str
|
Omit
=
omit
,
accept
:
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
)
->
AsyncStream
[
QueryPatchEvent
]

Parameters

NameTypeDescription
ai_searchstr | Omit
Default:omit

ai_search is a plain-language criterion evaluated against the messages from the agent trajectory scoped to the thread. AND-ed with the ordinary filters. Requires semantic filtering enabled for the deployment. Must contain nonempty text of at most 2000 UTF-8 bytes.

cursorstr | Omit
Default:omit

cursor is the opaque string from a previous response's next_cursor. Omit on the first request; pass the returned cursor to fetch the next page.

filterstr | Omit
Default:omit
max_start_timeUnion[str, datetime] | Omit
Default:omit
min_start_timeUnion[str, datetime] | Omit
Default:omit
page_sizeint | Omit
Default:omit
project_idstr | Omit
Default:omit
thread_filterstr | Omit
Default:omit
trace_filterstr | Omit
Default:omit
tree_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

GET with body payload — no resources created.

Returns the threads in a tracing project matching the query passed as the request payload. Results are filtered by the given time range and optional filters, with cursor-based pagination.

When ai_search is set, Accept: text/event-stream is required; requests without it return 406. AI search is unavailable on deployments that route queries to the v1 backend and returns 501 there.

Self-hosted deployments require LangSmith v0.16 or later.

filter narrows which threads are returned, using a LangSmith filter expression evaluated against each thread's root run. For example: has(tags, "production") or eq(status, "error"). See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

max_start_time is the exclusive upper bound on thread activity (RFC3339 date-time). Defaults to now (UTC) when omitted.

min_start_time is the inclusive lower bound on thread activity (RFC3339 date-time). Defaults to 1 day before now (UTC) when omitted.

page_size is the maximum number of threads to return in this response. Defaults to 20 when omitted; must be between 1 and 100 inclusive when set. The response may contain fewer threads than page_size even when next_cursor is non-null.

project_id is the tracing project UUID.

thread_filter narrows results using a LangSmith filter expression evaluated against each complete thread summary. Self-hosted deployments require LangSmith v0.17 or later; unsupported deployments return 501. See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

trace_filter narrows results to threads containing at least one trace whose root run matches this LangSmith filter expression. Trace-level aggregate fields are evaluated using the complete trace summary. Self-hosted deployments require LangSmith v0.17 or later; unsupported deployments return 501. See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

tree_filter narrows results to threads containing at least one trace with a matching run anywhere in its run tree. Self-hosted deployments require LangSmith v0.17 or later; unsupported deployments return 501. 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