Prerequisites
Before installing the SDK, you’ll need:- A LangSmith account - sign up here
- A LangSmith API key from your Settings page
Python installation
Python optional dependencies
The SDK supports optional features that require additional packages:TypeScript installation
Install the package
Install the LangSmith SDK using your preferred package manager:The SDK works with Node.js, Deno, and modern browsers.
Set environment variables
Configure your environment with your LangSmith credentials:For EU region users:
TypeScript peer dependencies
Some features require peer dependencies:Configuration options
You can configure the SDK using environment variables or constructor options.Environment variables
Enable or disable tracing globally
Your LangSmith API key (starts with
ls_)The project name where traces will be logged
The LangSmith API endpoint. Use
https://eu.api.smith.langchain.com for EU region.Your workspace ID (required for organization-scoped API keys)
Programmatic configuration
You can also configure the client programmatically:Region support
LangSmith is available in multiple regions:- US (Default)
- EU
Troubleshooting
Import errors
Import errors
If you see import errors, make sure you’ve installed the package and are using the correct Python version (3.10+):
Authentication errors
Authentication errors
If you see “Unauthorized” errors:
- Verify your API key starts with
ls_ - Check that
LANGSMITH_API_KEYis set:echo $LANGSMITH_API_KEY - If using an org-scoped key, ensure
LANGSMITH_WORKSPACE_IDis set - Verify your key hasn’t been revoked in the Settings page
No traces appearing
No traces appearing
If traces aren’t showing up:
- Check that
LANGSMITH_TRACING=trueis set - Verify the project name:
echo $LANGSMITH_PROJECT - Look for error messages in your application logs
- Check the browser console or terminal for SDK errors
- Ensure you’re waiting for async operations to complete
TypeScript type errors
TypeScript type errors
If you see TypeScript errors:
- Ensure you’re using TypeScript 5.0 or higher
- Install the latest version:
npm install langsmith@latest - Clear your node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install
Next steps
Quickstart
Get your first trace in 5 minutes
Tracing concepts
Learn how tracing works
OpenAI integration
Trace OpenAI SDK calls
LangChain integration
Use with LangChain