Repolode
brainlid

brainlid/langchain

Elixir library for integrating LLMs such as Claude, OpenAI, Gemini, Ollama and self-hosted models into Elixir applications.

Stars
1,212
Forks
218
Open issues
30
Last commit
3 days ago

What is it?

Elixir LangChain is a framework for building applications powered by language models in Elixir. It provides a common interface for calling many chat model providers, including Anthropic Claude, OpenAI (Chat Completions and Responses APIs), xAI Grok, Google Gemini and Vertex AI, DeepSeek, Mistral, Perplexity, Ollama, and local models run through Bumblebee and Nx.

The central module is LangChain.Chains.LLMChain, which assembles messages, tools and a chat model into a run. Developers can expose their own Elixir functions to the model as tools, with a context map that limits what each call can access. Multimodal content parts, streaming, and prompt caching for supported providers are also covered.

The library includes trajectory tools for evaluating agent tool-call sequences in tests, and emits :telemetry events with an optional OpenTelemetry integration for tracing.

Key features

  • 01Unified chat model interface across Claude, OpenAI, Gemini, Grok, Mistral and other providers
  • 02Custom Elixir functions can be exposed to the LLM as tools with a controlled context
  • 03Streaming responses and multimodal message content parts
  • 04Bumblebee support for running open models locally via Nx
  • 05Trajectory tools for testing agent tool-call sequences
  • 06Telemetry events with optional OpenTelemetry integration

Use cases

  • Adding a chatbot or assistant to a Phoenix web application
  • Letting an LLM call application functions to query user-scoped data
  • Switching between hosted and self-hosted models behind one interface
  • Writing regression tests for agent tool-call behavior

Quick start

  1. 1

    Add langchain to your deps in mix.exs

  2. 2

    Fetch dependencies

    mix deps.get
  3. 3

    Configure your API key in config/runtime.exs

Things to know

  • Requires Elixir 1.17 or higher.
  • Most hosted models need a paid API key from the provider.
  • License is not clearly stated in the metadata (NOASSERTION).

In collections

Topics

FAQ

What is langchain?
Elixir library for integrating LLMs such as Claude, OpenAI, Gemini, Ollama and self-hosted models into Elixir applications. Elixir LangChain is a framework for building applications powered by language models in Elixir. It provides a common interface for calling many chat model providers, including Anthropic Claude, OpenAI (Chat Completions and Responses APIs), xAI Grok, Google Gemini and Vertex AI, DeepSeek, Mistral, Perplexity, Ollama, and local models run through Bumblebee and Nx.
Is langchain free to use? What license does it have?
langchain is open source under the Other license. Check the license terms before using it in commercial products.
Is langchain still maintained?
Actively maintained. The last commit to langchain was on Nov 2, 2026.
What can I use langchain for?
Adding a chatbot or assistant to a Phoenix web application Letting an LLM call application functions to query user-scoped data Switching between hosted and self-hosted models behind one interface Writing regression tests for agent tool-call behavior
How do I install langchain?
Add langchain to your deps in mix.exs Fetch dependencies: mix deps.get Configure your API key in config/runtime.exs
Where can I get langchain?
The source code and installation instructions are on GitHub: https://github.com/brainlid/langchain

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects