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

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 a default project for queries:
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:

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

insights commands create, run, and read Insights reports, which group a project’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: