dotnet add package LangChainJSDotNet --version                
NuGet\Install-Package LangChainJSDotNet -Version                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LangChainJSDotNet" Version="" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LangChainJSDotNet --version                
#r "nuget: LangChainJSDotNet,"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LangChainJSDotNet as a Cake Addin
#addin nuget:?package=LangChainJSDotNet&version=

// Install LangChainJSDotNet as a Cake Tool
#tool nuget:?package=LangChainJSDotNet&version=                

🦜️🔗🟪 - LangChainJSDotNet

⚡ A thin .NET wrapper around the official LangChain.js library⚡

Looking for the official JS/TS or Python versions of LangChain? Check out:

🤔 What is this?

LangChainJSDotNet provides a seamless interface for .NET developers to run LangChain based code with minimal adjustments.

The official JS/TS version tracks the official Python version closely, therefore LangChain code could be easily ported and run in .NET using LangChainJSDotNet, potentially exposing all of the latest AI advancements and features from LangChain and its vast ecosystem to .NET developers.

While integrating Python code in .NET presents challenges, Microsoft's ClearScript library greatly simplifies the integration process with JavaScript code. Hence, for now, this library focuses exclusively on wrapping the JS version of LangChain.


  • No porting required: Use the official LangChain.js library in .NET.
  • The latest LangChain features are readily available.
  • Async support: LangChain agents can await .NET async methods.
  • Connect from .NET to the new LangSmith Platform.
  • Debugging capability: Support for debugging LangChain.js code.


This library employs a four-part SemVer-like version scheme. The initial three parts mirror the version of LangChain.js that the library embeds and wraps. The fourth part, always starting at 1, is reserved for incremental bug fixes or non-breaking feature additions.

For instance, v0.0.124.1 of this library embeds and wraps v0.0.124 of LangChain.js.

While the first part currently matches LangChain.js's major version, it might be repurposed in the future to also indicate major breaking changes specific to this library.


Install the LangChainJSDotNet NuGet package.

You may use the .NET command-line interface:

dotnet add package LangChainJSDotNet

This command will download and install LangChainJSDotNet along with all its required dependencies.

💡 Usage

using var langchainjs = new LangChainJS();


    const model = new OpenAI({ openAIApiKey: 'API_KEY' }); = async () => {

        const result = await'What is a good name for a company that makes colorful socks?');


await langchainjs.InvokeAsync("run");


using var langchainjs = new LangChainJS();

langchainjs.SetEnvironmentVariable("OPENAI_API_KEY", "API_KEY");


    const model = new OpenAI({ temperature: 0.9 });

    const template = new PromptTemplate({
                                          template: 'What is a good name for a company that makes {product}?',
                                          inputVariables: ['product'],

    chain = new LLMChain({ llm: model, prompt: template }); = async (prompt) => {
        const res = await{ product: prompt });
        return res.text.trim();

string result = await langchainjs.InvokeAsync<string>("run", "colorful socks");



See sample code for an example of a ReAct agent calling dynamic tools.

Agent input: "What is the result if you substruct 8 by foo?"...
The result is 3
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 71 6/4/2024 97 4/23/2024 110 3/12/2024 107 2/16/2024 110 2/5/2024 86 2/1/2024 85 1/29/2024 84 1/26/2024 340 10/28/2023 117 10/26/2023 116 10/24/2023 168 10/23/2023 82 10/20/2023 123 10/16/2023 108 10/11/2023 126 10/10/2023 115 10/9/2023 104 10/8/2023 151 9/29/2023 110 9/28/2023 126 9/26/2023 127 9/21/2023 123 9/21/2023 131 9/19/2023 148 9/15/2023 152 9/15/2023 148 9/13/2023 125 9/12/2023 156 9/9/2023 158 9/9/2023 170 9/1/2023 143 9/1/2023 142 8/31/2023 170 8/27/2023 162 8/25/2023 162 8/24/2023 177 8/22/2023 147 8/19/2023 210 8/11/2023 231 8/9/2023 203 8/8/2023