A comprehensive Python tool for migrating datasets, experiments, annotation queues, project rules, and prompts between LangSmith instances.
# Clone and install
git clone https://github.com/langchain-ai/langsmith-data-migration-tool.git
cd langsmith-data-migration-tool
uv sync
# Set up environment variables
export LANGSMITH_OLD_API_KEY="your_source_api_key"
export LANGSMITH_NEW_API_KEY="your_destination_api_key"
# Test connections
uv run langsmith-migrator test
# Start migrating datasets
uv run langsmith-migrator datasets
- Dataset Migration: Migrate datasets with examples, attachments, and associated experiments
- Attachment Support: Automatically downloads and re-uploads file attachments (images, documents, etc.) with examples
- Annotation Queue Migration: Transfer annotation queues with their configurations
- Project Rules Migration: Copy tracing project rules between instances
- Prompt Migration: Migrate prompts and their versions
- Interactive CLI: User-friendly command-line interface with improved selection UX
This migration tool does not support migrating trace data between LangSmith instances. The tool is designed specifically for migrating:
- Datasets and their examples (including file attachments)
- Experiments and evaluators
- Annotation queues
- Project rules
- Prompts
For migrating trace data, please use LangSmith's official Bulk Export functionality, which allows you to export traces to external storage systems like S3, BigQuery, or Snowflake.
π Learn more about trace exports: LangSmith Bulk Export Documentation
- Python 3.12 or higher
- uv package manager (recommended) or pip
# Clone the repository
git clone https://github.com/langchain-ai/langsmith-data-migration-tool.git
cd langsmith-data-migration-tool
# Install dependencies and the package
uv sync
# Run the tool using uv
uv run langsmith-migrator --help
# Clone the repository
git clone https://github.com/langchain-ai/langsmith-data-migration-tool.git
cd langsmith-data-migration-tool
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
# Install the package in editable mode
pip install -e .
# Run the tool
langsmith-migrator --help
Set up environment variables for your source and destination LangSmith instances:
export LANGSMITH_OLD_API_KEY="your_source_api_key"
export LANGSMITH_NEW_API_KEY="your_destination_api_key"
# Base URLs (default: https://api.smith.langchain.com)
export LANGSMITH_OLD_BASE_URL="https://your-source-instance.com"
export LANGSMITH_NEW_BASE_URL="https://your-destination-instance.com"
Alternatively, create a .env
file in the project directory:
LANGSMITH_OLD_API_KEY=your_source_api_key
LANGSMITH_NEW_API_KEY=your_destination_api_key
LANGSMITH_OLD_BASE_URL=https://your-source-instance.com
LANGSMITH_NEW_BASE_URL=https://your-destination-instance.com
LANGSMITH_VERIFY_SSL=true
If installed with uv, use:
uv run langsmith-migrator [COMMAND] [OPTIONS]
If installed with pip and activated in virtual environment, use:
langsmith-migrator [COMMAND] [OPTIONS]
You can also run it as a Python module:
python -m langsmith_migrator [COMMAND] [OPTIONS]
# Test connections to both instances
langsmith-migrator test
# Interactive dataset selection
langsmith-migrator datasets
# Migrate all datasets (skip selection UI)
langsmith-migrator datasets --all
# Include related experiments
langsmith-migrator datasets --include-experiments
# Migrate annotation queues
langsmith-migrator queues
# Resume previous migration
langsmith-migrator resume
# Clean up old sessions
langsmith-migrator clean
All commands support the following global options:
--source-key TEXT Source API key (or set LANGSMITH_OLD_API_KEY)
--dest-key TEXT Destination API key (or set LANGSMITH_NEW_API_KEY)
--source-url TEXT Source base URL (or set LANGSMITH_OLD_BASE_URL)
--dest-url TEXT Destination base URL (or set LANGSMITH_NEW_BASE_URL)
--no-ssl Disable SSL certificate verification
--batch-size INTEGER Batch size for operations (default: 100)
--workers INTEGER Number of concurrent workers (default: 4)
--dry-run Run without making changes
--verbose, -v Enable verbose output
If you encounter SSL certificate verification errors with self-hosted instances:
# Option 1: Use the --no-ssl flag
langsmith-migrator --no-ssl datasets
# Option 2: Set the environment variable
export LANGSMITH_VERIFY_SSL=false
langsmith-migrator datasets
When using langsmith-migrator datasets
or langsmith-migrator queues
, you'll see an interactive TUI with:
Keyboard Shortcuts:
ββ
- Navigate through itemsSpace
- Toggle selection on current itema
- Select all visible itemsn
- Clear all selections/
- Focus search boxEnter
- Confirm and proceedEsc
- Cancel and exit
The tool is organized into several specialized classes:
LangsmithMigrator
: Main orchestrator classDatasetMigrator
: Handles dataset and example migrationExperimentMigrator
: Manages experiment migrationAnnotationQueueMigrator
: Handles annotation queue migrationAPIClient
: Wrapper for HTTP requests with error handling
Mode | Description |
---|---|
EXAMPLES |
Migrate dataset metadata and all examples |
EXAMPLES_AND_EXPERIMENTS |
Migrate dataset, examples, experiments, and runs |
DATASET_ONLY |
Migrate only dataset metadata |
Mode | Description |
---|---|
QUEUE_AND_DATASET |
Migrate queue and its associated default dataset |
QUEUE_ONLY |
Migrate only the queue configuration |
If you get command not found: langsmith-migrator
:
Using uv:
# Always prefix with uv run
uv run langsmith-migrator --help
Using pip:
# Make sure virtual environment is activated
source .venv/bin/activate # Unix/macOS
.venv\Scripts\activate # Windows
# Or run as module
python -m langsmith_migrator --help
If you see ModuleNotFoundError: No module named 'langsmith_migrator.__main__'
:
# Reinstall the package
uv sync
# or
pip install -e .
If you encounter import errors:
# Using uv - sync dependencies
uv sync
# Using pip - install from requirements
pip install -r requirements.txt
For self-hosted instances with SSL issues:
# Option 1: Use --no-ssl flag
uv run langsmith-migrator --no-ssl test
# Option 2: Set environment variable
export LANGSMITH_VERIFY_SSL=false
uv run langsmith-migrator test
If connection tests fail:
- Verify API keys are correct
- Check base URLs (should include
https://
) - Ensure network connectivity to both instances
- Try verbose mode for more details:
uv run langsmith-migrator -v test