Skip to main content

Using your self-hosted instance of LangSmith

This guide will walk you through the process of using your self-hosted instance of LangSmith.

Self-Hosted LangSmith Instance Required

This guide assumes you have already deployed a self-hosted LangSmith instance. If you have not, please refer to the kubernetes deployment guide or the docker deployment guide.

Configuring the application you want to use with LangSmith

LangSmith has two APIs: One for interacting with the LangChain Hub/prompts and one for interacting with the backend of the LangSmith application. Each exists at its own URL and in a self-hosted environment are set via the LANGCHAIN_HUB_API_URL and LANGCHAIN_ENDPOINT environment variables, respectively, and have their own separate SDKs.

  1. Once you have deployed your instance, you can access the LangSmith UI at http://<host>.
  2. The backend API will be available at http://<host>/api

To use the LangSmith API, you will need to set the following environment variables in your application:

LANGCHAIN_ENDPOINT=http://<host>/api
LANGCHAIN_HUB_API_URL=http://<host>/api # Only set this if using the legacy langchainhub SDK
LANGCHAIN_API_KEY=foo # Set to a legitimate API key if using OAuth

You can also configure these variables directly in the LangSmith SDK client:

import langsmith

langsmith_client = langsmith.Client(
api_key='<api_key>',
api_url='http://<host>/api',
)

# Deprecated, you can use the Langsmith client for all interactions
import langchainhub

# Deprecated, use langsmith.Client instead
langchainhub.Client(
api_key='<api_key>',
api_url='http://<host>/api'
)

After setting the above, you should be able to run your code and see the results in your self-hosted instance. We recommend running through the quickstart guide to get a feel for how to use LangSmith.

API Reference

To access the API reference, navigate to http://<host>/api/docs in your browser.


Was this page helpful?


You can leave detailed feedback on GitHub.