LangSmith helps you debug, evaluate, and monitor your language models and intelligent agents. Works with any LLM application, including native integrations with LangChain.
What is LangSmith SDK?
LangSmith SDK is a client library that connects your LLM applications to the LangSmith platform for observability, evaluation, and monitoring. Available for both Python and TypeScript, the SDK provides a lightweight way to trace your application’s execution, evaluate model performance, and manage datasets. Whether you’re building with LangChain, using OpenAI directly, or working with any other LLM framework, LangSmith SDK helps you understand what’s happening inside your application.Key features
Tracing and observability
Automatically capture detailed traces of your LLM calls, chains, and agents with support for nested runs and streaming.
Evaluation framework
Evaluate model performance with custom evaluators, built-in metrics, and dataset-based testing.
Dataset management
Create, version, and manage test datasets from production runs or custom examples.
Native SDK wrappers
Drop-in wrappers for OpenAI, Anthropic, and Gemini SDKs that add tracing with zero code changes.
Test integrations
Integrate with Jest, Vitest, and Pytest to trace and evaluate your test suites.
Prompt caching
Cache and optimize prompt executions for faster iterations and reduced costs.
Data privacy
Anonymize sensitive data in traces with built-in PII detection and redaction.
OpenTelemetry support
Export traces using OpenTelemetry for integration with existing observability stacks.
How it works
LangSmith SDK captures execution traces by wrapping your code with decorators (Python) or wrapper functions (TypeScript). Each trace represents a “run” with inputs, outputs, timing, and metadata.Use cases
Debug LLM applications
Debug LLM applications
See exactly what’s happening in your application with detailed traces showing inputs, outputs, latency, and token usage for every LLM call.
Evaluate model performance
Evaluate model performance
Run evaluations on datasets to measure accuracy, hallucination rates, and custom metrics across different prompts and models.
Monitor production systems
Monitor production systems
Track usage, latency, and errors in production with automatic tracing and real-time monitoring.
Optimize prompts
Optimize prompts
Compare different prompt variations side-by-side and measure their impact on output quality.
Build test suites
Build test suites
Create regression tests from production examples and integrate with your existing test framework.
Quick example
Here’s how simple it is to start tracing your OpenAI calls:Get started
Installation
Install the SDK for Python or TypeScript
Quickstart
Get tracing in 5 minutes
Core concepts
Learn about tracing, evaluation, and datasets
API reference
Explore the complete API
Community and support
- Documentation: docs.smith.langchain.com
- GitHub: langchain-ai/langsmith-sdk
- Cookbook: langsmith-cookbook
- LangChain: Works seamlessly with LangChain Python and LangChain JS
LangSmith SDK is developed and maintained by LangChain, the company behind the LangChain framework.