What is LangSmith?
LangSmith is an all-in-one platform for building production-grade LLM applications. Developed by the LangChain team, it provides comprehensive tools for tracing, debugging, evaluating, and monitoring your AI workflowsβbridging the gap between prototype and production.
"LangSmith acts as a detective for your LLM appsβrecording every step, revealing the decision-making process, and helping you quickly pinpoint and fix issues."
Tracing
Full execution logs
Debugging
Find root causes
Evaluation
LLM-as-a-judge
Monitoring
Production insights
Core Features
Tracing
LangSmith records every operation in your LLM chainβprompt inputs, tool calls, memory reads, and model outputs. Traces reveal the internal decision-making process, helping you understand why the model chose specific actions.
Debugging
When something goes wrong, LangSmith helps pinpoint the exact step where failures occur. Answer questions like: "Why did the agent loop infinitely?" or "Which tool returned bad data?"
Evaluation
Test your LLM outputs against curated datasets using built-in or custom evaluators. LangSmith supports LLM-as-a-judge for assessing quality, accuracy, and coherence automatically.
Production Monitoring
Real-time dashboards for monitoring latency, token usage, costs, and errors in production. Set up alerts and track trends to ensure your LLM app stays healthy.
Quick Start
Getting started with LangSmith is simple. Set your API key and traces are automatically captured:
# 1. Install LangSmith
pip install langsmith
# 2. Set environment variables
export LANGCHAIN_TRACING_V2="true"
export LANGCHAIN_API_KEY="your-langsmith-api-key"
export LANGCHAIN_PROJECT="my-project"
# 3. Run your LangChain code - traces are automatic!
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4")
response = llm.invoke("Hello, how are you?")
print(response.content)
# View traces at: https://smith.langchain.com
What You'll See in LangSmith Dashboard
π Trace: ChatOpenAI
βββ Input: "Hello, how are you?"
βββ Output: "I'm doing well, thank you! How can I help you today?"
βββ Model: gpt-4
βββ Tokens: 25 (prompt: 12, completion: 13)
βββ Latency: 1.2s
βββ Cost: $0.0015
Custom Tracing with @traceable
Use the @traceable decorator to trace
any Python function:
from langsmith import traceable
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4")
@traceable(name="process_query")
def process_user_query(query: str) -> str:
"""Process a user query with context."""
# This will appear as a child span
context = fetch_context(query)
# LLM call is automatically traced
prompt = f"Context: {context}\n\nQuestion: {query}"
response = llm.invoke(prompt)
return response.content
@traceable(name="fetch_context")
def fetch_context(query: str) -> str:
# Simulated database lookup
return "Relevant context from database..."
# Run it
result = process_user_query("What is LangSmith?")
print(result)
Trace Hierarchy in LangSmith
π process_query (2.1s) βββ π¦ fetch_context (0.05s) β βββ Input: "What is LangSmith?" β βββ Output: "Relevant context from database..." β βββ π€ ChatOpenAI (2.0s) βββ Input: "Context: Relevant context..." βββ Output: "LangSmith is an observability platform..." βββ Tokens: 156 βββ Cost: $0.0089
Evaluation Example
Create a dataset and run evaluations to test your LLM's quality:
from langsmith import Client
from langsmith.evaluation import evaluate
client = Client()
# Create a dataset
dataset = client.create_dataset("qa-examples")
client.create_examples(
inputs=[
{"question": "What is Python?"},
{"question": "What is JavaScript?"},
],
outputs=[
{"answer": "A programming language"},
{"answer": "A scripting language"},
],
dataset_id=dataset.id,
)
# Define your target function
def answer_question(inputs: dict) -> dict:
response = llm.invoke(inputs["question"])
return {"answer": response.content}
# Run evaluation
results = evaluate(
answer_question,
data="qa-examples",
evaluators=["correctness", "helpfulness"],
)
print(results)
LangSmith vs LangFuse
| Aspect | LangSmith | LangFuse |
|---|---|---|
| License | Closed-source (SaaS) | Open-source (MIT) |
| Self-Hosting | Enterprise only | Free for all |
| LangChain Integration | Deep native integration | Good integration |
| Evaluation Tools | Built-in LLM-as-judge | Model-based evals |
| Free Tier | 5,000 traces/month | 50,000 observations/month |
| Best For | LangChain/LangGraph users | Mixed stack, self-hosting needs |
π‘ Tip: LangSmith is ideal if you're already using LangChain. Choose LangFuse for self-hosted or multi-framework setups.
Pricing
Developer
Free
- 1 user
- 5,000 traces/month
- 14-day retention
Plus
$39/user/month
- Up to 10 users
- 10,000 traces/user
- Email support
Enterprise
Custom
- Unlimited users
- Self-hosted option
- SSO, SLA, dedicated support
Key Metrics to Track
Latency
P50, P95, P99 response times
Cost
$ per trace, per user
Tokens
Input / Output per call
Errors
Failure rate, error types