> ## 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.5

> [!WARNING]
>
> `@braintrust/langchain-js` is deprecated as of v0.2.5 and will receive no further updates. Use [auto-instrumentation](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md#auto-instrumentation-typescript) to trace LangChain calls without changing your application code, or import `BraintrustLangChainCallbackHandler` from `braintrust` and attach it to each call yourself. See the [LangChain integration guide](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md) for setup examples. `setGlobalHandler` has no direct replacement.

The `@braintrust/langchain-js` package provides 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. **Deprecated**, with no direct replacement. Use auto-instrumentation or pass the callback handler explicitly.

### 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.