Query and manage LangSmith projects, traces, runs, datasets, evaluators, experiments, and threads from the terminal
The LangSmith CLI is a command-line tool for querying and managing your LangSmith data. It’s designed for both developers and AI coding agents and outputs JSON by default for scripting, with a --format pretty option for human-readable tables. Use it when you need scriptable access to your LangSmith data, such as bulk exports, automation, or giving a coding agent direct access to your traces, runs, and datasets.
The LangSmith CLI is in alpha. Commands, flags, and output schemas may change between releases. Report issues on GitHub.
langsmith auth login requires LangSmith CLI v0.2.30 or later. langsmith profile commands require LangSmith CLI v0.2.26 or later.The recommended local setup is to authenticate with OAuth:
langsmith auth login currently supports LangSmith Cloud (SaaS) only. For self-hosted or other non-SaaS LangSmith endpoints, authenticate with an API key or create an API-key profile.
langsmith auth login
This opens a browser-based authorization flow and stores OAuth tokens in ~/.langsmith/config.json under the selected profile. Select a profile with --profile or LANGSMITH_PROFILE:
langsmith auth login --profile devlangsmith --profile dev project list
In headless environments, pass --no-browser and open the printed URL manually:
langsmith profile listlangsmith profile create dev --workspace-id <workspace-id> --set-currentlangsmith profile use devlangsmith profile set-workspace <workspace-id>
For the full profile configuration reference, see Profile configuration.You can also authenticate with an API key directly.Set your API key as an environment variable:
export LANGSMITH_API_KEY="lsv2_..."
Optionally, set a default project for queries:
export LANGSMITH_PROJECT="my-default-project"
If you’re using LangSmith self-hosted, also set the endpoint:
The following commands cover the core resource types:
# List tracing projectslangsmith project list# List recent traces in a projectlangsmith trace list --project my-app --limit 5# Get a specific trace with full detaillangsmith trace get <trace-id> --project my-app --full# List LLM runs with token countslangsmith run list --project my-app --run-type llm --include-metadata# Datasets and experimentslangsmith dataset listlangsmith experiment list --dataset my-eval-set# Conversation threadslangsmith thread list --project my-chatbot# Sandboxeslangsmith sandbox listlangsmith sandbox tunnel my-vm --remote-port 5432
Returns up to 20 projects by default, sorted by most recent activity. Lists tracing projects only. (Use experiment list to list evaluation experiments.)
langsmith project listlangsmith project list --limit 50 --name-contains chatbotlangsmith --format pretty project list
Defaults to 50 results (most other commands default to 20). The same 7-day time window applies. Use --since or --last-n-minutes to override.
langsmith run list --project my-app --run-type llmlangsmith run list --project my-app --run-type tool --name searchlangsmith run list --project my-app --min-tokens 1000 --include-metadatalangsmith run get <run-id> --fulllangsmith run export llm_calls.jsonl --project my-app --run-type llm --full
Use --split to assign examples to named splits (such as test or train) when creating or listing.
langsmith example list --dataset my-dataset --limit 50langsmith example list --dataset my-dataset --split testlangsmith example create --dataset my-dataset \ --inputs '{"question": "What is LangSmith?"}' \ --outputs '{"answer": "A platform for LLM observability"}' \ --split testlangsmith example delete <example-id> --yes
Evaluators can be offline (run against a dataset during experiments) or online (run against a live project). Use --sampling-rate to evaluate only a fraction of production runs, and --replace to overwrite an existing evaluator by name.
Sandbox commands let you build snapshots, create sandboxes, execute commands, open interactive consoles, and tunnel TCP ports to services running inside sandboxes.See Sandbox CLI for the full sandbox command reference.
The api command is an authenticated, scriptable wrapper around the raw LangSmith REST API — useful for endpoints the typed commands above don’t cover, or for piping JSON into and out of shell scripts. It’s modeled after gh api and curl: pass the path as the only positional argument, and use -X to set the HTTP method (defaults to GET). Auth headers (x-api-key, x-tenant-id) are injected automatically.
# GET (default method) — query string supported in the pathlangsmith api sessions?limit=5# Discover endpoints from the OpenAPI speclangsmith api ls --tag datasetslangsmith api info GET sessions# Typed JSON fields with -F (numbers, booleans, null, objects, arrays parsed as JSON)# Method auto-promotes to POST when -F/-f/--input/--body is suppliedlangsmith api runs/query -F session_id=abc -F limit=10# String-typed fields with -f (always sent as a JSON string, even if numeric)langsmith api datasets -f name=my-dataset -f description="QA pairs"# Other HTTP methods via -Xlangsmith api sessions/abc-123 -X DELETE# Send a request body from a file or stdinlangsmith api datasets --input create-dataset.jsonecho '{"name":"test"}' | langsmith api sessions --input -# Force GET with fields — fields go to the query string instead of a bodylangsmith api runs -X GET -F limit=5 -F session=abc# Inspect response status + headerslangsmith api sessions --include# Add custom headerslangsmith api sessions -H "Accept: text/csv"
Key flags:
Flag
Short
Default
Description
--method
-X
GET
HTTP method
--field
-F
—
Typed JSON field as key=value. Repeatable. Use @<path> or @- for file/stdin values.
--raw-field
-f
—
String JSON field as key=value. Repeatable.
--input
—
—
File to use as the request body (- for stdin)
--body
—
—
Raw request body (JSON string, @file, or @- for stdin)
--header
-H
—
Additional headers as Key:Value. Repeatable.
--include
-i
false
Print response status line and headers before body
--input and --body are mutually exclusive. Subcommands langsmith api ls and langsmith api info browse and describe endpoints from the cached OpenAPI spec — pass --refresh to re-fetch.