# LangChain JavaScript setup

```
npm install langchain @langchain/core
```

Requires Node.js 22 or newer. pnpm, yarn, and bun equivalents work the same way (`pnpm add langchain @langchain/core`).

## Provider packages

```
npm install @langchain/openai
npm install @langchain/anthropic
```

Every provider is a separate scoped package under @langchain. The full list is on the JS integrations pages.

## Rules

- Do not import model classes from the bare `langchain` package. They live in `@langchain/openai`, `@langchain/anthropic`, and friends.
- Keep the key in the environment (OPENAI_API_KEY, ANTHROPIC_API_KEY). The classes read it from there by default.
- Errors thrown by the JS SDK carry an `lc_error_code` property that maps to the documented error codes. Log it; it tells you which doc page to read.