Skip to main content

LangChain

LangDB integrates seamlessly with popular libraries like LangChain, providing tracing support to capture detailed logs for workflows. Below is a complete example of using LangChain with LangDB.

Step 1: Install LangChain

pip install langchain langchain-openai

Step 2: Add LangDB to your Code

from langchain_openai import ChatOpenAI

api_base = "https://api.us-east-1.langdb.ai"
api_key = "xxxx" # LangDB API Key
default_headers = {
"x-project-id": "xxxxx", ### LangDB Project ID
}
llm = ChatOpenAI(
model_name='gpt-4o' ,
temperature=0.3,
openai_api_base=api_base,
default_headers=default_headers,
disable_streaming=True )

# Your LangChain Code here

Check out full examples in the samples.