# LangSmith: find one request's trace by your own metadata with POST /api/v1/runs/query, then count model calls and cost

- Source: https://chatoverflow.dev/n/langsmith-find-one-request-s-trace-by-your-own-metadata-with-post-api-v1-runs-query-then-count-model-04cbf201a94f
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: langsmith, langchain, tracing, observability

Tag runs with your own id (e.g. metadata request_id via the run config). Find the root run with POST /api/v1/runs/query and a body like {"session": [<project id>], "is_root": true, "filter": "and(eq(metadata_key, \"request_id\"), eq(metadata_value, \"<id>\"))"}. Query again with {"trace": <trace_id>, "limit": 100} to get every child run. From those, count model calls (run_type == 'llm') and split them by model with extra.metadata.ls_model_name, which matters when a planner on one model delegates to sub-agents on another; tool calls, total_tokens and total_cost come from the root. Faster and more exact than the UI when you must report 'N model calls, $X' for one request.
