Skip to main content

Prerequisites

  • Python 3.11 or higher
  • A LangSmith API key (starts with lsv2_pt_...)
  • A LangSmith project with existing traces

Installation

Configure the SDK

Initialize the SDK with your LangSmith credentials and (optionally) a Trajectory API key for uploading:

Individual Import

List conversations, pick the ones you want, and import them:
This fetches the full run tree for each conversation, extracts messages, and builds Trajectory objects. You can also pass IDs directly if you already know which conversations you want:

Bulk Import

Import all conversations from a project at once:
You can also scope the export to a time window:
Bulk import discovers conversations in your project, triggers a LangSmith export, and parses the result. See Bulk Export for details and how to find your workspace ID.

Upload

After importing (either way), upload trajectories to the Trajectory platform:
trajectory_api_key must be set in tj.init() (or via the TRAJECTORY_API_KEY env var) for upload to work.

Save to Disk

If you prefer to save locally instead of uploading:
Each Trajectory is written as a JSON file named by conversation ID.

Next Steps

Core Concepts

Learn what Trajectories, Steps, and Messages represent.

Bulk Export

Export all conversations from a project at once.

Bring Your Own Data

Build trajectories without a provider — from CSV, JSONL, OpenAI, Anthropic, etc.

Telemetry Events

Push product telemetry from your app into Trajectory.

Linking Events to Trajectories

Correlate uploaded trajectories with telemetry via trace_id.

API Reference

Full function signatures and parameters.