llm-bonsai
A real GenAI platform, deliberately kept tiny. Same structure, carefully pruned to fit small machines.
llm-bonsai runs the core of a GenAI platform in a small Kubernetes cluster: an OpenAI-compatible endpoint with keys, budgets, traces and evals, in front of local models and, if you add them, your own provider keys.
- Run it on your laptop, or on a spare machine at home that your laptop drives.
- One lab config, one CLI.
bonsai.tomldescribes the platform: its models, teams and ports (a spare machine addshost.toml, for what it publishes).llm-bonsaibuilds the platform from it, checks it, and explains what each run showed, with real numbers. - Real components, shrunk. Official images and charts with real config, at one replica, small models and tight limits. No paid API key needed.
- Opinionated. One tool for each job (LiteLLM, Ollama, Langfuse, Prometheus, Traefik, on minikube), wired one way. The lab config changes the models, teams and ports, not the pieces. Why each choice was made is written down in the ADRs and How it's built.
It's a home setup for exploring, not for production: one replica of everything, generated dev-only credentials, and network access meant for a trusted home network.
Who it's for
- Platform engineers who want to see a gateway, per-team budgets, tracing and evals working together.
- Developers building on LLMs who want a local OpenAI-compatible endpoint with real keys, limits and traces.
- Anyone learning how a GenAI platform fits together, by poking at a running one: the probes exhaust budgets, kill pods and overload the model, then say what happened.
| Component | Plays the role of | Namespace |
|---|---|---|
| LiteLLM | The LLM gateway: one OpenAI-compatible endpoint, per-team keys, budgets, rate limits, fallbacks, caching | gateway |
| Postgres, Valkey | The gateway's system of record (keys, teams, spend), and its shared counters and cache | gateway |
Ollama with qwen2.5:1.5b (or your models) |
Self-hosted model serving, on CPU (vLLM on GPUs at scale) | models |
| Langfuse | Tracing, prompt versions, datasets and scored experiments | observability |
| Prometheus (optional) | The gateway's requests, spend and latency over time | observability |
flowchart LR
PY["llm-bonsai CLI / support assistant"] --> LL["LiteLLM (gateway)"]
LL --> OL["Ollama: qwen2.5:1.5b (CPU)"]
LL --> PG[("Postgres: keys, teams, spend")]
LL --> VK[("Valkey: cache + shared limits")]
LL -- "OpenTelemetry" --> LF["Langfuse"]
PY -- "Langfuse SDK spans" --> LF
PR["Prometheus (optional)"] -- "scrapes /metrics" --> LL
Quick start
Two ways to run it: on one machine, your laptop or desktop, or on a spare machine at home that your laptop drives.
On one machine
You need:
- macOS or Linux, on arm64 or amd64, with enough memory:
- macOS: about 21 GiB, Docker Desktop's share below plus 4 GiB for everything else (a 24 GB Mac works);
- native Linux: a 16 GB machine run without a desktop, where Docker shares the machine's RAM;
- Docker, usable without
sudo, with 6 CPUs and memory:- Docker Desktop: at least 16.5 GiB (Settings → Resources → Memory ≥ 17 GB);
- native Linux: 15 GiB visible to Docker (
free -g), 14 at the least;
- 40 GiB of free disk where Docker keeps its data;
kubectl≥ 1.36,helm≥ 4.0,minikube≥ 1.39, anduvto install the CLI.
host check checks everything but uv, and says what to fix.
brew install kubernetes-cli helm minikube uv # on Linux, see Installing
uv tool install llm-bonsai # puts `llm-bonsai` on your PATH
llm-bonsai host check # read-only machine check
llm-bonsai host up # a minikube profile of its own: 6 CPUs, 14 GiB, 40 GB
llm-bonsai apply # Ollama, Postgres, Valkey, Langfuse, LiteLLM, then the teams' keys (in the cluster): 6–15 min the first time, ~6.5 GiB of images and models
llm-bonsai status # every piece's pods: ready, restarts, memory; --models asks each model group
llm-bonsai models ls # Ollama's downloads and the model groups that use them; ps, show, pull, rm
llm-bonsai probe smoke # end-to-end check
llm-bonsai ui # the web pages, until Ctrl-C (see "Where to look")
PASS chat completion (1.5s): 'Red.' via chat-small, 42 tokens
PASS streaming (0.3s): 3 chunks → 'Red.'
PASS embeddings (0.3s): 768-dim vector
PASS forbidden model (chat-broken) (0.0s): rejected with HTTP 403
PASS traced in Langfuse (6.5s): 2 generations for smoke-7e9ba901; chat-small: 42 tokens, 0.27s, $0.0045, team tag present
PASS failed call traced in Langfuse (4.2s): ERROR generation: litellm.APIConnectionError: …
all smoke checks passed
apply records what each step applied, in the cluster. Run it again after editing the lab config or upgrading llm-bonsai, and it reruns only the steps the change needs; apply --dry-run lists them first. When you're done, llm-bonsai teardown removes the platform and its data but keeps the cluster, and host down deletes the cluster too. Both ask first.
On a spare machine at home
A lab host, such as a 16 GB Linux notebook without a desktop, runs the cluster and publishes it to your network. Your laptop, the workstation, drives it over the Kubernetes API and opens its pages over HTTPS:
# the lab host, prepared once by hand: SSH with your key, Docker, kubectl, helm, minikube and uv
# on your laptop: kubectl, helm and the CLI installed
llm-bonsai host add you@<lab host> # over SSH: installs the CLI there, writes its host.toml on
# <its ip>.sslip.io, creates the cluster, and joins this laptop
llm-bonsai apply # the platform, plus an ingress with TLS from the platform's own CA
llm-bonsai probe smoke
llm-bonsai ui # lists the pages' URLs
# then trust ~/.config/llm-bonsai/ca.crt in your browser (Installing, step 6)
Installing walks through each step, from preparing the lab host and picking a domain to trusting the CA. Hardening then narrows who on your network reaches it.
Notes
- On Linux: tested end to end on Debian 13 on a 16 GB notebook without a desktop (Docker Engine 29.10, kubectl 1.37, helm 4.3, minikube 1.39). Installing lists what to install.
- On macOS: use Homebrew's
kubectl; the one Docker Desktop ships can be too old. Tested end to end on macOS 26 on Apple Silicon (24 GB, Docker Engine 29.9, kubectl 1.37, helm 4.3, minikube 1.39). - Upgrading and uninstalling: see Installing.
- Your other clusters are safe: the platform has its own kube context, and every command names it. See Configuration for that, for where the credentials live, and for changing the models, teams or ports.
What to try
Each probe opens its own connections, so nothing else needs to run. Each one prints the key and prompt it uses, what happened with real numbers, and a "What you just saw" summary of only what that run showed. probe fallback, abridged:
Requested model chat-broken → HTTP 200 in 3.04s
x-litellm-model-group chat-small
x-litellm-attempted-fallbacks 1
start took outcome backend
+0 ms 14 ms ERROR does-not-exist.models.svc.cluster.local:1234 [Name or service not known]
+40 ms 2910 ms ok ollama_chat/qwen2.5:1.5b
╭─ What you just saw ──────────────────────────────────────────────────────────────────────────────────╮
│ • The client asked for chat-broken and got a normal HTTP 200. Only the response headers say a │
│ fallback happened (attempted-fallbacks: 1, served by model group chat-small). │
│ • Langfuse keeps both attempts under one user id. It records the backend, not the model group, so │
│ the ERROR's message (the dead host) is how you tell which deployment failed. │
│ • The dead backend failed in 14 ms, so the fallback cost almost nothing. A backend that hangs │
│ instead costs up to `timeout` (5 s for chat-broken) × (1 + num_retries) before the fallback │
│ starts, which is why chat-broken has both set low. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
llm-bonsai … |
What you'll see | Takes |
|---|---|---|
probe fallback |
A dead model group still answers HTTP 200, from its fallback; only headers and Langfuse show the failover | seconds |
probe limits |
A 3/min limit returns 429; a budget lets the crossing request through, then returns 422 | ~1.5 min |
probe cache |
A cache hit is dozens of times faster and costs $0; change one parameter and it misses | seconds |
probe replicas |
Two gateway replicas without Valkey let 6 requests through a 3/min limit; with Valkey, 3 | ~2.5 min |
probe chaos |
Deleting the only gateway pod costs a ~20 s outage, nearly all of it pod startup | ~2 min |
probe load |
Past the model server's parallelism, throughput stays flat and time to first token climbs | ~1.5 min |
probe app |
One trace from the app down to the model: retrieval, prompt version, the gateway's call | seconds |
probe eval |
The assistant scored over a dataset; run it with --prompt strict too, and compare |
~40 s |
eval run |
Your own eval suite: cases, a prompt and scorers in one file, each run compared with the last (more) | seconds per case |
chat |
A streamed conversation with the model, as one Langfuse session (more) | interactive |
connect |
Points Claude Code, Codex, aider and other tools on OpenAI's or Anthropic's API at the gateway, with a key of its own (more) | seconds |
usage |
Requests, tokens and spend per team and member, end user or model group, over UTC days (more) | seconds |
Every command takes --help, and llm-bonsai -v <command> echoes each kubectl, helm and minikube call it makes. probe app and probe eval take --prompt strict for the other prompt version, and probe eval --no-judge skips the LLM judge.
Where to look
llm-bonsai ui opens the web pages until Ctrl-C, on these default URLs (llm-bonsai config show has yours). With network exposure, an ingress serves them over HTTPS to other machines instead, and ui lists where. The passwords are in the platform's credentials: llm-bonsai credentials show LITELLM_UI_PASSWORD prints one.
| Page | URL | Log in with |
|---|---|---|
| Langfuse | http://localhost:3000 | LANGFUSE_INIT_USER_EMAIL / LANGFUSE_INIT_USER_PASSWORD |
| LiteLLM | http://localhost:4000/ui | admin / LITELLM_UI_PASSWORD |
| Prometheus (if installed) | http://localhost:9090 | no login |
A short tour:
- Spend per team: LiteLLM → Teams.
payments-aiandsupport-boteach have a budget and their spend. - One team's traffic: Langfuse → Tracing, filter by tag
user_api_key_team_alias:support-bot. The gateway sets it from the key, so clients can't fake it. - A fallback: after
probe fallback, filter Tracing by the user id it prints: anERRORgeneration for the dead backend, then the one that succeeded, milliseconds later. - App and gateway in one trace: follow the link
probe appprints. Its spans and the gateway's call share a trace through onetraceparentheader. - Prompt versions and experiments: Langfuse → Prompts →
support-answer. Thenprobe evalandprobe eval --prompt strict: the second prints a link comparing the two runs side by side. - Your own eval suite:
llm-bonsai eval init capitals, thenllm-bonsai eval run capitals. Edit[prompt]inevals/capitals.toml(in the lab home) and run it again: Langfuse → Prompts →eval-capitalshas both versions, and the run prints a link comparing it with the first. - Metrics: with
[prometheus] enabled = truein the lab config andllm-bonsai apply, Prometheus → Status → Targets shows the gateway podUP. Using the platform has queries to paste.
At scale
The platform works at small scale. A platform for many teams and real traffic keeps the same shape, with more of each piece and guards around it:
- a gateway with several replicas sharing a highly available Redis (
probe replicasshows why); - vLLM on GPU node pools, scaled on queue depth rather than CPU (
probe loadshows why); - Langfuse on a replicated ClickHouse cluster, and eval suites run in CI on every prompt change;
- single sign-on in front of every page, where the platform's network exposure has each page's own login;
- Argo CD applying all of it from git.
The same platform, at scale goes through it piece by piece.
Learn more
- How it's built: the path of one request, then phase by phase with real output and the lessons, from why the node overstates its size to why model servers scale on queue depth.
- At scale: what each piece would change on a bigger platform, and which probe shows why.
- Using the platform yourself:
chat,curland the OpenAI SDK against the gateway,usageper team, member and model, your own eval suites, and PromQL for its metrics. - Connecting your own tools: Claude Code, Codex, aider,
llm, the SDKs and your scripts on the platform's model groups, each with a key of its own. - Installing: step by step, on one machine, or on a lab host on your network used from a workstation.
- Configuration: the lab home, every setting in
bonsai.toml(ports, models, teams) andhost.toml(the cluster's size, what it publishes), and how the platform stays in its own cluster. - Memory budget: what each piece uses, idle and at peak.
- Troubleshooting: known symptoms, causes and fixes.
- Pinned versions: every chart, image and tool version.
- Contributing: the dev loop, the ground rules and the repository layout.
- Releases: the changelog.
Security
All credentials are random, dev-only values, kept in one Secret in the platform's cluster. No real provider key is ever needed; one you add for a provider's model group stays in the gateway, and clients only hold the gateway's keys. By default nothing listens beyond this machine: the web pages are reached only through kubectl port-forward on loopback. With network exposure, which you turn on, other machines on your network reach the pages over HTTPS through an ingress, each page behind a login of its own (the LiteLLM UI's isn't the master key), and the Kubernetes API with a certificate per workstation. Hardening narrows that to your LAN and your workstations. Inside the cluster, network policies keep each namespace to itself: the gateway's Valkey has no password, and only the gateway's namespace reaches it.
License
Apache License 2.0. Use, change and share it as you like, including commercially. If you redistribute it or something built on it, keep the NOTICE file, which credits the original project, and mark the files you changed.
Metadata
Release files for llm-bonsai 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_bonsai-0.4.0.tar.gz | 332.3 kB | With provenance | Details for llm_bonsai-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_bonsai-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for llm_bonsai-0.4.0-py3-none-any.whl |
Total release size: 563.1 kB
Release files / llm_bonsai-0.4.0.tar.gz
| Download URL | llm_bonsai-0.4.0.tar.gz |
|---|---|
| Size | 332.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9821a4329d296e06a792506afeff7eb0204e690365cd28914008e5f5365caaf0
|
|
BLAKE2b-256 checksum How to use checksums |
9e478c42f8f1effef794e211d62f80fa5c9ee4ef7cef1c5681a17250bc0663c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / llm_bonsai-0.4.0-py3-none-any.whl
| Download URL | llm_bonsai-0.4.0-py3-none-any.whl |
|---|---|
| Size | 230.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97c95af71780033521583aadef902c1241f70df56f2cc90cefcf21498a444e24
|
|
BLAKE2b-256 checksum How to use checksums |
f1fa9f78ec9f05e807e5922cfd264ab944b68a0854e8f93b28ba9ee1cdd5033f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for llm-bonsai 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for llm_bonsai-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.