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.20.0
GitHub:

https://github.com/doofinder/llm_composer

First Post! Switch mode

mercyf

mercyf

This looks great :slight_smile:

Most Liked

sonic182

sonic182

llm_composer v0.16.0 released (Feb 23, 2026)

Quick update since the last post (v0.12.2 / MIT switch) — quite a bit has landed since then.


What’s new in 0.16.0

  • New provider: LlmComposer.Providers.OpenAIResponses — calls OpenAI’s /responses API with support for structured outputs and reasoning (provider/model-specific params passed via request_params), normalized into the usual LlmResponse shape. Since it targets the /responses API spec, it also works with compatible providers like x.ai (xAI/Grok), OpenRouter’s responses endpoint, and others.
  • Typed streaming chunks: new LlmComposer.StreamChunk struct + provider-specific parsing turns raw stream events into typed values (:text_delta, :tool_call_delta, :done, …).
  • LlmComposer.FunctionCallExtractors: centralizes function call extraction logic per provider.
  • Provider-aware parse_stream_response: now comes in /2 and /3 arities and returns %StreamChunk{} values instead of raw decoded maps.
  • Internals refactored to protocol-based adapters (LlmComposer.ProviderResponse + LlmComposer.ProviderStreamChunk) for cleaner normalization across providers.

Notable releases since 0.12.2

  • 0.13.0 (Dec 2025): function-call workflow is now manual/explicit via FunctionExecutor + FunctionCallHelpers — breaking change, see changelog.
  • 0.13.1 (Jan 2026): custom HTTP headers support for OpenRouter.
  • 0.14.0 (Feb 4): configurable retry/backoff for provider requests.
  • 0.14.1 (Feb 9): deep merge fix for nested request_params (e.g. Google’s generationConfig).
  • 0.14.2 (Feb 10): LlmResponse.new/3 now returns {:error, …} instead of raising on unknown provider formats.
  • 0.15.0 (Feb 17): configurable :json_engine (defaults to JSON, falls back to Jason); Google provider now preserves additionalProperties in response schemas.

Upgrade

{:llm_composer, "~> 0.16.0"}

Full changelog: llm_composer/CHANGELOG.md at master · doofinder/llm_composer · GitHub

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.

Last Post!

sonic182

sonic182

Hi all! Just released v0.20.0 — the headline is a new LlmComposer.Agent module.


LlmComposer.Agent — automatic tool-calling loop

Handles the full ask → execute → repeat cycle so you don’t have to manage it manually. Supports sequential and parallel tool execution, a configurable iteration limit, and per-tool error recovery.

LlmComposer.Agent.run(messages, tools: my_tools, provider: :open_ai)

Streaming agent (stream_response: true)

The agent now supports streaming, returning a lazy stream of StreamChunks:

  • :text_delta — model text as it arrives
  • :tool_call — emitted after each tool execution, result included (no extra telemetry handler needed)
  • :done — terminal chunk with cumulative usage and the full Agent.Result

Works across all supported providers: :open_ai, :open_router, :open_ai_responses, :google, :bedrock, :ollama.

Telemetry improvements

Spans for run_completion and providers_runner, enriched agent events with per-tool arguments and reasoning deltas, plus a :telemetry_metadata option to scope handlers to a single run.


Full changelog: Comparing 0.19.6...0.20.0 · doofinder/llm_composer · GitHub

Where Next?

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
385 14863 120
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
quatermain
Hello, I’m sharing my plugin here in forum after some time so it has time to mature and proof yourself. I use Claude Code daily on a pr...
New

Other Trending Topics Top

type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
bjorng
We want to introduce a new native datatype to Erlang: native records. Although replacing all tuple records with native records is not our...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
yureehuh
Introduction Founded in 2017 by landscape ecologist and fire mitigation expert Harry Statter, Frontline developed the first fully integra...
New

We're in Beta

About us Mission Statement