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

Install

To upgrade at any time:
Use the --dry-run flag to preview the update without installing.

Authenticate

langsmith login and langsmith profile commands require LangSmith CLI v0.2.26 or later. The recommended local setup is to authenticate with OAuth:
langsmith 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.
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 a default project for queries:
If you’re using LangSmith self-hosted or hybrid, also set the endpoint:
Or, pass them as flags per command:

Quickstart

The following commands cover the core resource types:

Output formats

Default JSON to stdout — easy to pipe, script, or feed to an agent:
Pretty tables --format pretty for human-readable output:
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 projects

Returns up to 20 projects by default, sorted by most recent activity. Lists tracing projects only. (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 a live project). 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, not tracing projects. (Use project list to list tracing projects.)

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.

Filter flags

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