Elixir
<div align="center" style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0"
<a href="https://github.com/kreuzberg-dev/alef">
<img src="https://img.shields.io/badge/Bindings-alef%20%D7%90-007ec6" alt="Bindings" /><a href="https://crates.io/crates/liter-llm">
<img src="https://img.shields.io/crates/v/liter-llm?label=Rust&color=007ec6" alt="Rust" /><a href="https://pypi.org/project/liter-llm/">
<img src="https://img.shields.io/pypi/v/liter-llm?label=Python&color=007ec6" alt="Python" /><a href="https://www.npmjs.com/package/@kreuzberg/liter-llm">
<img
src="https://img.shields.io/npm/v/@kreuzberg/liter-llm?label=Node.js&color=007ec6"
alt="Node.js"
/><a href="https://www.npmjs.com/package/@kreuzberg/liter-llm-wasm">
<img
src="https://img.shields.io/npm/v/@kreuzberg/liter-llm-wasm?label=WASM&color=007ec6"
alt="WASM"
/><a href="https://central.sonatype.com/artifact/dev.kreuzberg/liter-llm">
<img
src="https://img.shields.io/maven-central/v/dev.kreuzberg/liter-llm?label=Java&color=007ec6"
alt="Java"
/><a href="https://github.com/kreuzberg-dev/liter-llm/tree/main/packages/go">
<img
src="https://img.shields.io/github/v/tag/kreuzberg-dev/liter-llm?label=Go&color=007ec6"
alt="Go"
/><a href="https://www.nuget.org/packages/LiterLlm">
<img src="https://img.shields.io/nuget/v/LiterLlm?label=C%23&color=007ec6" alt="C#" /><a href="https://packagist.org/packages/kreuzberg/liter-llm">
<img
src="https://img.shields.io/packagist/v/kreuzberg/liter-llm?label=PHP&color=007ec6"
alt="PHP"
/><a href="https://rubygems.org/gems/liter_llm">
<img src="https://img.shields.io/gem/v/liter_llm?label=Ruby&color=007ec6" alt="Ruby" /><a href="https://hex.pm/packages/liter_llm">
<img src="https://img.shields.io/hexpm/v/liter_llm?label=Elixir&color=007ec6" alt="Elixir" /><a href="https://github.com/kreuzberg-dev/liter-llm/pkgs/container/liter-llm">
<img
src="https://img.shields.io/badge/Docker-007ec6?logo=docker&logoColor=white"
alt="Docker"
/><a href="https://github.com/kreuzberg-dev/homebrew-tap/blob/main/Formula/liter-llm.rb">
<img
src="https://img.shields.io/badge/Homebrew-007ec6?logo=homebrew&logoColor=white"
alt="Homebrew"
/><a href="https://github.com/kreuzberg-dev/liter-llm/tree/main/crates/liter-llm-ffi">
<img src="https://img.shields.io/badge/C-FFI-007ec6" alt="C FFI" /><a href="https://github.com/kreuzberg-dev/liter-llm/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-MIT-007ec6" alt="License" /><a href="https://docs.liter-llm.kreuzberg.dev">
<img src="https://img.shields.io/badge/Docs-liter--llm-007ec6" alt="Docs" /><div align="center" style="display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 28px 0 24px"
<a href="https://discord.gg/xt9WY3GnKR">
<img
height="22"
src="https://img.shields.io/badge/Discord-Chat-007ec6?logo=discord&logoColor=white"
alt="Join Discord"
/>Universal LLM API client for Elixir. Access 143+ LLM providers through a single interface with native BEAM concurrency, OTP integration, and idiomatic Elixir API.
What This Package Provides
- One provider surface — chat, streaming, embeddings, images, audio, search, OCR, tools, and structured output across the provider registry.
- Provider/model routing — call models with the
provider/modelconvention and keep provider-specific request code out of application paths. - Production controls — retries, fallback, rate limits, cache layers, budgets, health checks, OpenTelemetry spans, and redacted secrets.
- Same core as every binding — Rust, Python, Node.js, Go, Java, PHP, Ruby, .NET, Elixir, WASM, Kotlin Android, Swift, Dart, Zig, and C FFI use the same Rust implementation.
- BEAM package — Rustler NIF binding for OTP services.
Installation
Package Installation
Add to your mix.exs dependencies:
def deps do
[
{:liter_llm, "~> 1.4.0-rc.34"}
]
endThen run:
mix deps.getSystem Requirements
- Elixir 1.14+ and Erlang/OTP 25+ required
-
API keys via environment variables (e.g.
OPENAI_API_KEY,ANTHROPIC_API_KEY)
Quick Start
Basic Chat
Send a message to any provider using the provider/model prefix:
{:ok, client} = LiterLlm.create_client(System.get_env("OPENAI_API_KEY"))
request =
Jason.encode!(%{
model: "openai/gpt-4o-mini",
messages: [%{role: "user", content: "Hello!"}]
})
{:ok, result} = LiterLlm.defaultclient_chat_async(client, request)
IO.puts(Enum.at(result.choices, 0).message.content)Common Use Cases
Streaming Responses
Stream tokens in real time:
{:ok, client} = LiterLlm.create_client(System.get_env("OPENAI_API_KEY"))
request =
Jason.encode!(%{
model: "openai/gpt-4o-mini",
messages: [%{role: "user", content: "Count from 1 to 5."}],
stream: true
})
{:ok, stream} = LiterLlm.defaultclient_chat_stream(client, request)
Enum.each(stream, fn chunk ->
content = get_in(chunk, [:choices, Access.at(0), :delta, :content])
if content, do: IO.write(content)
end)
IO.puts("")Next Steps
- Provider Registry - Full list of supported providers
- GitHub Repository - Source, issues, and discussions
Features
Supported Providers (143+)
Route to any provider using the provider/model prefix convention:
| Provider | Example Model |
|---|---|
| OpenAI | openai/gpt-4o, openai/gpt-4o-mini |
| Anthropic | anthropic/claude-3-5-sonnet-20241022 |
| Groq | groq/llama-3.1-70b-versatile |
| Mistral | mistral/mistral-large-latest |
| Cohere | cohere/command-r-plus |
| Together AI | together/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo |
| Fireworks | fireworks/accounts/fireworks/models/llama-v3p1-70b-instruct |
| Google Vertex | vertexai/gemini-1.5-pro |
| Amazon Bedrock | bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 |
Key Capabilities
- Provider Routing -- Single client for 143+ LLM providers via
provider/modelprefix - Local LLMs — Connect to locally-hosted models via Ollama, LM Studio, vLLM, llama.cpp, and other local inference servers
- Unified API -- Consistent
chat,chat_stream,embeddings,list_modelsinterface - Streaming -- Real-time token streaming via
chat_stream - Tool Calling -- Function calling and tool use across all supporting providers
- Type Safe -- Schema-driven types compiled from JSON schemas
- Secure -- API keys never logged or serialized, managed via environment variables
- Observability -- Built-in OpenTelemetry with GenAI semantic conventions
- Error Handling -- Structured errors with provider context and retry hints
Performance
Built on a compiled Rust core for speed and safety:
- Provider resolution at client construction -- zero per-request overhead
- Configurable timeouts and connection pooling
- Zero-copy streaming with SSE and AWS EventStream support
- API keys wrapped in secure memory, zeroed on drop
Provider Routing
Route to 143+ providers using the provider/model prefix convention:
openai/gpt-4o
anthropic/claude-3-5-sonnet-20241022
groq/llama-3.1-70b-versatile
mistral/mistral-large-latestSee the provider registry for the full list.
Proxy Server
liter-llm also ships as an OpenAI-compatible proxy server with Docker support:
docker run -p 4000:4000 -e LITER_LLM_MASTER_KEY=sk-your-key ghcr.io/kreuzberg-dev/liter-llmSee the proxy server documentation for configuration, CLI usage, and MCP integration.
Documentation
- Documentation -- Full docs and API reference
- GitHub Repository -- Source, issues, and discussions
- Provider Registry -- 143 supported providers
Part of Kreuzberg.dev
- Kreuzberg — document intelligence: text, tables, metadata from 90+ formats with optional OCR.
- Kreuzberg Cloud — managed extraction API with SDKs, dashboards, and observability.
- kreuzcrawl — web crawling and scraping with HTML→Markdown and headless-Chrome fallback.
- html-to-markdown — fast, lossless HTML→Markdown engine.
- tree-sitter-language-pack — tree-sitter grammars and code-intelligence primitives.
- alef — the polyglot binding generator that produces this README and all per-language bindings.
- Discord — community, roadmap, announcements.
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
Join our Discord community for questions and discussion.
License
MIT -- see LICENSE for details.