sonic182

sonic182

Llm_composer - Elixir library for building LLM-based applications

Hi everyone, at Doofinder we have been building llm_composer for some new apps, and we thought it could be useful to share it with the community.

llm_composer is an Elixir library that simplifies working with large language models (LLMs) like OpenAI’s GPT, OpenRouter, Ollama, AWS Bedrock, and Google (Gemini).

It provides a streamlined way to build and execute LLM-based applications or chatbots, with features such as:

  • Multi-provider support (OpenAI, OpenRouter, Ollama, Bedrock, Google Gemini/Vertex AI).
  • System prompts and message history management.
  • Streaming responses.
  • Function calls with auto-execution.
  • Structured outputs with JSON schema validation.
  • Built-in cost tracking (currently for OpenRouter).
  • Easy extensibility for custom use cases.

A key feature is the provider router that handles failover automatically.
It will use one provider until it fails, then fall back to the next provider in the list, applying an exponential backoff strategy. This makes it resilient in production environments where provider APIs can become temporarily unavailable.

Under the hood, llm_composer uses Tesla as the HTTP client.
For production setups, especially when using streaming, it is recommended to run it with Finch for optimal performance.


More info and docs:

HexDocs: LlmComposer — llm_composer v0.13.0
GitHub:

Most Liked

Jskalc

Jskalc

Thanks for your efforts! :raising_hands:

Could you highlight the differences from ReqLLM, discussed in this topic? I believe both libraries aim to solve the same problem.

sonic182

sonic182

We started this lib about a year ago (we’d been using it internally even before that) and only now decided to share it here.

Both libraries aim at the same thing: wrapping LLM APIs behind a unified HTTP client.

The main differences are:

  • HTTP layer: we use Tesla, ReqLLM builds on Req.

  • Routing: llm_composer includes a router with fallback + retries.

  • API style: each library exposes a slightly different way to configure and work with “bots” or requests, so it depends which style you prefer.

mercyf

mercyf

This looks great :slight_smile:

sonic182

sonic182

LlmComposer v0.12.0 released

This version removes deprecated configuration options and adds built-in cost tracking for multiple providers.

Removed (breaking changes)

  • Removed deprecated :provider and :provider_opts keys. Use the :providers list instead.
  • Removed global :api_key in Settings. Each provider should define its own key.
  • Dropped backward compatibility handling for these deprecated options.

Added

  • Automatic cost tracking for OpenAI, Google, and OpenRouter:
    • Fetches real-time pricing from provider APIs (models.dev and OpenRouter).
    • Adds a CostInfo struct in responses with token usage and cost breakdowns.
    • Supports both automatic and manual pricing configuration.

Changelog: https://github.com/doofinder/llm_composer/blob/master/CHANGELOG.md
Docs: https://hexdocs.pm/llm_composer/readme.html

Where Next?

Popular in Announcing Top

zachdaniel
Hey folks! AshEvents Release We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps. Check o...
New
zachdaniel
Ash Framework 3.0: Official Release! I’m here with the fine folks at Gig City Elixir, pushing the button live on stage :sunglasses: T...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
hauleth
PhoenixBakery is library for Phoenix 1.6 (and later) that provides modules implementing Phoenix.Digester.Compressor. There are currently ...
New
Antrater
Hi there! At Moon Design System, we have been working hard for the past six months on the next generation of our LiveView component libra...
New
bentanweihao
Here’s a preview: Here’s the link to download: GenServer cheatsheet Tell me what you think!
New
tugayac
Hey Elixir Community! A few months back, I open sourced a link management system we had built into an app. It’s now got enough features ...
New
kraleppa
I’m happy to announce LiveDebugger v0.1.0! :mega: LiveDebugger is a browser-based tool for debugging LiveView applications, designed to ...
New
fhunleth
Elixir Circuits is a set of libraries for interacting with hardware. We previously announced Circuits.UART, and now we’re ready to announ...
New
Asd
Hi, I am happy to release the Repatch library for mocking and patching implementation in tests and anywhere else. It brings new possibili...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement