Skip to main content
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 human-readable tables by default, with a --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

To upgrade at any time:
Use the --dry-run flag to preview the update without installing.
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 operate on the backing trace storage. 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.
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:
In headless environments, pass --no-browser and open the printed URL manually:
To manage saved profiles:
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:
Optionally, set the agent environment to query by default using its tracer_session_name:
If you’re using LangSmith self-hosted, also set the endpoint:
Or, pass them as flags per command:

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.
Requires LangSmith CLI 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.
Pass your instance’s base URL. The CLI reads the deployment’s authorization server metadata to find the OAuth endpoints, so 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:
LANGSMITH_ENDPOINT takes precedence over a profile’s api_url. If it is set in your shell, every profile you select resolves to that endpoint — a common cause of commands unexpectedly reaching LangSmith Cloud while a self-hosted profile is active. Unset it when working with profiles, or pass --api-url explicitly.

Quickstart

The following commands cover the core resource types:

Search with AI

AI search finds runs, traces, and threads by a natural-language description of their conversations. 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.
Each server-sent event prints as a JSON patch, and --max-items counts events, not matched runs, traces, or threads. Pass a nonempty description of at most 2,000 UTF-8 bytes. To combine the description with structured conditions using AND, add --filter for runs and threads, or --trace-filter and --tree-filter for traces. 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:
JSON --format json to pipe, script, or feed output to an agent:
Write to file -o <path>:

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 legacy project 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.

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.

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.

View experiments

experiment list shows evaluation experiments. Use project list for the trace-storage destinations associated with agent environments.

Manage insights

insights commands create, run, and read Insights reports, which group an agent environment’s traces into categories to surface usage patterns and failure modes. Every insights command needs --project, --project-id, or the LANGSMITH_PROJECT environment variable.
insights create, insights run, and insights config require LangSmith CLI v0.2.60 or later.
To create a report, define it in a JSON file:
  • name and summary_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 the report should look for in this prompt.
  • last_n_hours, or start_time and end_time: The time range to sample traces from. Use one form, not both.
  • model: openai (default) or anthropic. To pick specific models, set cluster_model and summary_model together, each to openai, anthropic, or a model configuration UUID. Display names are not accepted.
  • schedule_cron: A cron expression for a recurring report. The first job starts immediately, and later jobs follow the schedule. Omit it for a one-time report.
The file also accepts filter, sample, hierarchy, partitions, attribute_schemas, and description. Unknown fields cause an error. insights create saves the file as a job configuration and starts the first report. Reports run asynchronously and incur model costs. The workspace needs secrets for the selected models. Pass --wait to poll until the report succeeds or fails, for up to 30 minutes. Pass --config - to read the file from stdin.
insights run starts a new report from a saved configuration without changing the configuration or its schedule:
insights list returns reports 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 report. 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 report it produced.

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.

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.

Call the LangSmith API directly

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.
Key flags: --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

Most trace and run commands share these filters: Detail flags — control which fields are included in the response: