What is LangWatch, How to Install and use langwatch

Explore LangWatch, the ultimate platform for monitoring and optimizing LLMs. This guide walks you through installing LangWatch, integrating it with a Python chatbot, and evaluating performance with a dataset for better AI results.

Ashley Goolam

Ashley Goolam

18 July 2025

What is LangWatch, How to Install and use langwatch

Struggling to evaluate and optimize your large language model (LLM) pipelines? Enter LangWatch, a game-changing platform that makes it easy to monitor, evaluate, and fine-tune your custom LLM workflows. In this guide, we’ll dive into what LangWatch is, why it’s awesome, and how to install and use it to supercharge your AI projects. We’ll walk through setting up a simple chatbot, integrating LangWatch, and testing it with a sample question—all while keeping things easy to follow. Let’s get started!

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

What Is LangWatch and Why Should You Care?

LangWatch is your go-to platform for tackling the tricky problem of LLM evaluation. Unlike traditional models with standard metrics like F1 score for classification, BLEU for translation, or ROUGE for summarization, generative LLMs are non-deterministic and tough to pin down. Plus, every company has its own data, fine-tuned models, and custom pipelines, making evaluation a headache. That’s where LangWatch shines!

LangWatch lets you:

Whether you’re building a chatbot, a translation tool, or a custom AI app, LangWatch helps you ensure your LLM delivers top-notch results. Ready to see it in action? Let’s install and use LangWatch!

langwatch official website

Step-by-Step Guide to Install and Use LangWatch

Prerequisites

Before we start, you’ll need:

Step 1: Sign Up for LangWatch

Create an Account:

Get Your API Key:

create an account with langwatch

Step 2: Set Up a Python Project with LangWatch

Let’s create a Python project and integrate LangWatch to track a simple chatbot.

  1. Create a Project Folder:
mkdir langwatch-demo
cd langwatch-demo

2. Set Up a Virtual Environment:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install LangWatch and Dependencies:

pip install langwatch chainlit openai

4. Create the Chatbot Code:

import os
import chainlit as cl
import asyncio
from openai import AsyncClient

openai_client = AsyncClient()  # Assumes OPENAI_API_KEY is set in environment
model_name = "gpt-4o-mini"
settings = {
    "temperature": 0.3,
    "max_tokens": 500,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0,
}

@cl.on_chat_start
async def start():
    cl.user_session.set(
        "message_history",
        [
            {
                "role": "system",
                "content": "You are a helpful assistant that only reply in short tweet-like responses, using lots of emojis."
            }
        ]
    )

async def answer_as(name: str):
    message_history = cl.user_session.get("message_history")
    msg = cl.Message(author=name, content="")
    stream = await openai_client.chat.completions.create(
        model=model_name,
        messages=message_history + [{"role": "user", "content": f"speak as {name}"}],
        stream=True,
        **settings,
    )
    async for part in stream:
        if token := part.choices[0].delta.content or "":
            await msg.stream_token(token)
    message_history.append({"role": "assistant", "content": msg.content})
    await msg.send()

@cl.on_message
async def main(message: cl.Message):
    message_history = cl.user_session.get("message_history")
    message_history.append({"role": "user", "content": message.content})
    await asyncio.gather(answer_as("AI Bites"))

5. Set Your OpenAI API Key:

export OPENAI_API_KEY="your-openai-api-key"  # On Windows: set OPENAI_API_KEY=your-openai-api-key

6. Run the Chatbot:

chainlit run app.py
test chainlit application

Step 3: Integrate LangWatch for Tracking

Now, let’s add LangWatch to track the chatbot’s messages.

  1. Modify app.py for LangWatch:
import os
import chainlit as cl
import asyncio
import langwatch
from openai import AsyncClient

openai_client = AsyncClient()
model_name = "gpt-4o-mini"
settings = {
    "temperature": 0.3,
    "max_tokens": 500,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0,
}

@cl.on_chat_start
async def start():
    cl.user_session.set(
        "message_history",
        [
            {
                "role": "system",
                "content": "You are a helpful assistant that only reply in short tweet-like responses, using lots of emojis."
            }
        ]
    )

async def answer_as(name: str):
    message_history = cl.user_session.get("message_history")
    msg = cl.Message(author=name, content="")
    stream = await openai_client.chat.completions.create(
        model=model_name,
        messages=message_history + [{"role": "user", "content": f"speak as {name}"}],
        stream=True,
        **settings,
    )
    async for part in stream:
        if token := part.choices[0].delta.content or "":
            await msg.stream_token(token)
    message_history.append({"role": "assistant", "content": msg.content})
    await msg.send()

@cl.on_message
@langwatch.trace()
async def main(message: cl.Message):
    message_history = cl.user_session.get("message_history")
    message_history.append({"role": "user", "content": message.content})
    await asyncio.gather(answer_as("AI Bites"))

2. Test the Integration:

chainlit run app.py
langwatch trace message

Step 4: Set Up a Workflow to Evaluate Your Chatbot

Let’s create a dataset and evaluator in LangWatch to assess the chatbot’s performance.

  1. Create a Dataset:
Question Expected Answer
What’s the French word for today? Aujourd’hui

2. Set Up an Evaluator:

workflow structure

3. Run the Evaluator:

run the llm answer match

You should see something like:

pop up result

4. Evaluate the Workflow:

evaluate the entire llm workfolw

Step 5: Optimize Your Workflow

Once your evaluation is complete, let’s optimize the chatbot’s performance.

1. Run Optimization:

start the llm optimization process

2. Check Improvements:

workflow optimization results

Step 6: Optional Local LangWatch Setup

Want to run LangWatch locally for testing with sensitive data? Follow these steps:

  1. Clone the Repository:
git clone https://github.com/langwatch/langwatch.git
cd langwatch

2. Set Up Environment:

cp langwatch/.env.example langwatch/.env

3. Run with Docker:

docker compose up -d --wait --build

4. Access the Dashboard:

Note: The Docker setup is for testing only and not scalable for production. For production, use LangWatch Cloud or Enterprise On-Premises.

Why Use LangWatch?

LangWatch solves the LLM evaluation puzzle by providing a unified platform to monitor, evaluate, and optimize your AI pipelines. Whether you’re tweaking prompts, analyzing performance, or ensuring your chatbot gives accurate answers (like “Aujourd’hui” for “today” in French), LangWatch makes it a breeze. Its integration with Python and tools like Chainlit and OpenAI means you can start tracking and improving your LLM apps in minutes.

For example, our demo chatbot now responds in tweet-like bursts with emojis, and LangWatch helps ensure it’s accurate and optimized. Want to scale up? Add more questions to your dataset or experiment with different LLM models in the evaluator.

Conclusion

There you have it! You’ve learned what LangWatch is, how to install it, and how to use it to monitor and optimize a chatbot. From setting up a Python project to tracking messages and evaluating performance with a dataset, LangWatch empowers you to take control of your LLM pipelines. Our test question—“What’s the French word for today?”—showed how easy it is to track and improve AI responses.

Ready to level up your AI game? Head to app.langwatch.ai, sign up, and start experimenting with LangWatch today.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Explore more

How to Create an MCP Server with the Java SDK

How to Create an MCP Server with the Java SDK

Create a Java MCP Server to share data with AI models using the Java SDK. This guide covers setup, testing with game data, and extending tools for Claude or Cursor integration.

4 August 2025

Apigee vs Kong: Comprehensive Guide to Choosing the Right API Gateway

Apigee vs Kong: Comprehensive Guide to Choosing the Right API Gateway

Choosing the right API gateway can shape your app’s performance, security, and scalability. This guide breaks down Apigee vs Kong—comparing features, use cases, developer experience, and when to use each. Plus, see how Apidog fits in to streamline your API workflow from design to deployment.

1 August 2025

Web Services vs Microservices: What's the Difference

Web Services vs Microservices: What's the Difference

Explore the key differences between web services and microservices. Learn when to use each architecture, real-world examples, and how Apidog simplifies API management across both styles. Get insights and a free tool to streamline your API strategy today!

1 August 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs