Détail du package

@langchain/core

langchain-ai8.9mMIT1.1.6

Core LangChain.js abstractions and schemas

llm, ai, gpt3, chain

readme

🦜️🔗 LangChain.js

npm License: MIT Twitter

LangChain is a framework for building LLM-powered applications. It helps you chain together interoperable components and third-party integrations to simplify AI application development — all while future-proofing decisions as the underlying technology evolves.

Documentation: To learn more about LangChain, check out the docs.

If you're looking for more advanced customization or agent orchestration, check out LangGraph.js. our framework for building agents and controllable workflows.

[!NOTE] Looking for the Python version? Check out LangChain.

To help you ship LangChain apps to production faster, check out LangSmith. LangSmith is a unified developer platform for building, testing, and monitoring LLM applications.

⚡️ Quick Install

You can use npm, pnpm, or yarn to install LangChain.js

npm install -S langchain or pnpm install langchain or yarn add langchain

🚀 Why use LangChain?

LangChain helps developers build applications powered by LLMs through a standard interface for agents, models, embeddings, vector stores, and more.

Use LangChain for:

  • Real-time data augmentation. Easily connect LLMs to diverse data sources and external/internal systems, drawing from LangChain’s vast library of integrations with model providers, tools, vector stores, retrievers, and more.
  • Model interoperability. Swap models in and out as your engineering team experiments to find the best choice for your application’s needs. As the industry frontier evolves, adapt quickly — LangChain’s abstractions keep you moving without losing momentum.

📦 LangChain's ecosystem

  • LangSmith - Unified developer platform for building, testing, and monitoring LLM applications. With LangSmith, you can debug poor-performing LLM app runs, evaluate agent trajectories, gain visibility in production, and deploy agents with confidence.
  • LangGraph - Build agents that can reliably handle complex tasks with LangGraph, our low-level agent orchestration framework. LangGraph offers customizable architecture, long-term memory, and human-in-the-loop workflows — and is trusted in production by companies like LinkedIn, Uber, Klarna, and GitLab.

🌐 Supported Environments

LangChain.js is written in TypeScript and can be used in:

  • Node.js (ESM and CommonJS) - 20.x, 22.x, 24.x
  • Cloudflare Workers
  • Vercel / Next.js (Browser, Serverless and Edge functions)
  • Supabase Edge Functions
  • Browser
  • Deno
  • Bun

📖 Additional Resources

  • Getting started: Installation, setting up the environment, simple examples
  • Learn: Learn about the core concepts of LangChain.
  • LangChain Forum: Connect with the community and share all of your technical questions, ideas, and feedback.
  • Chat LangChain: Ask questions & chat with our documentation.

💁 Contributing

As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.

For detailed information on how to contribute, see CONTRIBUTING.md.

Please report any security issues or concerns following our security guidelines.

changelog

@langchain/core

1.1.6

Patch Changes

  • #9668 a7b2a7d Thanks @bracesproul! - fix: Cannot merge two undefined objects error

  • #9657 a496c5f Thanks @dqbd! - fix(core): avoid writing to TransformStream in EventStreamCallbackHandler when underlying ReadableStream is closed

  • #9658 1da1325 Thanks @dqbd! - fix(core): ensure streaming test chat models respect AbortSignal

1.1.5

Patch Changes

1.1.4

Patch Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

Patch Changes

1.0.6

Patch Changes

1.0.5

Patch Changes

1.0.4

Patch Changes

  • 8319201: Export standard converter function utility

1.0.3

Patch Changes

  • 0a8a23b: feat(@langchain/core): support of ToolRuntime

1.0.2

Patch Changes

  • 6426eb6: fix chunks constructed with tool calls + chunks
  • 619ae64: Add BaseMessage.toFormattedString()

1.0.1

Patch changes

  • cacc137: remove bad import map exports

1.0.0

🎉 LangChain v1.0 is here! This release provides a focused, production-ready foundation for building agents with significant improvements to the core abstractions and APIs. See the release notes for more details.

✨ Major Features

Standard content blocks

A new unified API for accessing modern LLM features across all providers:

  • New contentBlocks property: Provides provider-agnostic access to reasoning traces, citations, built-in tools (web search, code interpreters, etc.), and other advanced LLM features
  • Type-safe: Full TypeScript support with type hints for all content block types
  • Backward compatible: Content blocks can be loaded lazily with no breaking changes to existing code

Example:

const response = await model.invoke([
  { role: "user", content: "What is the weather in Tokyo?" },
]);

// Access structured content blocks
for (const block of response.contentBlocks) {
  if (block.type === "thinking") {
    console.log("Model reasoning:", block.thinking);
  } else if (block.type === "text") {
    console.log("Response:", block.text);
  }
}

For more information, see our guide on content blocks.

Enhanced Message API

Improvements to the core message types:

  • Structured content: Better support for multimodal content with the new content blocks API
  • Provider compatibility: Consistent message format across all LLM providers
  • Rich metadata: Enhanced metadata support for tracking message provenance and transformations

🔧 Improvements

  • Better structured output generation: Core abstractions for generating structured outputs in the main agent loop
  • Improved type safety: Enhanced TypeScript definitions across all core abstractions
  • Performance optimizations: Reduced overhead in message processing and runnable composition
  • Better error handling: More informative error messages and better error recovery

📦 Package Changes

The @langchain/core package remains focused on essential abstractions:

  • Core message types and content blocks
  • Base runnable abstractions
  • Tool definitions and schemas
  • Middleware infrastructure
  • Callback system
  • Output parsers
  • Prompt templates

🔄 Migration Notes

Backward Compatibility: This release maintains backward compatibility with existing code. Content blocks are loaded lazily, so no changes are required to existing applications.

New Features: To take advantage of new features like content blocks and middleware:

  1. Update to @langchain/core@next:

    npm install @langchain/core@1.0.0
  2. Use the new contentBlocks property to access rich content:

    const response = await model.invoke(messages);
    console.log(response.contentBlocks); // New API
    console.log(response.content); // Legacy API still works
  3. For middleware and createAgent, install langchain@next:

    npm install langchain@1.0.0 @langchain/core@1.0.0

📚 Additional Resources


0.3.79

Patch Changes

  • 1063b43: fix chunks constructed with tool calls + chunks

0.3.78

Patch Changes

  • 1519a97: update chunk concat logic to match on missing ID fields
  • 079e11d: omit tool call chunks without tool call id

0.3.76

Patch Changes

  • 41bd944: support base64 embeddings format
  • e90bc0a: fix(core): prevent tool call chunks from merging incorrectly in AIMes…
  • 3a99a40: Fix deserialization of RemoveMessage if represented as a plain object
  • 58e9522: make mustache prompt with nested object working correctly
  • e44dc1b: handle backticks in structured output

0.3.75

Patch Changes

  • d6d841f: fix(core): Fix deep nesting of runnables within traceables

0.3.74

Patch Changes

  • 4e53005: fix(core): Always inherit parent run id onto callback manager from context

0.3.73

Patch Changes

  • a5a2e10: add root export to satisfy bundler requirements