# LangChain overview for Node.js

> Source: <https://dev.to/zsevic/langchain-overview-for-nodejs-54en>
> Published: 2026-06-15 20:43:14+00:00

[LangChain.js](https://docs.langchain.com/oss/javascript/langchain/overview) is a framework for LLM applications in TypeScript and Node.js. It standardizes how you wire prompts, models, tools, document loaders, embeddings, and retrievers into reusable pipelines and agents.

| Project | Role |
|---|---|
|

`createAgent`

, loaders, retrieversUse Deep Agents for complex multi-step tasks out of the box. Use LangChain's `createAgent`

when you want a minimal harness you compose with middleware. Reach for LangGraph when you need custom stateful workflows, branching, or fine-grained control over the agent loop.

Install the core packages first ([install guide](https://docs.langchain.com/oss/javascript/langchain/install)):

```
npm i langchain @langchain/core @langchain/openai zod
```

Provider-specific integrations live in separate packages:

`langchain`

- `createAgent`

, `tool`

, and high-level chain helpers`zod`

- tool input schemas when defining tools with `tool()`

`@langchain/core`

- prompts, output parsers, Runnable interface, LCEL`@langchain/openai`

- `ChatOpenAI`

, `OpenAIEmbeddings`

`@langchain/textsplitters`

- document chunking (used in the For raw API access, see the [Chat Completions](https://sevic.dev/notes/chatgpt-api-nodejs/) and [OpenAI Responses API](https://sevic.dev/notes/llm-integration-openai-responses-api/) posts. For provider-agnostic text and agents, see the [Vercel AI SDK](https://sevic.dev/notes/llm-integration-vercel-ai-sdk/) and [OpenAI Agents SDK](https://sevic.dev/notes/ai-agents-openai-sdk/) posts.

| Tool | Best for |
|---|---|
Raw `openai` package |
Minimal calls, full control, least abstraction |
|

`generateText`

, streaming, embeddings, tool loops`createAgent`

, swappable vector storesReach for LangChain when RAG or multi-step LLM pipelines grow beyond a few manual API calls.

`langchain`

, `@langchain/core`

, `@langchain/openai`

, and `zod`

installed`OPENAI_API_KEY`

set in the environment**Document** - a chunk of text with optional metadata. Loaders produce `Document`

instances; splitters break long sources into retrieval-friendly pieces.

``` js
import { Document } from '@langchain/core/documents';

const doc = new Document({
  pageContent: 'LangChain helps compose LLM pipelines.',
  metadata: { source: 'intro' }
});
```

**Runnable** - any component with `.invoke()`

, `.stream()`

, or `.batch()`

. Prompts, models, parsers, and composed chains are all Runnables.

**LCEL (LangChain Expression Language)** - chain Runnables with `.pipe()`

. Data flows left to right: prompt → model → parser. The same `.invoke()`

, `.stream()`

, and `.batch()`

interface applies to every Runnable in the chain.

``` js
import { ChatPromptTemplate } from '@langchain/core/prompts';
import { StringOutputParser } from '@langchain/core/output_parsers';
import { ChatOpenAI } from '@langchain/openai';

const prompt = ChatPromptTemplate.fromMessages([
  ['system', 'Answer in one sentence.'],
  ['human', '{question}']
]);

const model = new ChatOpenAI({ model: 'gpt-5.5' });
const chain = prompt.pipe(model).pipe(new StringOutputParser());

const answer = await chain.invoke({ question: 'What is LangChain?' });
console.log(answer);
```

**Agents** - LangChain's current high-level agent API is [ createAgent](https://docs.langchain.com/oss/javascript/langchain/agents). Pass a model string or chat model, optional tools (with

`zod`

schemas), and an optional checkpointer for conversation memory (`@langchain/langgraph`

):

``` js
import { createAgent } from 'langchain';

const agent = createAgent({
  model: 'gpt-5.5',
  tools: []
});

const result = await agent.invoke({
  messages: [{ role: 'user', content: 'What is LangChain?' }]
});
```

`@langchain/langgraph`

`thread_id`

; long-term memory via `createAgent`

with tools and middleware; for production agents you may also prefer the `LANGSMITH_TRACING=true`

); optional The same LCEL chain supports streaming and batch invocation:

``` js
for await (const chunk of await chain.stream({ question: 'What is LCEL?' })) {
  process.stdout.write(chunk);
}

const answers = await chain.batch([
  { question: 'What is a Runnable?' },
  { question: 'What is a retriever?' }
]);
```

Runnable LCEL scripts for this post live in the `langchain-overview-nodejs-demo`

folder. Get access via [code demos](https://sevic.dev/demos).
