LangSmith SDK
LangSmith SDK is the official Python and JavaScript client for the LangSmith platform, enabling debugging, evaluation, and monitoring of LLM applications. It integrates natively with LangChain and works with any LLM app, helping developers trace and improve model performance.
✨ Key features
- Python and JavaScript/TypeScript SDKs
- Native integration with LangChain
- Automatic tracing via traceable decorator/wrapper
- OpenAI client wrapper for easy tracing
- Environment-based configuration for API keys
- Works with any LLM application
🎯 Use cases
- Trace LLM calls to debug and monitor performance
- Evaluate model outputs in development
- Monitor production LLM applications
- Integrate tracing into LangChain apps
📦 Installation
🧰 Requirements: Requires Python or Node.js environment, a LangSmith account with API key (LANGSMITH_API_KEY), and workspace ID for org-scoped keys.
Python
pip install -U langsmith
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY=ls_...
export LANGSMITH_WORKSPACE_ID=<your-workspace-id> # Required for org-scoped keys
JavaScript/TypeScript
pnpm add langsmith
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY=ls_...
export LANGSMITH_WORKSPACE_ID=<your-workspace-id> # Required for org-scoped keys
🚀 Usage
Python
import openai
from langsmith import traceable
from langsmith.wrappers import wrap_openai
client = wrap_openai(openai.Client())
client.chat.completions.create(
messages=[{"role": "user", "content": "Hello, world"}],
model="gpt-3.5-turbo"
)
JavaScript
import { OpenAI } from "openai";
import { traceable } from "langsmith/traceable";
import { wrapOpenAI } from "langsmith/wrappers";
const client = wrapOpenAI(new OpenAI());
await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{ content: "Hi there!", role: "user" }],
});
❓ FAQ
What languages are supported?
The SDK supports Python and JavaScript/TypeScript.
How do I enable tracing?
Set the environment variable LANGSMITH_TRACING=true and provide your API key via LANGSMITH_API_KEY.
Does it work with LangChain?
Yes, it has native integration with LangChain Python and LangChain JS.
Where can I find more documentation?
See the LangSmith Documentation at https://docs.smith.langchain.com/.
📊 Repository
🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.