# Langtrace

> Open source OpenTelemetry observability for LLM applications

- Category: Evaluation & Production Ops / Observability & LLMOps
- Language: TypeScript
- Licence: Apache-2.0
- Repository: https://github.com/Scale3-Labs/langtrace
- Website: https://www.langtrace.ai
- Canonical page: https://ai-tldr.dev/tools/langtrace/

## In short

Langtrace is an open source observability tool for applications that call LLM APIs, vector databases, and LLM frameworks. You add its SDK to your code, and it captures traces and metrics that let you debug and analyze what your application is doing at runtime. It sits in the Observability & LLMOps category of the Evaluation & Production Ops tools and is open-source, written in TypeScript and licensed Apache-2.0.

## Overview

Langtrace is an open source observability tool for applications that call LLM APIs, vector databases, and LLM frameworks. You add its SDK to your code, and it captures traces and metrics that let you debug and analyze what your application is doing at runtime.

It is built for developers building LLM-powered apps who need to see latency, cost, and usage patterns instead of guessing. The traces follow OpenTelemetry (OTEL) standards, so the data fits into tooling you may already use.

As an LLM observability tool, Langtrace sits between your app and the model or database providers. It automatically captures traces from many vendors and frameworks, and you can run it as a managed cloud service or self-host the whole stack on your own infrastructure.

## What it does

- Built on OpenTelemetry (OTEL) standards for consistent, portable tracing
- Real-time monitoring of LLM API calls, vector database operations, and framework usage
- Performance insights into latency, cost, and usage patterns
- Automatic trace capture for many LLM providers, frameworks, and vector databases (OpenAI, Anthropic, Langchain, LlamaIndex, Pinecone, ChromaDB, and more)
- TypeScript/JavaScript and Python SDKs
- Self-hosting option via Docker Compose, with no telemetry leaving your servers

## Getting started

Install the SDK for your language, then initialize Langtrace before importing any LLM modules. You can use the managed cloud or self-host the stack.

1. Install the SDK

   Install the Langtrace SDK for TypeScript/JavaScript or Python.

```bash
# TypeScript/JavaScript
npm i @langtrase/typescript-sdk

# Python
pip install langtrace-python-sdk
```

2. Initialize in TypeScript

   Import and initialize Langtrace before any LLM module imports. Pass your API key, or set LANGTRACE_API_KEY as an environment variable and call init() with no arguments.

```ts
import * as Langtrace from '@langtrase/typescript-sdk' // Must precede any llm module imports
Langtrace.init({ api_key: '<your_api_key>' })
```

3. Initialize in Python

   Import langtrace and call init() with your API key, or set LANGTRACE_API_KEY in the environment and call init() with no arguments.

```python
from langtrace_python_sdk import langtrace
langtrace.init(api_key='<your_api_key>')
```

4. Self-host with Docker (optional)

   To run Langtrace locally you need the Next.js app, a Postgres database, and a Clickhouse database. With Docker and Docker Compose installed, start the stack and open http://localhost:3000.

```bash
docker compose up
```

## When to use it

- Debugging an LLM application by tracing each step of a workflow to see where it slows down or fails
- Tracking the cost and latency of LLM API calls across providers like OpenAI, Anthropic, and Gemini
- Monitoring vector database operations (Pinecone, ChromaDB, Weaviate) alongside model calls in one trace
- Self-hosting observability for LLM apps where data must stay on your own infrastructure
