---
title: '🛠️ LangSmith'
description: 'Integrate with Langsmith to debug and monitor your LLM app'
---

EmbedJs now supports integration with [LangSmith](https://www.langchain.com/langsmith).

To use LangSmith, you need to do the following steps.

1. Have an account on LangSmith and keep the environment variables in handy
2. Set the environment variables in your app so that EmbedJs has context about it.
3. Just use EmbedJs and everything will be logged to LangSmith, so that you can better test and monitor your application.

Let's cover each step in detail.

* First make sure that you have created a LangSmith account and have all the necessary variables handy. LangSmith has a [good documentation](https://docs.smith.langchain.com/) on how to get started with their service.

* Once you have setup the account, we will need the following environment variables

```bash
# Setting environment variable for LangChain Tracing V2 integration.
export LANGCHAIN_TRACING_V2=true

# Setting the API endpoint for LangChain.
export LANGCHAIN_ENDPOINT=https://api.smith.langchain.com

# Replace '<your-api-key>' with your LangChain API key.
export LANGCHAIN_API_KEY=<your-api-key>

# Replace '<your-project>' with your LangChain project name, or it defaults to "default".
export LANGCHAIN_PROJECT=<your-project>  # if not specified, defaults to "default"
```

* Now create an app using EmbedJs and everything will be automatically visible in LangSmith automatically.


```ts
import { RAGApplicationBuilder } from '@llm-tools/embedjs';
import { OpenAiEmbeddings } from '@llm-tools/embedjs-openai';

//Replace this with your OpenAI key
process.env.OPENAI_API_KEY = "sk-xxxx"

//Build a new application
const ragApplication = await new RAGApplicationBuilder()
.setModel(SIMPLE_MODELS.OPENAI_GPT4_O)
.setEmbeddingModel(new OpenAiEmbeddings())
.build();

//Add new documents
ragApplication.addLoader('https://www.forbes.com/profile/elon-musk')
ragApplication.addLoader('https://en.wikipedia.org/wiki/Elon_Musk')

//Query your app
await ragApplication.query('What is the net worth of Elon Musk today?')
```

* Now the entire log for this will be visible in langsmith.

<img src="/images/langsmith.png"/>
