Skip to main content
LangSmith Fetch is a command-line interface (CLI) tool for retrieving trace data (runs, traces, and threads) from your LangSmith projects. It allows you to use LangSmith’s tracing and debugging features directly in your terminal and development workflows. You can use LangSmith Fetch for the following use cases:
  • Immediate debugging: Fetch the most recent trace of a failed or unexpected deployment run with a single command.
  • Bulk export for analysis: Export large numbers of traces or entire conversation threads to JSON files for offline analysis, building evaluation datasets, or regression tests.
  • Terminal-based workflows: Integrate trace data into your existing tools; for example, piping output to Unix utilities like jq, or feeding traces into an AI coding assistant for automated analysis.

Installation

Setup

  1. Set your LangSmith API key:
  2. Set your project name:
    The CLI will automatically fetch traces or threads in LANGSMITH_PROJECT. Replace your-project-name with the name of your LangSmith project (if it doesn’t exist, it will be created automatically on first use). To find your project UUID, refer to Find project and trace IDs. When you set the LANGSMITH_PROJECT environment variable, langsmith-fetch automatically looks up the project UUID and saves both to ~/.langsmith-cli/config.yaml. By default, you do not need to include the project UUID with langsmith-fetch. However, you can override the configured project by specifying a different project UUID via the --project-uuid CLI flag.
    To fetch a thread, langsmith-fetch requires a project UUID. Therefore, ensure that the LANGSMITH_PROJECT environment variable is set, or specify the --project-uuid <project-id> manually when you run langsmith-fetch thread <thread-id>.
  3. (Optional) Set your LangSmith endpoint if you’re using self-hosted LangSmith:

Use with a coding agent

After you’ve installed and set up langsmith-fetch, use your coding agent to ask questions like the following:
Many agents will use the langsmith-fetch --help command to understand how to use the CLI and complete your request.

Find project and trace IDs

In most cases, you won’t need to find IDs manually (the CLI uses your environment’s project name and latest traces by default). However, if you want to fetch a specific item by ID, you can find the IDs in the LangSmith UI:
  • Project UUID: Each project has a unique ID (UUID). You can find it in the project’s URL or by hovering over ID next to the project’s name. This UUID can be used with the --project-uuid flag on CLI commands
  • Trace ID: Every trace (single execution) has an ID. In the Runs view, click on a specific run to see its Trace ID (copyable from the trace details panel). You can use langsmith-fetch trace <trace-id> to retrieve that exact trace if you have the ID.

Usage

After installation and setup, you can use the langsmith-fetch command to retrieve traces or threads. The general usage is:
LangSmith Fetch provides the following commands to fetch either single items or in bulk:
Traces are fetched chronologically with most recent first.

Options

The commands support additional flags to filter and format the output:

Output formats

The --format option controls how the fetched data is displayed:
  • pretty (default): A human-readable view with rich text formatting for easy inspection in the terminal. This format is great for quick debugging of a single trace or thread. By default:
    Explicitly specify the format:
  • json: Well-formatted JSON output with syntax highlighting. Use this if you want to examine the raw data structure or pipe it into JSON processing tools.
  • raw: Compact JSON with no extra whitespace. This is useful for piping the output to other programs (e.g., using jq or saving directly) without extra formatting.

Fetch a trace or thread

You can fetch a single thread or trace with the ID. The command will output to the terminal by default:
To fetch a thread, langsmith-fetch thread also requires a project UUID. Ensure that the LANGSMITH_PROJECT environment variable is configured, or use the --project-uuid flag to define a thread’s project:
Output from a single trace fetch in default pretty format You can optionally redirect the thread or trace data to a file using the --file option.

Fetch multiple

For bulk fetches of traces or threads, we recommend specifying a target directory path. Each fetched trace or thread will be saved as a separate JSON file in that folder, making it easy to browse or process them later.
You can specify a destination directory for the bulk commands (traces/threads). For example, the following command will save the 10 most recent traces as JSON files in the my-traces-data directory:
If you omit the directory and --limit, the tool will output the results of the most recent, single trace to your terminal. When sending to a directory, files will be named in the following way:
  • Default: Files named by trace ID (e.g., 3b0b15fe-1e3a-4aef-afa8-48df15879cfe.json).
  • Custom pattern: Use --filename-pattern with placeholders:
    • {trace_id}: Trace ID (default: {trace_id}.json).
    • {index} or {idx}: Sequential number starting from 1.
    • Format specs supported: {index:03d} for zero-padded numbers.

Include metadata and feedback

You can include run metadata and any feedback associated with the trace:

Override the configured tracing project

To fetch traces from a different project than the one configured with LANGSMITH_PROJECT, use --project-uuid:
Running this command will just fetch traces from that project, it will not modify the LangSmith project already configured in ~/.langsmith-cli/config.yaml. You may also need to fetch a particular trace in a different project to the configured LANGSMITH_PROJECT. You can do this by including a trace-id and project-id with langsmith-fetch:

Export to files

You can fetch traces or full threads and export to a file:
This command retrieves all threads that have occurred since December 1, 2025, saving each conversation as a JSON file under ./my_threads. This is useful for exporting chat transcripts or building regression tests on multi-turn conversations. You could also use --limit with threads to fetch a specific number of recent threads, and --last-n-minutes works here as well.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.