Home/Data & Retrieval/langchain_dart
langchain_dart logo

langchain_dart

davidmigloz/langchain_dart

Build LLM-powered Dart/Flutter applications.

GraphCanon updated 2w · GitHub synced 2w

685 stars154 forksLast push 3w Dart MIT

Decision brief

Unveils capabilities for LLM-powered Dart/Flutter applications with a focus on component chaining and RAG pipelines.

Good fit when

  • You are developing Dart or Flutter applications that require integration with various Language Models (LLMs) without rewriting extensive connectivity code.
  • Your application demands complex use cases such as implementing a Retrieval-Augmented Generation (RAG) pipeline, where you need to retrieve relevant documents and combine them with model responses.

Avoid when

  • Your application does not require the chaining of multiple components or complex use cases such as RAG pipelines and can function with direct, simple API calls to language models.
  • You are looking for a framework that supports languages other than Dart; LangChain.dart is specifically designed for Dart/Flutter applications only.
Pricing:
freemium - Freely available for use and licensed under MIT. No explicit service-level pricing is outlined beyond potential costs from using integrated third-party models or services.

Observed Jul 12, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Very active (5d since push)
As of 2w
Provenance
Not a fork · Personal account
As of 2w
Security (OSV)
No lockfile
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

git clone https://github.com/davidmigloz/langchain_dart

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

LangChain.dart provides a unified interface for calling different Language Models (LLMs) and enables chaining multiple components to implement complex use cases, such as RAG pipelines in Dart/Flutter applications.

Capability facts

Languages
dart

Source: github.language · Aug 8, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

LangChain integrationLangChain

Source: README excerpt (regex_v1, Aug 8, 2026)

To start using LangChain.dart, add `langchain` as a dependency to your `pubspec.yaml` file. Also, includ
Source link

Tags

README

Getting started

To start using LangChain.dart, add langchain as a dependency to your pubspec.yaml file. Also, include the dependencies for the specific integrations you want to use (e.g.langchain_community, langchain_openai, langchain_google, etc.):

dependencies:
  langchain: {version}
  langchain_community: {version}
  langchain_openai: {version}
  langchain_google: {version}
  ...

The most basic building block of LangChain.dart is calling an LLM on some prompt. LangChain.dart provides a unified interface for calling different LLMs. For example, we can use ChatGoogleGenerativeAI to call Google's Gemini model:

final model = ChatGoogleGenerativeAI(apiKey: googleApiKey);
final prompt = PromptValue.string('Hello world!');
final result = await model.invoke(prompt);
// Hello everyone! I'm new here and excited to be part of this community.

But the power of LangChain.dart comes from chaining together multiple components to implement complex use cases. For example, a RAG (Retrieval-Augmented Generation) pipeline that would accept a user query, retrieve relevant documents from a vector store, format them using prompt templates, invoke the model, and parse the output:

// 1. Create a vector store and add documents to it
final vectorStore = MemoryVectorStore(
  embeddings: OpenAIEmbeddings(apiKey: openaiApiKey),
);
await vectorStore.addDocuments(
  documents: [
    Document(pageContent: 'LangChain was created by Harrison'),
    Document(pageContent: 'David ported LangChain to Dart in LangChain.dart'),
  ],
);

// 2. Define the retrieval chain
final retriever = vectorStore.asRetriever();
final setupAndRetrieval = Runnable.fromMap<String>({
  'context': retriever.pipe(
    Runnable.mapInput((docs) => docs.map((d) => d.pageContent).join('\n')),
  ),
  'question': Runnable.passthrough(),
});

// 3. Construct a RAG prompt template
final promptTemplate = ChatPromptTemplate.fromTemplates([
  (ChatMessageType.system, 'Answer the question based on only the following context:\n{context}'),
  (ChatMessageType.human, '{question}'),
]);

// 4. Define the final chain
final model = ChatOpenAI(apiKey: openaiApiKey);
const outputParser = StringOutputParser<ChatResult>();
final chain = setupAndRetrieval
    .pipe(promptTemplate)
    .pipe(model)
    .pipe(outputParser);

// 5. Run the pipeline
final res = await chain.invoke('Who created LangChain.dart?');
print(res);
// David created LangChain.dart

License

LangChain.dart is licensed under the MIT License.

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.