--format json option for scripting. 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.
Install
langchain-langsmith-cli, ships the same prebuilt binary as the other install methods, with one wheel per platform. It installs through any PyPI proxy, such as a JFrog Artifactory PyPI remote repository or a Nexus PyPI proxy, so you can install it where only an internal package index is reachable.
To upgrade at any time:
--dry-run flag to preview the update without installing.
self-update replaces the binary in place for installs from the install script or GitHub Releases. If a package manager installed the CLI, self-update leaves the binary alone and prints the command to run instead:
To replace the binary in place anyway, pass
--force.
Querying a SmithDB-backed deployment requires LangSmith CLI
v0.2.44 or later.Authenticate
The CLI selects an agent environment through--project or LANGSMITH_PROJECT. Retrieve that environment’s tracer_session_name and use it for these options. Commands named project, such as project list, work with the trace storage behind each agent environment, not with agents.
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 also works against self-hosted instances from LangSmith CLI v0.2.46 and newer, provided the deployment is on LangSmith 0.16 or later with the OAuth authorization server enabled (requires a signing JWKS to be configured). See Self-hosted instances. On earlier deployments, or without a signing JWKS, authenticate with an API key or create an API-key profile.~/.langsmith/config.json under the selected profile. Select a profile with --profile or LANGSMITH_PROFILE:
--no-browser and open the printed URL manually:
tracer_session_name:
Self-hosted instances
Point the CLI at your instance with--api-url, or with LANGSMITH_ENDPOINT. Both the browser-based login and API keys are supported.
- OAuth
- API key
Requires LangSmith CLI Pass your instance’s base URL. The CLI reads the deployment’s authorization server metadata to find the OAuth endpoints, so
v0.2.46 or later and a deployment on LangSmith 0.16 or later, with the OAuth authorization server enabled. The chart exposes the OAuth authorization server under /api, but those endpoints stay inert until you configure a signing JWKS.The OAuth authorization server is enabled automatically when config.hostname is set in your Helm chart and a signing JWKS is configured (via config.signingJwks, or the key langsmith_signing_jwks in config.existingSecretName). Without the signing JWKS, the OAuth endpoints are inactive and the CLI will receive a 404 — use the API key tab instead.https://langsmith.example.com and https://langsmith.example.com/api both work.Tokens are stored under the named profile, so later commands only need --profile:Set up coding agents
langsmith setup gives Claude Code, Cursor, and Codex the LangSmith skills and the hosted LangSmith MCP server. It detects the agents installed on your machine, shows what it will change, and asks before writing. Running it again changes nothing that is already set up.
langsmith setup requires LangSmith CLI v0.5.0 or later. From v0.6.0, it installs the langchain-skills plugin and replaces skills it installed earlier from the deprecated langsmith-skills package.
No API key is written: each agent signs in to the MCP server with OAuth.
setup never replaces an MCP entry named langsmith or a skill directory it didn’t write unless you pass --force.
Quickstart
The following commands cover the core resource types:Search with AI
AI search finds runs, traces, and threads from a plain-language description, which LangSmith turns into filters, time bounds, and conditions on the conversation. Use--ai-search on the streaming query commands to search from the terminal.
These commands require LangSmith CLI v0.3.9 or later and an organization admin to enable AI search. The same data-handling and PHI restrictions apply as in the UI. For release stage and availability, see Search with AI. The commands require
--project-id and do not resolve --project names.--max-items counts events, not matched runs, traces, or threads.
Pass a nonempty description of at most 2,000 UTF-8 bytes, and put structured conditions in the description itself. Combining --ai-search with --filter, --trace-filter, --tree-filter, or --thread-filter returns HTTP 400. A time period in the description replaces --min-start-time and --max-start-time.
The non-streaming traces query and threads query commands also accept --ai-search, but the server rejects those requests with HTTP 406 because AI search requires streaming. Ordinary list commands do not support AI search.
Output formats
Default Human-readable tables:--format json to pipe, script, or feed output to an agent. From v0.6.0, --json is a shorthand for --format json:
jq, pass a jq expression with --jq, which implies --format json:
-o <path>:
v0.6.0, notes about it go to stderr: the profile and workspace in use when you have more than one profile, a list that stopped at --limit while more items match, and a run or trace list that searched only the default 7-day window. With --format json or --jq, each note is a JSON object with a notice field.
Today, output that is piped or redirected stays human-readable, and the CLI warns on stderr. From
v1.0.0, piped or redirected output defaults to JSON. Pass --format explicitly in scripts to keep the same output across the change.Use the CLI from scripts and agents
The CLI never waits on a prompt that a script or agent can’t answer, and its errors say how to fix them.- Destructive commands need
--yes. Commands that delete or overwrite data ask for confirmation in a terminal. Without a terminal, pass--yes. Fromv0.6.0untilv1.0.0, a run without a terminal and without--yesgoes ahead with a deprecation warning only if the command never prompted before or stdin suppliesy; otherwise it refuses. Fromv1.0.0, it always refuses. An agent should confirm with the user, then rerun with--yes. - Retry-safe creates. From
v0.6.0,dataset create,prompt create, andagents createaccept--if-not-exists, which returns the existing resource instead of failing when it already exists. - Errors name the fix. From
v0.6.0, unknown subcommands fail with a suggestion, and not-found, workspace, and permission errors name the command to run next, such aslangsmith workspaces list. - Exit codes. Every failure exits
1untilv1.0.0. Fromv0.6.0, setLANGSMITH_EXIT_CODES=detailedto use the detailed codes now:
langsmith docs agents prints a task-oriented command reference for coding agents, generated from the installed version of the CLI.
Commands
Each command group targets a specific LangSmith resource. Most commands support--limit, --offset, and a shared set of filter flags.
List trace-storage destinations
The legacyproject list command lists the backing trace-storage destinations, including those associated with agent environments. It returns up to 20 by default, sorted by most recent activity. Use experiment list to list evaluation experiments.
Query traces
Defaults to the last 7 days, newest first. Use--since or --last-n-minutes to change the time window.
Query runs
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.
Query threads
--project is required for all thread commands.
Investigate failures and verify fixes
Requires LangSmith CLI
v0.5.0 or later.investigate and verify each run a fixed set of reads and return one compact report, so an agent makes one call instead of chaining list and stats commands. With --format json, the suggested follow-up commands are in .next.
investigate compares a window (default: the last 24 hours) with a baseline just before it (--baseline, default 7d): trace count, error rate, p50 and p99 latency, and cost. It groups the newest failed runs by step and error, marks each group as new or ongoing, and lists evidence trace IDs and related open issues.
verify checks that failures stopped after a fix. Pass --since with the time the fix went live, and narrow the target failures with --match. Each target is reported as fixed, still_failing, inconclusive (too few runs to tell), or no_traffic, and errors that appear only after the fix are listed as new_failures.
Manage datasets
dataset export exports the examples (rows) within a dataset, not the dataset metadata itself.
Manage examples
Use--split to assign examples to named splits (such as test or train) when creating or listing.
v0.6.0, --from-run turns runs into examples. Each example copies the run’s inputs, outputs, and attachments and keeps the run as its source. --from-run is repeatable, --from-run - reads run IDs from stdin, and --skip-duplicates skips runs whose inputs already match an example in the dataset. For chat and LLM datasets, the server converts each run to the dataset’s format.
Manage evaluators
Evaluators can be offline (run against a dataset during experiments) or online (run against an agent environment). Use--sampling-rate to evaluate only a fraction of production runs, and --replace to overwrite an existing evaluator by name.
From v0.6.0, evaluator upload sends the whole file unchanged, so imports and helpers are kept. The file must define perform_eval (Python) or performEval (JavaScript or TypeScript). Earlier versions require --function.
Run and compare experiments
experiment list shows evaluation experiments. Use project list for the trace-storage destinations associated with agent environments.
experiment run and experiment compare require LangSmith CLI v0.6.0 or later.experiment run runs your app over every example in a dataset and records the results as an experiment. The command after -- runs once per example, outside a shell. It reads the example’s inputs as a JSON object on stdin, gets LANGSMITH_EXAMPLE_ID and LANGSMITH_RUN_ID in its environment, and must print its outputs as one JSON value on stdout. A non-zero exit, a timeout (--timeout, default 5 minutes), or output that isn’t JSON records that example with an error, and the other examples still run.
experiment get. --evaluator limits scoring to the named evaluator rules. The command exits non-zero only when the experiment can’t be created, recorded, or closed. Examples whose command failed are counted in error_count.
experiment compare compares a candidate experiment with a baseline on the same dataset. It reports each feedback score, total cost, p50 and p99 latency, total tokens, and error rate for both experiments and the change, and lists the examples that got worse: pass_to_fail, score_drop, or new_error. Higher scores are treated as better. --limit caps the listed examples (default 20); regression_count is always the full count.
Manage insights
insights commands create, run, and read Insights configurations and their jobs, which group an agent environment’s traces into categories that show usage patterns and where the agent fails. Select the environment with --project or LANGSMITH_PROJECT, set to its tracer_session_name, or with --project-id, set to its session_id.
On LangSmith Cloud, and on self-hosted installations that run continuous Insights, a configuration is an insight that categorizes new traces as they arrive. Each job builds or refreshes its categories. On other self-hosted installations, each job produces a batch report.
insights create, insights run, and insights config require LangSmith CLI v0.2.60 or later.nameandsummary_prompt: Required. The summary prompt is a Mustache template and must reference at least one of{{run.inputs}},{{run.outputs}},{{run.error}},{{run.feedback}}, or{{all_thread_messages}}. The CLI does not support auto mode, so state what Insights should look for in this prompt.last_n_hours, orstart_timeandend_time: The time range to sample traces from. Use one form, not both.model:openai(default) oranthropic. To pick specific models, setcluster_modelandsummary_modeltogether, each toopenai,anthropic, or a model configuration UUID. Display names are not accepted.schedule_cron: A cron expression for a recurring batch report. The first job starts immediately, and later jobs follow the schedule. Omit it for a one-time report. With continuous Insights, scheduled jobs do not run.
filter, sample, hierarchy, partitions, attribute_schemas, and description. Unknown fields cause an error.
insights create saves the file as a job configuration and starts its first job. Jobs run asynchronously and incur model costs. With continuous Insights, the insight also incurs model costs for each conversation it categorizes. The workspace needs secrets for the selected models. Pass --wait to poll until the job succeeds or fails, for up to 30 minutes. Pass --config - to read the file from stdin.
With continuous Insights, the insight chooses its own sampling rate. The CLI cannot set the rate or Slack updates. Use the UI instead.
insights run starts a new job from a saved configuration without changing the configuration. With continuous Insights, the job refreshes the insight’s categories:
insights list returns jobs with their status and category counts. insights get adds the executive summary, highlighted traces, and per-category statistics:
insights config update replaces a configuration’s name and analysis settings from a JSON file in the same format. It does not start a job. With continuous Insights, the insight applies the new settings to conversations it analyzes from then on. Omit description or schedule_cron to keep the current value, or set schedule_cron to null to stop the schedule. insights config delete removes the configuration and every job it produced. With continuous Insights, it also stops categorizing new traces.
Manage sandboxes
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.Trace an MCP server
Requires LangSmith CLI
v0.6.0 or later.langsmith mcp proxy traces each tool call an MCP server handles, with no changes to the server. Register the proxy with your agent in place of the server. The agent talks to the proxy over stdio, and the proxy starts the server, or forwards to a remote server with --url, and passes MCP messages through unchanged. Each tools/call becomes a tool run with its arguments and result in --project (default: LANGSMITH_PROJECT, then default).
--header values go only to --url, never to LangSmith, and LangSmith credentials never go to --url. --url must use HTTPS unless the host is localhost, and redirects to another host are refused. Tracing never blocks the server: without LangSmith credentials, the proxy warns on stderr and runs the server untraced.
Manage custom apps
langsmith apps commands scaffold, run locally, and publish custom apps, UIs that run inside LangSmith and call the LangSmith API.
See CLI reference for the full command list.
Hash a recovery password
Requires LangSmith CLI
v0.5.1 or later.pbkdf2_sha256$<iterations>$<salt>$<hash>. No login or API key is required.
For scripted use, pipe the password on stdin instead:
Call the LangSmith API directly
Theapi 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.
--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.
Filter flags
Mosttrace and run commands share these filters:
Detail flags — control which fields are included in the response:
Connect these docs to your agent of choice via MCP for real-time answers.

