The `langchainplus-sdk` is the official Python client library designed to connect to the LangSmith LLM Tracing and Evaluation Platform. LangSmith is a unified developer platform that helps teams debug, evaluate, and monitor language models and intelligent agents. This SDK facilitates logging traces, creating datasets, and evaluating runs, offering seamless integration with the LangChain framework while also supporting standalone use with other LLM applications. The current version is 0.0.20, with updates to the underlying LangSmith platform being more frequent.
pip install langchainplus-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `LangChainPlusClient` and interact with the LangSmith platform by creating a dataset and an example. It highlights the use of environment variables for configuration, which is the recommended way for tracing. Replace 'YOUR_LANGCHAINPLUS_API_KEY' with your actual LangSmith API key.
Be aware that `langchainplus-sdk` is the correct PyPI package for the LangSmith Python client. Refer to LangSmith documentation for the most up-to-date usage patterns.
Monitor official LangSmith documentation for updates to the `RunTree` API when logging traces outside of LangChain. Decouple your core logic from `RunTree` where possible to minimize refactoring needs.
Always ensure that required environment variables are correctly set and accessible to your application. Double-check API keys and endpoint URLs. Use a `.env` file for local development and secure secrets management in production.
Be aware of potential inaccuracies in token cost reporting, especially for non-streaming LLM calls with caching enabled. Cross-reference LangSmith reports with direct API usage metrics from your LLM provider if cost accuracy is critical. Monitor `langsmith-sdk` GitHub issues for fixes related to token parsing.
Upgrade both `langchainplus-sdk` and `langchain` to their latest versions to ensure compatibility with `pydantic` v2, or if forced to use older versions, explicitly install `pydantic==1.*` before installing other packages. ```python # Recommended: Upgrade all relevant packages pip install --upgrade langchain langchainplus-sdk pydantic # Alternative (if older versions are strictly required): pip install pydantic==1.* # Install pydantic v1 first pip install langchainplus-sdk==0.0.20 # Install the compatible sdk version ```
Set the `LANGCHAIN_API_KEY` environment variable with your LangSmith API key. Also, ensure `LANGCHAIN_TRACING_V2` is set to 'true' and `LANGCHAIN_ENDPOINT` points to the correct LangSmith URL. ```python import os os.environ["LANGCHAIN_API_KEY"] = "YOUR_LANGSMITH_API_KEY" os.environ["LANGCHAIN_TRACING_V2"] = "true" # Enables v2 tracing os.environ["LANGCHAIN_ENDPOINT"] = "https://api.langchain.plus" # Or your self-hosted instance ```
Check the official LangSmith SDK documentation for the correct import path and class name for the client in your installed version. As of current versions, the primary client is typically imported from `langsmith`. ```python # For current versions of the LangSmith SDK: from langsmith import Client # client = Client(...) # Use the imported Client class # If using an older version of langchain and its associated sdk, # you might need to pin the langchainplus-sdk version, e.g.: pip install langchainplus-sdk==0.0.20 ```
No dependency data recorded yet.