LangSmith Fetch - Minimal CLI for fetching LangSmith threads and traces
Project description
LangSmith Fetch
LangSmith Fetch is CLI for fetching threads or traces from LangSmith projects. It is designed to be easily used by humans or code agents to programmatically fetch LangSmith data for testing and debugging.
🚀 Quickstart
pip install langsmith-fetch
Set your LangSmith API key and project name:
export LANGSMITH_API_KEY=lsv2_...
export LANGSMITH_PROJECT=your-project-name
export LANGSMITH_ENDPOINT=your-langsmith-api-url # setting this if you use self-host langsmith
That's it! The CLI will automatically fetch traces or threads in LANGSMITH_PROJECT.
Fetch recent traces to directory (recommended):
langsmith-fetch traces ./my-traces --limit 10
Fetch specific trace by ID:
langsmith-fetch trace 3b0b15fe-1e3a-4aef-afa8-48df15879cfe
Same commands work for threads:
langsmith-fetch threads ./my-threads --limit 10
langsmith-fetch thread my-thread-id
Include metadata and feedback:
langsmith-fetch traces ./my-traces --limit 10 --include-metadata --include-feedback
For code agents:
Use langsmith-fetch to fetch recent LangSmith traces. Run langsmith-fetch --help for usage details.
Commands
| Command | What it fetches | Output |
|---|---|---|
trace <id> |
Specific trace by ID | stdout or file |
thread <id> |
Specific thread by ID | stdout or file |
traces [dir] |
Recent traces (bulk) | Multiple JSON files in directory (RECOMMENDED) or stdout |
threads [dir] |
Recent threads (bulk) | Multiple JSON files in directory (RECOMMENDED) or stdout |
Flags
| Flag | Applies To | Description | Default |
|---|---|---|---|
--project-uuid <uuid> |
thread, threads, traces |
LangSmith project UUID (overrides config) | From config or env |
-n, --limit <int> |
traces, threads |
Maximum number to fetch | 1 |
--last-n-minutes <int> |
traces, threads |
Only fetch from last N minutes | None |
--since <timestamp> |
traces, threads |
Only fetch since ISO timestamp | None |
--filename-pattern <text> |
traces, threads |
Filename pattern (use {trace_id}, {thread_id}, {index}) |
{trace_id}.json or {thread_id}.json |
--format <type> |
All commands | Output format: pretty, json, or raw |
pretty |
--file <path> |
trace, thread |
Save to file instead of stdout | stdout |
--include-metadata |
traces |
Include run metadata (status, timing, tokens, costs) | Not included |
--include-feedback |
traces |
Include feedback data (requires extra API call) | Not included |
--max-concurrent <int> |
traces, threads |
Concurrent fetches (max 10 recommended) | 5 |
--no-progress |
traces, threads |
Disable progress bar | Progress shown |
Output Formats
pretty(default): Human-readable Rich panels with color and formattingjson: Pretty-printed JSON with syntax highlightingraw: Compact single-line JSON for piping to tools likejq
Concepts
LangSmith organizes data into three levels:
- Runs: Individual LLM calls or tool executions
- Traces: A collection of runs representing a single execution path (one trace contains multiple runs)
- Threads: A collection of traces representing a conversation or session (one thread contains multiple traces)
Configuration
langsmith-fetch requires only LANGSMITH_PROJECT env var. It automatically looks up the Project UUID and saves both to ~/.langsmith-cli/config.yaml.
Finding IDs in LangSmith UI:
Project UUID (automatic lookup via LANGSMITH_PROJECT):
Trace ID (for fetching specific traces):
Thread ID (for fetching specific threads):
Tests
Run the test suite:
# Install with test dependencies
pip install -e ".[test]"
# Or with uv
uv sync --extra test
# Run all tests
pytest tests/
# Run with verbose output
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=langsmith_cli
The test suite includes 71 tests covering:
- All CLI commands (traces, trace, thread, threads, config)
- All output formats (pretty, json, raw)
- Config management and storage
- Project UUID lookup and caching
- API fetching and error handling
- Time filtering and SDK integration
- Edge cases and validation
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langsmith_fetch-0.3.1.tar.gz.
File metadata
- Download URL: langsmith_fetch-0.3.1.tar.gz
- Upload date:
- Size: 5.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c8ad53a17ee1654efdd20b00ca7cf47288373468c66ae4d87f72ab09ca48055
|
|
| MD5 |
48e553e14243a6a88d763608abda837c
|
|
| BLAKE2b-256 |
38ebd21403968c0fac374391b97951dc9025806a38d83e3a723429dae2c1a122
|
File details
Details for the file langsmith_fetch-0.3.1-py3-none-any.whl.
File metadata
- Download URL: langsmith_fetch-0.3.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad98a94521a3723ab861eb374675cf73b1f400ee736190b9dc3e90afeb17b69f
|
|
| MD5 |
79ae9fb1b3c137bc32eea02070e6fdb5
|
|
| BLAKE2b-256 |
c7f47d8727673ade5ad31f70e1ff14ebdd2d2e11d10afe4085de9b9296c4ddb2
|