runs

Returns a paginated list of runs for the given projects within min/max start_time. Supports filters, cursor pagination, and selects to select fields to return.

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.

post/api/v2/runs/query

Request

  • Base URL
    https://api.smith.langchain.com
  • URL
    https://api.smith.langchain.com/api/v2/runs/query
  • Auth
    • API key in header X-API-Key and API key in header X-Tenant-Id
    • or HTTP bearer and API key in header X-Tenant-Id

Headers

Acceptstring

application/json, or text/event-stream (required when ai_search is set)

Content-Typestring

application/json (required for JSON body)

Request body

ai_searchstring

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

cursorstring

cursor is the opaque string from a previous response's next_cursor. Treat it as opaque and pass it back unmodified.

filterstring

filter narrows results to runs matching this LangSmith filter expression, evaluated against each individual run. For example: and(eq(run_type, "llm"), gt(latency, 5)) or eq(status, "error"). See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

has_errorboolean

has_error filters to runs that errored (true) or completed without error (false).

idsstring[]

ids optionally limits the request to these run UUIDs.

include_subtree_usageboolean

include_subtree_usage enriches selected token and cost fields on root and intermediate runs with subtree totals, and selected first_token_time with the earliest observed subtree timestamp. Descendants contribute regardless of this request's filters or time bounds. Runs without observed descendants retain their original values. Defaults to false.

is_rootboolean

is_root returns only root runs (true) or only non-root runs (false).

max_feedback_modified_atstring date-time

max_feedback_modified_at is the exclusive upper bound (RFC3339) on feedback modified_at, applied to the feedback conditions in filter, trace_filter, or tree_filter (for example eq(feedback_key, "correctness")). Requires at least one feedback condition. Runs must still fall within the start_time window.

max_start_timestring date-time

max_start_time is the upper bound for run start_time (RFC3339). Defaults to now.

min_feedback_modified_atstring date-time

min_feedback_modified_at is the inclusive lower bound (RFC3339) on feedback modified_at, applied to the feedback conditions in filter, trace_filter, or tree_filter (for example eq(feedback_key, "correctness")). Requires at least one feedback condition. Runs must still fall within the start_time window.

min_start_timestring date-time

min_start_time is the lower bound for run start_time (RFC3339). Defaults to 1 day ago.

page_sizeinteger

page_size is the maximum number of runs to return in this response. Defaults to 100 when omitted; must be between 1 and 1000 inclusive when set.

project_idsstring[]

project_ids lists tracing project UUIDs to query. Required unless reference_dataset_id is set. Mutually exclusive with reference_dataset_id — set exactly one of them.

reference_dataset_idstring uuid

reference_dataset_id resolves session IDs server-side from the dataset. Required unless project_ids is set. Mutually exclusive with project_ids — set exactly one of them. When provided and min_start_time is omitted, the server derives it from the earliest session creation date.

reference_examplesstring[]

reference_examples optionally limits to runs linked to these dataset example UUIDs.

run_type'TOOL' | 'CHAIN' | 'LLM' | 'RETRIEVER' | 'EMBEDDING' | 'PROMPT' | 'PARSER'
selectsQueryRunSelectField[]

selects lists which properties to include on each returned run. If omitted, only id is returned. Properties not listed are omitted from each run object.

trace_filterstring

trace_filter narrows results to runs whose root trace matches this LangSmith filter expression. Use this to filter by properties of the trace's root run — for example eq(status, "success") to include only traces that completed without error. See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

trace_idstring uuid

trace_id optionally limits results to runs belonging to this trace UUID.

tree_filterstring

tree_filter narrows results to runs that belong to a trace containing at least one run matching this LangSmith filter expression anywhere in the run tree (not just the root). Use this to find runs inside traces that involved a specific tool, tag, or model — for example has(tags, "production") or eq(name, "my_tool"). See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

Example request

{
  "ai_search": "The customer was charged twice",
  "cursor": "eyJ2IjoxLCJhIjoicnVucy5xdWVyeSIsImsiOiJwYXNzIiwiYiI6InNkYiIsInQiOiJsdChjdXJzb3IsICcyMDI1LTEyLTEyIDE5OjAzOjI4LjQ4MTI1NTAxOWIxM2YyJykifQ",
  "filter": "and(eq(run_type, \"llm\"), gt(latency, 5))",
  "ids": [
    "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
    "f47ac10b-58cc-4372-a567-0e02b2c3d479"
  ],
  "is_root": true,
  "max_feedback_modified_at": "2024-12-31T23:59:59Z",
  "max_start_time": "2024-12-31T23:59:59Z",
  "min_feedback_modified_at": "2024-01-01T00:00:00Z",
  "min_start_time": "2024-01-01T00:00:00Z",
  "page_size": 100,
  "project_ids": [
    "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
    "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"
  ],
  "reference_dataset_id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
  "reference_examples": [
    "b2c3d4e5-f6a7-4b5c-9d0e-1f2a3b4c5d6e",
    "c3d4e5f6-a7b8-4c5d-0e1f-2a3b4c5d6e7f"
  ],
  "selects": [
    "ID",
    "NAME",
    "PROJECT_ID",
    "START_TIME",
    "RUN_TYPE",
    "STATUS"
  ],
  "trace_filter": "eq(status, \"success\")",
  "trace_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "tree_filter": "has(tags, \"production\")"
}

Response

OK

next_cursorstring

next_cursor is the opaque cursor to pass as cursor on the next request. Null on the final page.

Example response

{
  "items": [
    {
      "app_path": "/app/chains/chat.py:invoke",
      "completion_cost": 0.0003,
      "completion_tokens": 150,
      "dotted_order": "20240115T103000000000Z018e4c7ea9fb7ef0a5b66ea3a82e9327.",
      "end_time": "2024-01-15T10:30:01.500Z",
      "error": "context deadline exceeded",
      "events": [
        {
          "name": "new_token",
          "time": "2024-01-15T10:30:00.312Z"
        }
      ],
      "first_token_time": "2024-01-15T10:30:00.312Z",
      "id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
      "is_in_dataset": true,
      "is_root": true,
      "last_queued_at": "2024-01-15T10:31:00Z",
      "latency_seconds": 1.523,
      "ls_user_id": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
      "name": "ChatOpenAI",
      "parent_run_ids": [
        "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
        "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d"
      ],
      "price_model_id": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
      "project_id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
      "prompt_cost": 0.0002,
      "prompt_tokens": 200,
      "reference_dataset_id": "c3d4e5f6-a7b8-4c5d-0e1f-2a3b4c5d6e7f",
      "reference_example_id": "b2c3d4e5-f6a7-4b5c-9d0e-1f2a3b4c5d6e",
      "share_url": "https://smith.langchain.com/public/4f7a1b2c-8d9e-4a0b-9c1d-2e3f4a5b6c7d/r",
      "start_time": "2024-01-15T10:30:00.000Z",
      "tags": [
        "production",
        "gpt-4"
      ],
      "thread_id": "d4e5f6a7-b8c9-4d5e-1f2a-3b4c5d6e7f8a",
      "total_cost": 0.000525,
      "total_tokens": 350,
      "trace_id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327"
    }
  ],
  "next_cursor": "eyJ2IjoxLCJhIjoicnVucy5xdWVyeSIsImsiOiJwYXNzIiwiYiI6InNkYiIsInQiOiJsdChjdXJzb3IsICcyMDI1LTEyLTEyIDE5OjAzOjI4LjQ4MTI1NTAxOWIxM2YyJykifQ"
}

Changes