Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
"group": "Additional resources",
"pages": [
"langsmith/polly",
"langsmith/langsmith-cli",
"langsmith/skills",
{
"group": "Data management",
"pages": [
Expand Down Expand Up @@ -340,8 +342,6 @@
"langsmith/export-traces",
"langsmith/compare-traces",
"langsmith/share-trace",
"langsmith/langsmith-fetch",
"langsmith/langsmith-mcp-server",
"langsmith/platform-logs",
"langsmith/data-export"
]
Expand Down Expand Up @@ -1737,6 +1737,14 @@
"source": "/docs",
"destination": "/"
},
{
"source": "/langsmith/langsmith-fetch",
"destination": "/langsmith/langsmith-cli"
},
{
"source": "/langsmith/langsmith-mcp-server",
"destination": "/langsmith/langsmith-cli"
},
{
"source": "/langsmith/api-v1-v2-overview",
"destination": "/langsmith/trace-with-api"
Expand Down
165 changes: 165 additions & 0 deletions src/langsmith/langsmith-cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
title: LangSmith CLI
sidebarTitle: LangSmith CLI
description: 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.
Comment thread
Palashio marked this conversation as resolved.

<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

Choose any method below.
Comment thread
Palashio marked this conversation as resolved.
Outdated

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

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

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

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

## Authentication

Set your API key as an environment variable:
Comment thread
Palashio marked this conversation as resolved.
Outdated

```bash
export LANGSMITH_API_KEY="lsv2_..."
```

Optional defaults:

```bash
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
langsmith --api-key lsv2_... trace list --project my-app
```

## Quickstart

Common tasks to get oriented:
Comment thread
Palashio marked this conversation as resolved.
Outdated

```bash
# 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
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.

<AccordionGroup>
Comment thread
Palashio marked this conversation as resolved.
Outdated
<Accordion title="project — list tracing projects" icon="folders">

```bash
langsmith project list # default limit: 20
langsmith project list --name-contains chatbot
langsmith --format pretty project list
```
</Accordion>

<Accordion title="trace — query and export traces" icon="route">

```bash
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
```
</Accordion>

<Accordion title="run — query individual runs" icon="list-details">

```bash
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
```
</Accordion>

<Accordion title="thread — query conversation threads" icon="messages">

```bash
langsmith thread list --project my-chatbot --last-n-minutes 120
langsmith thread get <thread-id> --project my-chatbot --full
```
</Accordion>

<Accordion title="dataset — manage evaluation datasets" icon="database">

```bash
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
```
</Accordion>

<Accordion title="evaluator — manage evaluators" icon="scale">

```bash
langsmith evaluator list
langsmith evaluator upload evals.py --name accuracy --function check_accuracy --dataset my-eval-set
langsmith evaluator delete accuracy --yes
```
</Accordion>

<Accordion title="experiment — results and summaries" icon="chart-bar">

```bash
langsmith experiment list --dataset my-eval-set
langsmith experiment get my-experiment-2024-01-15
```
</Accordion>
</AccordionGroup>


Loading