> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-patchr-1773857969-df0cef9.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LangSmith CLI

> Query and manage LangSmith projects, traces, runs, datasets, evaluators, experiments, and threads from the terminal

The LangSmith CLI is a fast, agent-friendly command-line tool for working with your LangSmith data and workflows directly from the terminal. It’s designed for both humans and AI coding agents to list, filter, retrieve, and export data—with predictable JSON output by default and a pretty table mode for humans.

<Callout icon="terminal" color="#504B5F">
  Built for agents and scripts: defaults to JSON, supports clean stdout/stderr separation, and offers `--yes` flags for non-interactive use.
</Callout>

## Installation

Use one of the follow methods for installation:

<CodeGroup>
  ```bash Install script (recommended) theme={null}
  curl -sSL https://raw.githubusercontent.com/langchain-ai/langsmith-cli/main/scripts/install.sh | sh
  ```

  ```bash Install to a custom directory theme={null}
  INSTALL_DIR=$HOME/.local/bin \
    curl -sSL https://raw.githubusercontent.com/langchain-ai/langsmith-cli/main/scripts/install.sh | sh
  ```

  ```bash GitHub Releases theme={null}
  # Download the latest binary for your platform
  # https://github.com/langchain-ai/langsmith-cli/releases
  ```

  ```bash Go install theme={null}
  go install github.com/langchain-ai/langsmith-cli/cmd/langsmith@latest
  ```
</CodeGroup>

## Authentication

Set your [API key](/langsmith/create-account-api-key) as an environment variable:

```bash theme={null}
export LANGSMITH_API_KEY="lsv2_..."
```

Optional defaults:

```bash theme={null}
export LANGSMITH_ENDPOINT="https://api.smith.langchain.com"  # self-hosted/hybrid
export LANGSMITH_PROJECT="my-default-project"                 # default project for queries
```

Or pass them as flags when running commands:

```bash theme={null}
langsmith --api-key lsv2_... trace list --project my-app
```

## Quickstart

The following commands cover the core resource types—projects, traces, runs, datasets, experiments, and threads:

```bash theme={null}
# List tracing projects (sessions)
langsmith project list

# List recent traces in a project
langsmith trace list --project my-app --limit 5

# Get a specific trace with full detail
langsmith trace get <trace-id> --project my-app --full

# List LLM runs with token counts
langsmith run list --project my-app --run-type llm --include-metadata

# Datasets and experiments
langsmith dataset list
langsmith experiment list --dataset my-eval-set

# Conversation threads in a project
langsmith thread list --project my-chatbot
```

## Output formats

* Default: JSON to stdout for easy piping and scripting
* Pretty tables: `--format pretty` for human-readable tables and trees
* Write to file: `-o <path>`

```bash theme={null}
langsmith trace list --project my-app                  # JSON array to stdout
langsmith --format pretty trace list --project my-app  # tables/trees
langsmith trace list --project my-app -o traces.json   # write JSON to file
```

## Commands overview

The CLI groups functionality by resource. Each command supports filters like `--limit`, `--last-n-minutes`, and more.

### project—list tracing projects

```bash theme={null}
langsmith project list                    # default limit: 20
langsmith project list --name-contains chatbot
langsmith --format pretty project list
```

### trace—query and export traces

```bash theme={null}
langsmith trace list --project my-app --limit 50 --last-n-minutes 60
langsmith trace list --project my-app --error --include-metadata
langsmith trace get <trace-id> --project my-app --full
langsmith trace export ./traces --project my-app --limit 20 --full
```

### run—query individual runs

```bash theme={null}
langsmith run list --project my-app --run-type llm
langsmith run list --project my-app --run-type tool --name search
langsmith run get <run-id> --full
langsmith run export llm_calls.jsonl --project my-app --run-type llm --full
```

### thread—query conversation threads

```bash theme={null}
langsmith thread list --project my-chatbot --last-n-minutes 120
langsmith thread get <thread-id> --project my-chatbot --full
```

### dataset—manage evaluation datasets

```bash theme={null}
langsmith dataset list --name-contains eval
langsmith dataset get my-dataset
langsmith dataset create --name my-eval-set --description "QA pairs for v2"
langsmith dataset export my-dataset ./data.json --limit 500
```

### evaluator—manage evaluators

```bash theme={null}
langsmith evaluator list
langsmith evaluator upload evals.py --name accuracy --function check_accuracy --dataset my-eval-set
langsmith evaluator delete accuracy --yes
```

### experiment—results and summaries

```bash theme={null}
langsmith experiment list --dataset my-eval-set
langsmith experiment get my-experiment-2024-01-15
```

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/langsmith-cli.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
