> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintrust.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain JS Integration

> LangChain JS Integration v0.2.4

The `@braintrust/langchain-js` package provides seamless integration between Braintrust and LangChain.js.

## Installation

```bash npm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
npm install @braintrust/langchain-js
```

```bash pnpm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
pnpm add @braintrust/langchain-js
```

## Quick start

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { BraintrustCallbackHandler } from "@braintrust/langchain-js";
import { ChatOpenAI } from "@langchain/openai";

// Create a callback handler
const handler = new BraintrustCallbackHandler();

// Use with any LangChain model
const llm = new ChatOpenAI({ callbacks: [handler] });
```

## API Reference

### Functions

#### setGlobalHandler

setGlobalHandler function.

### Classes

#### BraintrustCallbackHandler

A Braintrust tracer for LangChain.js that logs LLM calls, chains, and tools.

## Source Code

For the complete source code and additional examples, visit the [Braintrust JavaScript SDK repository](https://github.com/braintrustdata/braintrust-sdk-javascript/tree/main/integrations/langchain-js).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.