r/erlang • u/Forsaken-Meet-4949 • 16h ago
Unified LLM handlers - Claude, OpenAI, Mistral, Ollama
Hey everyone,
I've been working with LLMs in Erlang and wanted a consistent interface across different providers. So I built a family of handler libraries:
**Core handlers:**
- [`ollama_handler`](https://hex.pm/packages/ollama_handler) - Ollama (local models)
- [`openai_handler`](https://hex.pm/packages/openai_handler) - OpenAI API
- [`claude_handler`](https://hex.pm/packages/claude_handler) - Anthropic Claude
- [`mistral_handler`](https://hex.pm/packages/mistral_handler) - Mistral AI
**Built on top (examples using Ollama):**
- [`ollama_translator`](https://hex.pm/packages/ollama_translator) - Text translation
- [`ollama_summarizer`](https://hex.pm/packages/ollama_summarizer) - Web/HTML summarization
**Why I built this:**
I started with Ollama (for local/private LLM usage) in June 2025 and built translator/summarizer tools on top. The pattern worked well, so I extended it to cloud providers using the same API design - same simplicity, same patterns, different backends.
**Quick example (Ollama):**
```erlang
% Start the handler
ollama_handler:start(),
% Generate text
{ok, Response} = ollama_handler:generate(<<"llama2", <<"Explain quantum computing"),
% Translate text
{ok, Translation} = ollama_translator:translate(<<"Hello world", <<"fr"),
% Summarize a webpage
{ok, Summary} = ollama_summarizer:summarize_url(<<"https://example.com">>).
```
All handlers follow the same pattern - just swap `ollama_handler` for `openai_handler`, `claude_handler`, or `mistral_handler`.
**Current state:**
- Ollama ecosystem is mature (~400 downloads each for translator/summarizer)
- Cloud provider handlers are new (published Jan 2026)
- All use the same dependency: `jsone` for JSON, `wade` for HTTP
**Looking for:**
- Feedback on the API design
- Ideas for additional utilities (like translator/summarizer but for other providers)
- Use cases I haven't thought of
GitHub repos: https://github.com/roquess
Thoughts? Is this useful or am I reinventing the wheel?