PHPackages                             kreuzberg/liter-llm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kreuzberg/liter-llm

ActivePhp-ext

kreuzberg/liter-llm
===================

High-performance LLM client for PHP. Unified interface for streaming, tool calling, and provider routing across OpenAI, Anthropic, and 142+ providers. Powered by Rust core.

1.0.0-rc.3(1mo ago)40MITRustPHP ^8.2CI failing

Since Mar 27Pushed 1mo agoCompare

[ Source](https://github.com/kreuzberg-dev/liter-llm)[ Packagist](https://packagist.org/packages/kreuzberg/liter-llm)[ Docs](https://github.com/kreuzberg-dev/liter-llm)[ RSS](/packages/kreuzberg-liter-llm/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

liter-llm
=========

[](#liter-llm)

 [ ![Rust](https://camo.githubusercontent.com/5e0e1e81af4e148d2fe6e84ea6baa20203dffd1614c2b3dd0a385765f2f94627/68747470733a2f2f696d672e736869656c64732e696f2f6372617465732f762f6c697465722d6c6c6d3f6c6162656c3d5275737426636f6c6f723d303037656336) ](https://crates.io/crates/liter-llm) [ ![Python](https://camo.githubusercontent.com/be6d36408f87ce8c92a07f44e5abac12b8ef0450ff30d20b90d03faf6124c729/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f6c697465722d6c6c6d3f6c6162656c3d507974686f6e26636f6c6f723d303037656336) ](https://pypi.org/project/liter-llm/) [ ![Node.js](https://camo.githubusercontent.com/de7625dddc2f369d4942f62b570f42fbb315eda6952512cc6e2f43082ae625a7/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f406b7265757a626572672f6c697465722d6c6c6d3f6c6162656c3d4e6f64652e6a7326636f6c6f723d303037656336) ](https://www.npmjs.com/package/@kreuzberg/liter-llm) [ ![WASM](https://camo.githubusercontent.com/91c0d7511d5d53e5f0e411e3565eba8744949339ab9c5affe25a69f76eac093e/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f406b7265757a626572672f6c697465722d6c6c6d2d7761736d3f6c6162656c3d5741534d26636f6c6f723d303037656336) ](https://www.npmjs.com/package/@kreuzberg/liter-llm-wasm) [ ![Java](https://camo.githubusercontent.com/cabf855c720ca5bcc30e660008bab8ac8a136cf2d0734e238f8df30564458d75/68747470733a2f2f696d672e736869656c64732e696f2f6d6176656e2d63656e7472616c2f762f6465762e6b7265757a626572672f6c697465722d6c6c6d3f6c6162656c3d4a61766126636f6c6f723d303037656336) ](https://central.sonatype.com/artifact/dev.kreuzberg/liter-llm) [ ![Go](https://camo.githubusercontent.com/7dba1f8124ca9d9dc112ba46d67f1d7e72fee01819fa88d8489ae890ce9cb178/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6b7265757a626572672d6465762f6c697465722d6c6c6d3f6c6162656c3d476f26636f6c6f723d303037656336) ](https://github.com/kreuzberg-dev/liter-llm/tree/main/packages/go) [ ![C#](https://camo.githubusercontent.com/913d82218ab797d4b7d971fd9a312f7199f664cd87942d20efe3e4337b4eba58/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f762f4c697465724c6c6d3f6c6162656c3d4325323326636f6c6f723d303037656336) ](https://www.nuget.org/packages/LiterLlm) [ ![PHP](https://camo.githubusercontent.com/a33104e13fc6a389770ef88e1ef84f035aff0f1bdf6c40f8a146819f5b9298ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b7265757a626572672f6c697465722d6c6c6d3f6c6162656c3d50485026636f6c6f723d303037656336) ](https://packagist.org/packages/kreuzberg/liter-llm) [ ![Ruby](https://camo.githubusercontent.com/3330365b40db2e36aa119aff0895d65d1528145a77278f9e9805dbcefe606a5d/68747470733a2f2f696d672e736869656c64732e696f2f67656d2f762f6c697465725f6c6c6d3f6c6162656c3d5275627926636f6c6f723d303037656336) ](https://rubygems.org/gems/liter_llm) [ ![Elixir](https://camo.githubusercontent.com/d1a8f034af793514d50387310a93f989a23a3b4f5500ac6b46141b62878fe970/68747470733a2f2f696d672e736869656c64732e696f2f686578706d2f762f6c697465725f6c6c6d3f6c6162656c3d456c6978697226636f6c6f723d303037656336) ](https://hex.pm/packages/liter_llm) [ ![Docker](https://camo.githubusercontent.com/32cec0d80520c2e9872e7c80e7f3d5d6b916c41998b25dddb1289399cbc8ba0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f636b65722d3030376563363f6c6f676f3d646f636b6572266c6f676f436f6c6f723d7768697465) ](https://github.com/kreuzberg-dev/liter-llm/pkgs/container/liter-llm) [ ![C FFI](https://camo.githubusercontent.com/41b9c58c3810775402965a3a7652da9832ea83391c1ff255081e5551900db8f2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f432d4646492d303037656336) ](https://github.com/kreuzberg-dev/liter-llm/tree/main/crates/liter-llm-ffi) [ ![License](https://camo.githubusercontent.com/2d9625df144a4f5af0784d0669d17a624b41369a41ca568bf79f12d517315afc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d3030376563362e737667) ](https://github.com/kreuzberg-dev/liter-llm/blob/main/LICENSE) [ ![Docs](https://camo.githubusercontent.com/8079d569578159b460ce74ad8b30554ec9b0d41b1f3485c9b24ebc154a2031fb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d6b7265757a626572672e6465762d303037656336) ](https://docs.liter-llm.kreuzberg.dev)

[![kreuzberg.dev](https://private-user-images.githubusercontent.com/247880403/531720042-1b6c6ad7-3b6d-4171-b1c9-f2026cc9deb8.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ2NzMyODYsIm5iZiI6MTc3NDY3Mjk4NiwicGF0aCI6Ii8yNDc4ODA0MDMvNT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zY3OGU2NjQ4N2E3MzFiODA4NjIzOThkZTgyYTQ4MmJmNGQwNDc5ZjJkYmM5ODJlMDBlNTllZGEzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.pHsiACBvmKxlr_FSydlkmSegQhU0L-wR_oVqZhjHttA) [ ![Discord](https://camo.githubusercontent.com/f66b90b5263482521c9ff4e4cae96688b20f4670a56a633be6a10c633091b757/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d4a6f696e2532306f7572253230636f6d6d756e6974792d3732383964613f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465) ](https://discord.gg/xt9WY3GnKR)

**A lighter, faster, safer universal LLM API client** -- one Rust core, 11 native language bindings, 142 providers.

Why liter-llm?
--------------

[](#why-liter-llm)

A universal LLM API client, compiled from the ground up in Rust. No interpreter, no transitive dependency tree, no supply chain surface area. One binary, 11 native language bindings, 142 providers.

- **Compiled Rust core.** No `pip install` supply chain. No `.pth` auto-execution hooks. No runtime dependency tree to compromise. The kind of [supply chain attack that hit litellm](https://www.xda-developers.com/popular-python-library-backdoor-machine/) in 2026 is structurally impossible here.
- **Secrets stay secret.** API keys are wrapped in [`secrecy::SecretString`](https://docs.rs/secrecy/) -- zeroed on drop, redacted in logs, never serialized.
- **Polyglot from day one.** Python, TypeScript, Go, Java, Ruby, PHP, C#, Elixir, WebAssembly, C/FFI -- all thin wrappers around the same Rust core. No reimplementation drift.
- **Observability built in.** Production-grade [OpenTelemetry](https://opentelemetry.io/) with GenAI semantic conventions -- not an afterthought callback system.
- **Composable middleware.** Rate limiting, caching, cost tracking, health checks, and fallback as [Tower](https://docs.rs/tower/) layers you stack like building blocks.

We give credit to [litellm](https://github.com/BerriAI/litellm) for proving the category -- our provider registry was bootstrapped from theirs. See [ATTRIBUTIONS.md](ATTRIBUTIONS.md).

Feature Comparison
------------------

[](#feature-comparison)

An honest look at where things stand. We're newer and leaner -- litellm has breadth we haven't matched yet, and we have depth they can't easily retrofit.

liter-llmlitellm**Language**Rust (compiled, memory-safe)Python**Bindings**11 native (Rust, Python, TS, Go, Java, Ruby, PHP, C#, Elixir, WASM, C)Python (+ OpenAI-compatible proxy)**Providers**142 (compiled at build time)100+ (runtime resolution)**Streaming**SSE + AWS EventStream binary protocolSSE**Observability**Built-in OpenTelemetry (GenAI semconv)51+ callback integrations**API key safety**`secrecy::SecretString` (zeroed, redacted)Plain strings**Middleware**Composable Tower stackBuilt-in, non-composable**Proxy / Gateway**--Yes**Guardrails**--35+ hooks**Semantic caching**--Redis + Qdrant backends**Virtual key mgmt**--Yes**Management API**--Multi-tenant (teams, budgets, keys)**Fine-tuning API**--Yes**Load balancer**Fallback middlewareFull router with strategies**Cost tracking**Embedded pricing + OTEL spansPer-key/team/model budgets**Rate limiting**Per-model RPM/TPM (Tower layer)Per-key/user/team/model**Caching**In-memory LRU (Tower layer)16 backends (Redis, S3, disk, ...)**Tool calling**Parallel tools, structured output, JSON schemaFull support**Embeddings**YesYes**Batch API**YesYes**Audio / Speech**YesYes**Image generation**YesYesKey Features
------------

[](#key-features)

- **142 providers** -- OpenAI, Anthropic, Google, AWS Bedrock, Groq, Mistral, Together AI, Fireworks, Perplexity, DeepSeek, Cohere, and [130+ more](schemas/providers.json)
- **11 native bindings** -- Rust, Python, TypeScript/Node.js, Go, Java, Ruby, PHP, C#, Elixir, WebAssembly, C/FFI
- **First-class streaming** -- SSE and AWS EventStream binary protocol with zero-copy buffers
- **OpenTelemetry** -- GenAI semantic conventions, cost tracking spans, HTTP-level tracing
- **Tower middleware** -- Rate limiting, LRU caching, cost estimation, health checks, cooldowns, fallback -- all composable
- **Tool calling** -- Parallel tools, structured outputs, JSON schema validation
- **Embeddings** -- Dimension selection, base64 format, multi-provider support
- **Schema-driven** -- Provider registry and API types compiled from JSON schemas, no runtime lookups

Architecture
------------

[](#architecture)

```
liter-llm/
├── crates/
│   ├── liter-llm/           # Rust core library
│   ├── liter-llm-py/        # Python (PyO3) core
│   ├── liter-llm-node/      # Node.js (NAPI-RS) core
│   ├── liter-llm-ffi/       # C-compatible FFI layer
│   ├── liter-llm-php/       # PHP (ext-php-rs) core
│   └── liter-llm-wasm/      # WebAssembly (wasm-bindgen) core
├── packages/
│   ├── python/               # Python package
│   ├── typescript/           # TypeScript/Node.js package
│   ├── go/                   # Go (cgo) module
│   ├── java/                 # Java (Panama FFI) package
│   ├── ruby/                 # Ruby (Magnus) gem
│   ├── elixir/               # Elixir (Rustler NIF) package
│   ├── csharp/               # .NET (P/Invoke) package
│   └── php/                  # PHP (Composer) package
└── schemas/                  # Provider registry and API schemas

```

Quick Start
-----------

[](#quick-start)

Install in your language of choice:

LanguageInstallPython`pip install liter-llm`Node.js`pnpm add @kreuzberg/liter-llm`Rust`cargo add liter-llm`Go`go get github.com/kreuzberg-dev/liter-llm/packages/go`Java`dev.kreuzberg:liter-llm` (Maven/Gradle)Ruby`gem install liter_llm`PHP`composer require kreuzberg/liter-llm`C#`dotnet add package LiterLlm`Elixir`{:liter_llm, "~> 0.1"}` in mix.exsWASM`pnpm add @kreuzberg/liter-llm-wasm`C/FFIBuild from source -- see [FFI crate](crates/liter-llm-ffi)### Usage

[](#usage)

```
from liter_llm import LiterLlmClient

client = LiterLlmClient()

# Chat with any provider using the provider/model prefix
response = client.chat(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

# Stream responses
for chunk in client.chat_stream(
    model="anthropic/claude-3-5-sonnet-20241022",
    messages=[{"role": "user", "content": "Tell me a story"}],
):
    print(chunk.delta, end="", flush=True)
```

The same API is available in all 11 languages -- see the language READMEs below for idiomatic examples.

Core API
--------

[](#core-api)

All bindings expose a unified `chat()` function:

LanguageUsageRust`DefaultClient::new(config).chat(messages, options).await`Python`LiterLlmClient(api_key=...).chat(messages, config)`Node.js`new LiterLlmClient({ apiKey }).chat(messages, config)`Go`client.Chat(ctx, messages, config)`Java`client.chat(messages, configJson)`Ruby`LiterLlm::Client.new(api_key: ...).chat(messages, config)`Elixir`LiterLlm.chat(messages, config)`PHP`LiterLlm\Client::new($apiKey)->chat($messages, $config)`C#`new LiterLlmClient(apiKey).ChatAsync(messages, config)`WASM`new LiterLlmClient({ apiKey }).chat(messages, config)`C FFI`liter_llm_chat(client, messages_json, config_json)`Language READMEs
----------------

[](#language-readmes)

LanguageREADMEBindingPython[packages/python](packages/python/README.md)PyO3TypeScript / Node.js[crates/liter-llm-node](crates/liter-llm-node/README.md)NAPI-RSGo[packages/go](packages/go/README.md)cgoJava[packages/java](packages/java/README.md)Panama FFIRuby[packages/ruby](packages/ruby/README.md)MagnusElixir[packages/elixir](packages/elixir/README.md)Rustler NIFPHP[packages/php](packages/php/README.md)ext-php-rs.NET (C#)[packages/csharp](packages/csharp/README.md)P/InvokeWebAssembly[crates/liter-llm-wasm](crates/liter-llm-wasm/README.md)wasm-bindgenC/C++ (FFI)[crates/liter-llm-ffi](crates/liter-llm-ffi)C ABIPart of kreuzberg.dev
---------------------

[](#part-of-kreuzbergdev)

liter-llm is built by the [kreuzberg.dev](https://kreuzberg.dev) team -- the same people behind [Kreuzberg](https://github.com/kreuzberg-dev/kreuzberg) (document extraction for 91+ formats), [tree-sitter-language-pack](https://github.com/kreuzberg-dev/tree-sitter-language-pack) (multilingual parsing), and [html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown). All our libraries share the same Rust-core, polyglot-bindings architecture. Visit [kreuzberg.dev](https://kreuzberg.dev) or find us on [GitHub](https://github.com/kreuzberg-dev).

Contributing
------------

[](#contributing)

Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

Join our [Discord community](https://discord.gg/xt9WY3GnKR) for questions and discussion.

License
-------

[](#license)

MIT -- see [LICENSE](LICENSE) for details.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e332a98740b42010f18d4ff016720276b0f6b893776963c6fe29beac6f5a94ff?d=identicon)[Goldziher](/maintainers/Goldziher)

---

Top Contributors

[![Goldziher](https://avatars.githubusercontent.com/u/30733348?v=4)](https://github.com/Goldziher "Goldziher (99 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

anthropicapi-clientllmmachine-learningopenaipolyglotpythonruststreamingtypescriptperformancestreamingopenaiphp8llmanthropicllm clientrusttool-callingprovider-routing

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kreuzberg-liter-llm/health.svg)

```
[![Health](https://phpackages.com/badges/kreuzberg-liter-llm/health.svg)](https://phpackages.com/packages/kreuzberg-liter-llm)
```

###  Alternatives

[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[vizra/vizra-adk

Vizra Agent Development Kit - A comprehensive Laravel package for building intelligent AI agents.

29026.1k](/packages/vizra-vizra-adk)[helgesverre/toon

Token-Oriented Object Notation - A compact data format for reducing token consumption when sending structured data to LLMs

11841.4k9](/packages/helgesverre-toon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
