How langchain-ai/langsmith-python works
LangSmith’s Python SDK records and manages traces from LLM applications, sends them to the LangSmith platform, and supports follow-on dataset and evaluation workflows. The graph also preserves documented tracing integrations and the sandbox API. The README establishes the main workflow; source-index references and excerpts support the client, model, and transport layers. Some capability modules were not sampled, so their internal calls are not asserted.
Main entry points: client.py API client · _base_client.py HTTP API layer · run_helpers.py Trace decorator · run_trees.py Run tree
Components 24
Tracing
- Trace decorator
src/langsmith/run_helpers.py - Run tree
src/langsmith/run_trees.py - Trace client
src/langsmith/client.py - Trace schemas
src/langsmith/schemas.py - Trace addressing
src/langsmith/address.py
Platform API
- API client
src/langsmith/client.py - API resources
src/langsmith/resources - Prompt webhooks
src/langsmith/resources/prompt_webhooks.py - Sandbox clients
src/langsmith/sandbox/_client.py
Evaluation
- Datasets and runs
src/langsmith/resources/datasets/datasets.py - Evaluation runners
src/langsmith/evaluation - Online evaluators
src/langsmith/resources/online_evaluators.py
Integrations
- LLM wrappers
src/langsmith/wrappers - Agent integrations
src/langsmith/integrations - OTel exporter
src/langsmith/_internal/otel/_otel_exporter.py
SDK Runtime
- HTTP API layer
src/langsmith/_base_client.py - HTTP backend
src/langsmith/_httpx.py - Model serialization
src/langsmith/_models.py - Request types
src/langsmith/_types.py - Compatibility utilities
src/langsmith/_compat.py - Run identifiers
src/langsmith/uuid.py
Other components
- Application developer
- LLM application
- LangSmith platform
Connections 23
- Application developer → LLM application: runs
- LLM application → LLM wrappers: wraps LLM calls
- LLM application → Trace decorator: decorates functions
- Trace decorator → Run tree: manages traces
src/langsmith/run_helpers.py - Run tree → Trace client: posts runs
- Trace client → API client: sends traces
src/langsmith/client.py - API client → LangSmith platform: calls API
- API client → HTTP API layer: uses HTTP layer
src/langsmith/client.py - HTTP API layer → HTTP backend: uses backend
src/langsmith/_base_client.py - HTTP API layer → Model serialization: serializes responses
src/langsmith/_base_client.py - HTTP API layer → Request types: uses request types
src/langsmith/_base_client.py - Model serialization → Compatibility utilities: uses compatibility helpers
src/langsmith/_models.py - Trace client → Trace schemas: uses schemas
src/langsmith/client.py - Trace client → Trace addressing: resolves trace projects
src/langsmith/client.py - Trace client → Run identifiers: uses identifiers
src/langsmith/client.py - API client → API resources: exposes resources
src/langsmith/client.py - API client → Prompt webhooks: manages webhooks
- API client → Sandbox clients: manages sandboxes
src/langsmith/sandbox/_client.py - API client → Datasets and runs: creates datasets
src/langsmith/client.py - Datasets and runs → Evaluation runners: feeds evaluation
- API client → Online evaluators: manages evaluators
src/langsmith/client.py - Agent integrations → Trace decorator: instruments agents
src/langsmith/integrations/claude_agent_sdk/_client.py - OTel exporter → LangSmith platform: exports telemetry