llm-bonsai 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. llm_bonsai-0.4.0/CONTRIBUTING.md +117 -0
  2. llm_bonsai-0.4.0/LICENSE +202 -0
  3. llm_bonsai-0.4.0/Makefile +38 -0
  4. llm_bonsai-0.4.0/NOTICE +6 -0
  5. llm_bonsai-0.4.0/PKG-INFO +244 -0
  6. llm_bonsai-0.4.0/README.md +202 -0
  7. llm_bonsai-0.4.0/docs/adr/0001-local-first-network-later.md +7 -0
  8. llm_bonsai-0.4.0/docs/adr/0002-network-exposure.md +52 -0
  9. llm_bonsai-0.4.0/docs/adr/0003-lab-host-and-workstation.md +34 -0
  10. llm_bonsai-0.4.0/docs/adr/0004-your-own-provider.md +23 -0
  11. llm_bonsai-0.4.0/docs/adr/0005-the-lab-host-over-ssh.md +24 -0
  12. llm_bonsai-0.4.0/docs/at-scale.md +78 -0
  13. llm_bonsai-0.4.0/docs/configuration.md +226 -0
  14. llm_bonsai-0.4.0/docs/connect.md +100 -0
  15. llm_bonsai-0.4.0/docs/hardening.md +167 -0
  16. llm_bonsai-0.4.0/docs/how-its-built.md +511 -0
  17. llm_bonsai-0.4.0/docs/install.md +220 -0
  18. llm_bonsai-0.4.0/docs/memory.md +46 -0
  19. llm_bonsai-0.4.0/docs/pinned-versions.md +19 -0
  20. llm_bonsai-0.4.0/docs/troubleshooting.md +64 -0
  21. llm_bonsai-0.4.0/docs/using-the-lab.md +204 -0
  22. llm_bonsai-0.4.0/pyproject.toml +148 -0
  23. llm_bonsai-0.4.0/pyproject.toml.orig +131 -0
  24. llm_bonsai-0.4.0/scripts/check_infra.py +85 -0
  25. llm_bonsai-0.4.0/src/llm_bonsai/__init__.py +5 -0
  26. llm_bonsai-0.4.0/src/llm_bonsai/__main__.py +3 -0
  27. llm_bonsai-0.4.0/src/llm_bonsai/catalog.py +188 -0
  28. llm_bonsai-0.4.0/src/llm_bonsai/cli.py +195 -0
  29. llm_bonsai-0.4.0/src/llm_bonsai/clients/__init__.py +2 -0
  30. llm_bonsai-0.4.0/src/llm_bonsai/clients/credentials.py +127 -0
  31. llm_bonsai-0.4.0/src/llm_bonsai/clients/gateway.py +257 -0
  32. llm_bonsai-0.4.0/src/llm_bonsai/clients/kube.py +243 -0
  33. llm_bonsai-0.4.0/src/llm_bonsai/clients/lab.py +68 -0
  34. llm_bonsai-0.4.0/src/llm_bonsai/clients/langfuse.py +129 -0
  35. llm_bonsai-0.4.0/src/llm_bonsai/clients/ollama.py +71 -0
  36. llm_bonsai-0.4.0/src/llm_bonsai/clients/registry.py +44 -0
  37. llm_bonsai-0.4.0/src/llm_bonsai/clients/shell.py +33 -0
  38. llm_bonsai-0.4.0/src/llm_bonsai/clients/tunnels.py +164 -0
  39. llm_bonsai-0.4.0/src/llm_bonsai/commands/__init__.py +5 -0
  40. llm_bonsai-0.4.0/src/llm_bonsai/commands/apply.py +225 -0
  41. llm_bonsai-0.4.0/src/llm_bonsai/commands/chat.py +301 -0
  42. llm_bonsai-0.4.0/src/llm_bonsai/commands/config.py +240 -0
  43. llm_bonsai-0.4.0/src/llm_bonsai/commands/connect.py +83 -0
  44. llm_bonsai-0.4.0/src/llm_bonsai/commands/context.py +59 -0
  45. llm_bonsai-0.4.0/src/llm_bonsai/commands/credentials.py +137 -0
  46. llm_bonsai-0.4.0/src/llm_bonsai/commands/debug.py +38 -0
  47. llm_bonsai-0.4.0/src/llm_bonsai/commands/evals.py +149 -0
  48. llm_bonsai-0.4.0/src/llm_bonsai/commands/host.py +238 -0
  49. llm_bonsai-0.4.0/src/llm_bonsai/commands/logs.py +63 -0
  50. llm_bonsai-0.4.0/src/llm_bonsai/commands/models.py +206 -0
  51. llm_bonsai-0.4.0/src/llm_bonsai/commands/probe.py +127 -0
  52. llm_bonsai-0.4.0/src/llm_bonsai/commands/setup.py +106 -0
  53. llm_bonsai-0.4.0/src/llm_bonsai/commands/status.py +281 -0
  54. llm_bonsai-0.4.0/src/llm_bonsai/commands/teardown.py +28 -0
  55. llm_bonsai-0.4.0/src/llm_bonsai/commands/ui.py +70 -0
  56. llm_bonsai-0.4.0/src/llm_bonsai/commands/usage.py +193 -0
  57. llm_bonsai-0.4.0/src/llm_bonsai/commands/workstations.py +186 -0
  58. llm_bonsai-0.4.0/src/llm_bonsai/config/__init__.py +1 -0
  59. llm_bonsai-0.4.0/src/llm_bonsai/config/access.py +54 -0
  60. llm_bonsai-0.4.0/src/llm_bonsai/config/env.py +29 -0
  61. llm_bonsai-0.4.0/src/llm_bonsai/config/host_config.py +227 -0
  62. llm_bonsai-0.4.0/src/llm_bonsai/config/lab_config.py +512 -0
  63. llm_bonsai-0.4.0/src/llm_bonsai/config/location.py +85 -0
  64. llm_bonsai-0.4.0/src/llm_bonsai/config/toml_file.py +123 -0
  65. llm_bonsai-0.4.0/src/llm_bonsai/core/__init__.py +5 -0
  66. llm_bonsai-0.4.0/src/llm_bonsai/core/apply.py +244 -0
  67. llm_bonsai-0.4.0/src/llm_bonsai/core/assistant.py +184 -0
  68. llm_bonsai-0.4.0/src/llm_bonsai/core/chat.py +109 -0
  69. llm_bonsai-0.4.0/src/llm_bonsai/core/connect.py +182 -0
  70. llm_bonsai-0.4.0/src/llm_bonsai/core/debug.py +190 -0
  71. llm_bonsai-0.4.0/src/llm_bonsai/core/evals/__init__.py +2 -0
  72. llm_bonsai-0.4.0/src/llm_bonsai/core/evals/run.py +431 -0
  73. llm_bonsai-0.4.0/src/llm_bonsai/core/evals/scorers.py +100 -0
  74. llm_bonsai-0.4.0/src/llm_bonsai/core/evals/suite.py +253 -0
  75. llm_bonsai-0.4.0/src/llm_bonsai/core/install/__init__.py +1 -0
  76. llm_bonsai-0.4.0/src/llm_bonsai/core/install/applied.py +101 -0
  77. llm_bonsai-0.4.0/src/llm_bonsai/core/install/credentials.py +128 -0
  78. llm_bonsai-0.4.0/src/llm_bonsai/core/install/infra.py +612 -0
  79. llm_bonsai-0.4.0/src/llm_bonsai/core/install/ingress.py +212 -0
  80. llm_bonsai-0.4.0/src/llm_bonsai/core/install/preflight.py +402 -0
  81. llm_bonsai-0.4.0/src/llm_bonsai/core/install/prometheus.py +33 -0
  82. llm_bonsai-0.4.0/src/llm_bonsai/core/logs.py +49 -0
  83. llm_bonsai-0.4.0/src/llm_bonsai/core/ollama.py +161 -0
  84. llm_bonsai-0.4.0/src/llm_bonsai/core/pages.py +126 -0
  85. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/__init__.py +5 -0
  86. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/app.py +132 -0
  87. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/cache.py +121 -0
  88. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/chaos.py +178 -0
  89. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/evaluation.py +189 -0
  90. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/fallback.py +106 -0
  91. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/limits.py +203 -0
  92. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/load.py +244 -0
  93. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/replicas.py +170 -0
  94. llm_bonsai-0.4.0/src/llm_bonsai/core/probes/smoke.py +123 -0
  95. llm_bonsai-0.4.0/src/llm_bonsai/core/remote.py +222 -0
  96. llm_bonsai-0.4.0/src/llm_bonsai/core/status.py +349 -0
  97. llm_bonsai-0.4.0/src/llm_bonsai/core/teams.py +246 -0
  98. llm_bonsai-0.4.0/src/llm_bonsai/core/usage.py +267 -0
  99. llm_bonsai-0.4.0/src/llm_bonsai/core/workstations.py +232 -0
  100. llm_bonsai-0.4.0/src/llm_bonsai/errors.py +5 -0
  101. llm_bonsai-0.4.0/src/llm_bonsai/infra/cert-manager/values.yaml +23 -0
  102. llm_bonsai-0.4.0/src/llm_bonsai/infra/langfuse/values.yaml +126 -0
  103. llm_bonsai-0.4.0/src/llm_bonsai/infra/litellm/values.yaml +120 -0
  104. llm_bonsai-0.4.0/src/llm_bonsai/infra/namespaces.yaml +21 -0
  105. llm_bonsai-0.4.0/src/llm_bonsai/infra/network-policies.yaml +162 -0
  106. llm_bonsai-0.4.0/src/llm_bonsai/infra/ollama/values.yaml +15 -0
  107. llm_bonsai-0.4.0/src/llm_bonsai/infra/postgres/postgres.yaml +70 -0
  108. llm_bonsai-0.4.0/src/llm_bonsai/infra/prometheus/prometheus.yaml +141 -0
  109. llm_bonsai-0.4.0/src/llm_bonsai/infra/traefik/values.yaml +30 -0
  110. llm_bonsai-0.4.0/src/llm_bonsai/infra/valkey/valkey.yaml +56 -0
  111. llm_bonsai-0.4.0/src/llm_bonsai/models/__init__.py +4 -0
  112. llm_bonsai-0.4.0/src/llm_bonsai/models/base.py +25 -0
  113. llm_bonsai-0.4.0/src/llm_bonsai/models/gateway.py +43 -0
  114. llm_bonsai-0.4.0/src/llm_bonsai/models/kube.py +165 -0
  115. llm_bonsai-0.4.0/src/llm_bonsai/models/lab.py +80 -0
  116. llm_bonsai-0.4.0/src/llm_bonsai/models/langfuse.py +31 -0
  117. llm_bonsai-0.4.0/src/llm_bonsai/models/ollama.py +62 -0
  118. llm_bonsai-0.4.0/src/llm_bonsai/models/usage.py +68 -0
  119. llm_bonsai-0.4.0/src/llm_bonsai/py.typed +0 -0
  120. llm_bonsai-0.4.0/src/llm_bonsai/report.py +160 -0
  121. llm_bonsai-0.4.0/tests/conftest.py +7 -0
  122. llm_bonsai-0.4.0/tests/fakes.py +102 -0
  123. llm_bonsai-0.4.0/tests/test_apply.py +687 -0
  124. llm_bonsai-0.4.0/tests/test_assistant.py +54 -0
  125. llm_bonsai-0.4.0/tests/test_chat.py +257 -0
  126. llm_bonsai-0.4.0/tests/test_cli.py +368 -0
  127. llm_bonsai-0.4.0/tests/test_connect.py +261 -0
  128. llm_bonsai-0.4.0/tests/test_credentials.py +116 -0
  129. llm_bonsai-0.4.0/tests/test_debug.py +128 -0
  130. llm_bonsai-0.4.0/tests/test_docs.py +131 -0
  131. llm_bonsai-0.4.0/tests/test_evals.py +357 -0
  132. llm_bonsai-0.4.0/tests/test_gateway.py +322 -0
  133. llm_bonsai-0.4.0/tests/test_host.py +281 -0
  134. llm_bonsai-0.4.0/tests/test_host_config.py +102 -0
  135. llm_bonsai-0.4.0/tests/test_kube.py +724 -0
  136. llm_bonsai-0.4.0/tests/test_lab_config.py +313 -0
  137. llm_bonsai-0.4.0/tests/test_logs.py +48 -0
  138. llm_bonsai-0.4.0/tests/test_models.py +306 -0
  139. llm_bonsai-0.4.0/tests/test_preflight.py +161 -0
  140. llm_bonsai-0.4.0/tests/test_probes.py +44 -0
  141. llm_bonsai-0.4.0/tests/test_status.py +413 -0
  142. llm_bonsai-0.4.0/tests/test_takeaways.py +248 -0
  143. llm_bonsai-0.4.0/tests/test_tunnels.py +58 -0
  144. llm_bonsai-0.4.0/tests/test_usage.py +306 -0
  145. llm_bonsai-0.4.0/tests/test_workstations.py +320 -0
@@ -0,0 +1,117 @@
1
+ # Contributing
2
+
3
+ Issues and pull requests are welcome. For anything larger than a fix, open an issue first so we can agree on the shape.
4
+
5
+ ## Dev loop
6
+
7
+ ```bash
8
+ git clone https://github.com/cauabernardino/llm-bonsai && cd llm-bonsai
9
+ uv sync # Python 3.12+, dev tools included
10
+ make check # ruff, mypy and pyright (strict), pytest: what CI runs (CI also runs `uv build`)
11
+ # pytest runs the tests in a random order (pytest-randomly); its header prints
12
+ # the seed, and `uv run pytest --randomly-seed=N` replays that order
13
+ uv run llm-bonsai --help # the CLI from your checkout; it uses the lab home (below)
14
+ make infra # renders what `apply` installs and validates it with kubeconform: needs helm,
15
+ # kubeconform and the network, and CI runs it too
16
+ ```
17
+
18
+ `make check` needs no cluster: the tests cover the pure logic (parsers, takeaways, preflight rules, argv building) against fakes. Anything that talks to the platform is checked by running it: `uv run llm-bonsai probe smoke` is the end-to-end test. Say in the PR which probes you ran, and on what machine.
19
+
20
+ In a checkout, commands run as `uv run llm-bonsai …`. They use the same [lab home](docs/configuration.md#lab-home) as an installed CLI, `~/.config/llm-bonsai`, unless you point `LLM_BONSAI_HOME` elsewhere. For a platform of its own while developing, `export LLM_BONSAI_HOME=$PWD`: the checkout's `bonsai.toml`, `evals/`, `ca.crt` and `kubeconfig` are git-ignored. The credentials are in the dev cluster. The tests never touch a lab home: `tests/conftest.py` gives each one an empty folder. The Makefile has shortcuts (`make` lists them): `make up` (`apply`), `make smoke`, `make ui`, `make down` (`teardown`), `make nuke` (`host down`).
21
+
22
+ Working with a coding agent? [AGENTS.md](AGENTS.md) gives it the rules, how to verify a change, and the gotchas. [GLOSSARY.md](GLOSSARY.md) is the vocabulary for code, output and docs.
23
+
24
+ ## Ground rules
25
+
26
+ A PR that breaks one of these needs to say why.
27
+
28
+ - **Never need a paid API key.** Everything runs on local models by default, and every probe works without a provider. A provider's model group is the user's choice, with their own key ([ADR 0004](docs/adr/0004-your-own-provider.md)); no default, probe team or test may depend on one.
29
+ - **No Bitnami images or charts.** Use official images, with plain manifests when there's no official chart.
30
+ - **One replica of everything, small models, tight limits.** Probes that need more (like `probe replicas`) scale up and put things back.
31
+ - **Stay inside the memory budget.** The cluster gets 14 GiB. A new piece needs requests and limits, and its measured RAM goes in the [memory budget](docs/memory.md) table.
32
+ - **Pin every version.** No `latest`, no floating chart versions.
33
+ - **Teach.** Output says what happened, with real numbers, and only claims what that run showed.
34
+
35
+ ## Where things live
36
+
37
+ - **Chart versions and the Kubernetes version:** `src/llm_bonsai/core/install/infra.py`. Images installed by a chart follow its version; the first line of each values file records which.
38
+ - **Images of the plain manifests** (Postgres, Valkey, Prometheus): the manifests under `src/llm_bonsai/infra/`, and `probe replicas`' curl client in `core/probes/replicas.py`. Each is pinned by tag and digest, `image:tag@sha256:…`, so a re-pushed tag can't change what runs. The digest is the multi-arch index's, which serves both arm64 and amd64: `docker buildx imagetools inspect image:tag` prints it.
39
+ - **Tool floors and host requirements:** `src/llm_bonsai/core/install/preflight.py`. The kubectl floor follows the Kubernetes version.
40
+ - **Python dependencies:** `pyproject.toml` sets the ranges, `uv.lock` pins them. Run `uv lock` after changing them; CI fails on a stale lock. Each range stops below the next breaking release, because `uv tool install` ignores the lock and the caps are all an installed CLI gets. Dependabot widens them monthly.
41
+
42
+ Renovate proposes the bumps monthly (`.github/renovate.json5`): the charts, the images, Kubernetes patches and the tools CI downloads. Each version lives in the code, the first line of its values file and its row in [Pinned versions](docs/pinned-versions.md), and one PR changes all three. `tests/test_docs.py` checks that they agree and keeps them in the form Renovate matches. Two things it can't do: the app version a chart ships (beside the chart's, in the values file and the table) needs a hand, and a Kubernetes minor needs a newer minikube, so it's yours to do. CI renders every chart with its values (`make infra`), which catches a values key a chart no longer has only if the schema rejects it: on a live platform, `apply` and `probe smoke` remain the test.
43
+
44
+ When you bump a version by hand, change the same three places, and, for Kubernetes or a tool floor, the requirements in the README's quick start and in [Installing](docs/install.md#what-each-machine-needs).
45
+
46
+ The default model groups and the lab config's schema are in `src/llm_bonsai/config/lab_config.py`; the gateway's model list and Ollama's pull list are generated from them (`core/install/infra.py`). The probe teams, their limits and `chat-broken` are in `src/llm_bonsai/catalog.py`; `core/teams.py` turns them and the lab config's teams into what the gateway should have.
47
+
48
+ ## Repository layout
49
+
50
+ ```
51
+ Makefile shortcuts for the CLI, plus `make check` and `make infra`
52
+ scripts/check_infra.py renders the charts and manifests for kubeconform, without a cluster
53
+ src/llm_bonsai/ the package behind the `llm-bonsai` command
54
+ infra/ what the CLI installs (Helm values, plain manifests); ships in the wheel
55
+ cli.py the root app: registers every command, turns failures into messages
56
+ catalog.py namespaces, Services, components, the probe teams and chat-broken
57
+ report.py output conventions every probe follows
58
+ errors.py LabError, the expected failure every layer raises
59
+ config/ location (lab home, kube context, infra files), env (credentials as a .env
60
+ file: backups and imports), lab_config (bonsai.toml), host_config (host.toml, and what the lab
61
+ host records in the cluster), access (the URLs, from both), toml_file (strict,
62
+ versioned TOML, shared with eval suites)
63
+ models/ records, one module per context: base, lab, kube, gateway, usage, langfuse
64
+ clients/ shell, Kube (pinned kubectl/helm), port-forward tunnels, Gateway, Langfuse, Ollama, and
65
+ Lab: the clients one command uses, closed (with its port-forwards) when it ends
66
+ core/ the domains, free of the CLI: chat, connect, status, logs, debug, usage, teams, pages, ollama, assistant,
67
+ remote (where the platform runs, and the lab host over SSH), workstations (`join`: certificates of their own),
68
+ apply (which steps a lab config change needs)
69
+ install/ host checks, cluster, secrets, Helm releases, the ingress, the Prometheus scrape key,
70
+ applied (what each step last applied, recorded in the cluster)
71
+ evals/ eval suites: the file schema, scorers, runs; `probe eval` is a built-in suite
72
+ probes/ one module per probe
73
+ commands/ the CLI layer: one module per command or group
74
+ tests/ unit tests for the pure logic; no cluster needed
75
+ docs/ the guides linked from the README; adr/ for decisions
76
+ AGENTS.md context for coding agents
77
+ GLOSSARY.md the project's vocabulary
78
+ ```
79
+
80
+ ## Adding a probe
81
+
82
+ 1. Add a module under `src/llm_bonsai/core/probes/` with a `run(lab: Lab)` function.
83
+ 2. Get clients from `lab`, never build your own. That way port-forwards close when the command ends.
84
+ 3. Follow the conventions in `report.py`. `probe smoke`, a pass/fail check, is the one exception.
85
+ - `report.header` names the key and the prompt.
86
+ - Tables show what happened.
87
+ - `report.summary` ends the probe with "What you just saw", plus at most one `not_shown=` point.
88
+ 4. Build the bullets in a pure function (`takeaways(...)` in most probes) and test it in `tests/test_takeaways.py`. Include the branch where the platform misbehaves.
89
+ 5. Register the command in `src/llm_bonsai/commands/probe.py` and in the command tree in `tests/test_cli.py`.
90
+ 6. Add a row to the probe table in the README.
91
+
92
+ ## Code and commits
93
+
94
+ - Type everything. `make check` runs both mypy and pyright in strict mode.
95
+ - Comments explain why, not what. Leave out notes about how the code came to be.
96
+ - Commits get a title that says what changed and a short body that says why. One concern per commit. Pull requests are squash-merged, so the PR title becomes the commit title.
97
+
98
+ ## Releasing
99
+
100
+ For maintainers. Releases are cut by hand, whenever there's something worth shipping. The commit titles since the last tag become the release notes, and the [Releases](https://github.com/cauabernardino/llm-bonsai/releases) page is the changelog.
101
+
102
+ 1. Open a pull request that bumps the version: `uv version --bump minor` (or `patch`, `major`) updates `pyproject.toml` and `uv.lock`. Title it `Release X.Y.Z`.
103
+ 2. Once it's merged, tag the merge commit and push only the tag:
104
+
105
+ ```bash
106
+ git switch main && git pull
107
+ git tag "v$(uv version --short)"
108
+ git push origin "v$(uv version --short)" # the release workflow checks, builds and publishes
109
+ ```
110
+
111
+ The workflow checks and builds the package, installs the wheel on its own to run it, publishes it to PyPI, then creates the GitHub Release with `SHA256SUMS` and build provenance. PyPI takes it through Trusted Publishing, so no token is stored anywhere. That needs, once: the repository's `pypi` environment (Settings → Environments), and on PyPI a trusted publisher for the project `llm-bonsai`, repository `cauabernardino/llm-bonsai`, workflow `release.yml`, environment `pypi`.
112
+
113
+ The workflow refuses a tag that isn't on `main` or doesn't match the version in `pyproject.toml`. If it fails before PyPI, fix the cause through a pull request, then move the tag to the new commit: `git push origin :refs/tags/vX.Y.Z`, tag again and push. Once PyPI has the package, it never takes that version again: rerun the failed jobs (the upload skips what PyPI already has), or release the fix as the next patch version.
114
+
115
+ Between releases, a checkout reports the last release's version while it carries newer charts. `apply` from a checkout stamps the platform with that version, so an installed CLI of the same version isn't refused: apply from a checkout only on a platform you'll keep driving from one.
116
+
117
+ Before 1.0, a minor bump may break things. When one does, add a line saying so to its release notes (`gh release edit` or the Releases page).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,38 @@
1
+ # Shortcuts for the common flows. The CLI is the real interface: `uv run llm-bonsai --help`.
2
+ CLI := uv run llm-bonsai
3
+
4
+ .PHONY: help preflight cluster up down nuke smoke ui check infra
5
+
6
+ help: ## List these shortcuts (a new lab: make preflight cluster up smoke)
7
+ @grep -E '^[a-z]+:.*## ' $(MAKEFILE_LIST) | sed -E 's/:.*## /\t/' | expand -t 12
8
+
9
+ preflight: ## host check: check this machine, read-only
10
+ $(CLI) host check
11
+
12
+ cluster: ## host up: the platform's own minikube profile
13
+ $(CLI) host up
14
+
15
+ up: ## apply: install the platform, or bring it up to date
16
+ $(CLI) apply
17
+
18
+ down: ## teardown: remove the platform and its data, keep the cluster
19
+ $(CLI) teardown
20
+
21
+ nuke: ## host down: delete the cluster too
22
+ $(CLI) host down
23
+
24
+ smoke: ## probe smoke: end-to-end check
25
+ $(CLI) probe smoke
26
+
27
+ ui: ## ui: the web pages on localhost:3000, :4000 and :9090 by default, until Ctrl-C
28
+ $(CLI) ui
29
+
30
+ check: ## ruff, mypy and pyright (strict), pytest: no cluster needed
31
+ uv run ruff check
32
+ uv run ruff format --check
33
+ uv run mypy
34
+ uv run pyright
35
+ uv run pytest
36
+
37
+ infra: ## render the charts and manifests and validate them with kubeconform: needs helm and kubeconform
38
+ uv run python scripts/check_infra.py
@@ -0,0 +1,6 @@
1
+ llm-bonsai
2
+ Copyright 2026 Cauã Bernardino
3
+ https://github.com/cauabernardino/llm-bonsai
4
+
5
+ This product includes software developed by Cauã Bernardino as part of
6
+ llm-bonsai, licensed under the Apache License, Version 2.0 (see LICENSE).
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-bonsai
3
+ Version: 0.4.0
4
+ Summary: A real GenAI platform, kept tiny: an OpenAI-compatible LLM gateway with team keys, budgets, traces and evals over local models or your own provider, on a laptop or a home server, built and probed by one CLI.
5
+ Keywords: llm,genai,llm-gateway,openai-compatible,litellm,langfuse,ollama,kubernetes,observability,evals,platform-engineering,self-hosted,homelab
6
+ Author: Cauã Bernardino
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Education
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: System :: Systems Administration
24
+ Classifier: Typing :: Typed
25
+ Requires-Dist: certifi>=2024.2.2
26
+ Requires-Dist: cryptography>=50.0.2,<51
27
+ Requires-Dist: httpx>=0.29.0,<0.30
28
+ Requires-Dist: langfuse>=5.2,<6
29
+ Requires-Dist: openai>=3.60.0,<4
30
+ Requires-Dist: pydantic>=2.14.4,<3
31
+ Requires-Dist: python-dotenv>=1.2.4,<2
32
+ Requires-Dist: rich>=15.0.0,<16
33
+ Requires-Dist: tomli-w>=1.2.0,<2
34
+ Requires-Dist: typer>=0.29.3,<0.30
35
+ Requires-Python: >=3.12
36
+ Project-URL: Homepage, https://github.com/cauabernardino/llm-bonsai
37
+ Project-URL: Documentation, https://github.com/cauabernardino/llm-bonsai#readme
38
+ Project-URL: Repository, https://github.com/cauabernardino/llm-bonsai
39
+ Project-URL: Issues, https://github.com/cauabernardino/llm-bonsai/issues
40
+ Project-URL: Changelog, https://github.com/cauabernardino/llm-bonsai/releases
41
+ Description-Content-Type: text/markdown
42
+
43
+ # llm-bonsai
44
+
45
+ [![check](https://github.com/cauabernardino/llm-bonsai/actions/workflows/check.yml/badge.svg)](https://github.com/cauabernardino/llm-bonsai/actions/workflows/check.yml)
46
+
47
+ > A real GenAI platform, deliberately kept tiny. Same structure, carefully pruned to fit small machines.
48
+
49
+ 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.
50
+
51
+ - **Run it on your laptop,** or on a spare machine at home that your laptop drives.
52
+ - **One lab config, one CLI.** `bonsai.toml` describes the platform: its models, teams and ports (a spare machine adds `host.toml`, for what it publishes). `llm-bonsai` builds the platform from it, checks it, and explains what each run showed, with real numbers.
53
+ - **Real components, shrunk.** Official images and charts with real config, at one replica, small models and tight limits. No paid API key needed.
54
+ - **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](docs/adr/) and [How it's built](docs/how-its-built.md).
55
+
56
+ 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.
57
+
58
+ ## Who it's for
59
+
60
+ - **Platform engineers** who want to see a gateway, per-team budgets, tracing and evals working together.
61
+ - **Developers building on LLMs** who want a local OpenAI-compatible endpoint with real keys, limits and traces.
62
+ - **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.
63
+
64
+ | Component | Plays the role of | Namespace |
65
+ |---|---|---|
66
+ | [LiteLLM](https://docs.litellm.ai/) | The LLM gateway: one OpenAI-compatible endpoint, per-team keys, budgets, rate limits, fallbacks, caching | `gateway` |
67
+ | Postgres, [Valkey](https://valkey.io/) | The gateway's system of record (keys, teams, spend), and its shared counters and cache | `gateway` |
68
+ | [Ollama](https://ollama.com/) with `qwen2.5:1.5b` (or [your models](docs/configuration.md#models)) | Self-hosted model serving, on CPU (vLLM on GPUs at scale) | `models` |
69
+ | [Langfuse](https://langfuse.com/) | Tracing, prompt versions, datasets and scored experiments | `observability` |
70
+ | [Prometheus](https://prometheus.io/) (optional) | The gateway's requests, spend and latency over time | `observability` |
71
+
72
+ ```mermaid
73
+ flowchart LR
74
+ PY["llm-bonsai CLI / support assistant"] --> LL["LiteLLM (gateway)"]
75
+ LL --> OL["Ollama: qwen2.5:1.5b (CPU)"]
76
+ LL --> PG[("Postgres: keys, teams, spend")]
77
+ LL --> VK[("Valkey: cache + shared limits")]
78
+ LL -- "OpenTelemetry" --> LF["Langfuse"]
79
+ PY -- "Langfuse SDK spans" --> LF
80
+ PR["Prometheus (optional)"] -- "scrapes /metrics" --> LL
81
+ ```
82
+
83
+ ## Quick start
84
+
85
+ Two ways to run it: [on one machine](#on-one-machine), your laptop or desktop, or [on a spare machine at home](#on-a-spare-machine-at-home) that your laptop drives.
86
+
87
+ ### On one machine
88
+
89
+ You need:
90
+
91
+ - macOS or Linux, on arm64 or amd64, with enough memory:
92
+ - **macOS:** about 21 GiB, Docker Desktop's share below plus 4 GiB for everything else (a 24 GB Mac works);
93
+ - **native Linux:** a 16 GB machine run without a desktop, where Docker shares the machine's RAM;
94
+ - Docker, usable without `sudo`, with 6 CPUs and memory:
95
+ - **Docker Desktop:** at least 16.5 GiB (Settings → Resources → Memory ≥ 17 GB);
96
+ - **native Linux:** 15 GiB visible to Docker (`free -g`), 14 at the least;
97
+ - 40 GiB of free disk where Docker keeps its data;
98
+ - `kubectl` ≥ 1.36, `helm` ≥ 4.0, `minikube` ≥ 1.39, and [`uv`](https://docs.astral.sh/uv/) to install the CLI.
99
+
100
+ `host check` checks everything but `uv`, and says what to fix.
101
+
102
+ ```bash
103
+ brew install kubernetes-cli helm minikube uv # on Linux, see Installing
104
+ uv tool install llm-bonsai # puts `llm-bonsai` on your PATH
105
+
106
+ llm-bonsai host check # read-only machine check
107
+ llm-bonsai host up # a minikube profile of its own: 6 CPUs, 14 GiB, 40 GB
108
+ 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
109
+ llm-bonsai status # every piece's pods: ready, restarts, memory; --models asks each model group
110
+ llm-bonsai models ls # Ollama's downloads and the model groups that use them; ps, show, pull, rm
111
+ llm-bonsai probe smoke # end-to-end check
112
+ llm-bonsai ui # the web pages, until Ctrl-C (see "Where to look")
113
+ ```
114
+
115
+ ```
116
+ PASS chat completion (1.5s): 'Red.' via chat-small, 42 tokens
117
+ PASS streaming (0.3s): 3 chunks → 'Red.'
118
+ PASS embeddings (0.3s): 768-dim vector
119
+ PASS forbidden model (chat-broken) (0.0s): rejected with HTTP 403
120
+ PASS traced in Langfuse (6.5s): 2 generations for smoke-7e9ba901; chat-small: 42 tokens, 0.27s, $0.0045, team tag present
121
+ PASS failed call traced in Langfuse (4.2s): ERROR generation: litellm.APIConnectionError: …
122
+ all smoke checks passed
123
+ ```
124
+
125
+ `apply` records what each step applied, in the cluster. Run it again after editing the [lab config](docs/configuration.md#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.
126
+
127
+ ### On a spare machine at home
128
+
129
+ 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:
130
+
131
+ ```bash
132
+ # the lab host, prepared once by hand: SSH with your key, Docker, kubectl, helm, minikube and uv
133
+ # on your laptop: kubectl, helm and the CLI installed
134
+ llm-bonsai host add you@<lab host> # over SSH: installs the CLI there, writes its host.toml on
135
+ # <its ip>.sslip.io, creates the cluster, and joins this laptop
136
+ llm-bonsai apply # the platform, plus an ingress with TLS from the platform's own CA
137
+ llm-bonsai probe smoke
138
+ llm-bonsai ui # lists the pages' URLs
139
+ # then trust ~/.config/llm-bonsai/ca.crt in your browser (Installing, step 6)
140
+ ```
141
+
142
+ [Installing](docs/install.md#a-lab-host-and-a-workstation) walks through each step, from preparing the lab host and picking a domain to trusting the CA. [Hardening](docs/hardening.md) then narrows who on your network reaches it.
143
+
144
+ ### Notes
145
+
146
+ - **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](docs/install.md#1-prepare-the-lab-host) lists what to install.
147
+ - **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).
148
+ - **Upgrading and uninstalling:** see [Installing](docs/install.md#upgrading-and-uninstalling).
149
+ - **Your other clusters are safe:** the platform has its own kube context, and every command names it. See [Configuration](docs/configuration.md) for that, for where the credentials live, and for changing the models, teams or ports.
150
+
151
+ ## What to try
152
+
153
+ 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:
154
+
155
+ ```
156
+ Requested model chat-broken → HTTP 200 in 3.04s
157
+ x-litellm-model-group chat-small
158
+ x-litellm-attempted-fallbacks 1
159
+
160
+ start took outcome backend
161
+ +0 ms 14 ms ERROR does-not-exist.models.svc.cluster.local:1234 [Name or service not known]
162
+ +40 ms 2910 ms ok ollama_chat/qwen2.5:1.5b
163
+
164
+ ╭─ What you just saw ──────────────────────────────────────────────────────────────────────────────────╮
165
+ │ • The client asked for chat-broken and got a normal HTTP 200. Only the response headers say a │
166
+ │ fallback happened (attempted-fallbacks: 1, served by model group chat-small). │
167
+ │ • Langfuse keeps both attempts under one user id. It records the backend, not the model group, so │
168
+ │ the ERROR's message (the dead host) is how you tell which deployment failed. │
169
+ │ • The dead backend failed in 14 ms, so the fallback cost almost nothing. A backend that hangs │
170
+ │ instead costs up to `timeout` (5 s for chat-broken) × (1 + num_retries) before the fallback │
171
+ │ starts, which is why chat-broken has both set low. │
172
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
173
+ ```
174
+
175
+ | `llm-bonsai …` | What you'll see | Takes |
176
+ |---|---|---|
177
+ | `probe fallback` | A dead model group still answers HTTP 200, from its fallback; only headers and Langfuse show the failover | seconds |
178
+ | `probe limits` | A 3/min limit returns 429; a budget lets the crossing request through, then returns 422 | ~1.5 min |
179
+ | `probe cache` | A cache hit is dozens of times faster and costs $0; change one parameter and it misses | seconds |
180
+ | `probe replicas` | Two gateway replicas without Valkey let 6 requests through a 3/min limit; with Valkey, 3 | ~2.5 min |
181
+ | `probe chaos` | Deleting the only gateway pod costs a ~20 s outage, nearly all of it pod startup | ~2 min |
182
+ | `probe load` | Past the model server's parallelism, throughput stays flat and time to first token climbs | ~1.5 min |
183
+ | `probe app` | One trace from the app down to the model: retrieval, prompt version, the gateway's call | seconds |
184
+ | `probe eval` | The assistant scored over a dataset; run it with `--prompt strict` too, and compare | ~40 s |
185
+ | `eval run` | Your own eval suite: cases, a prompt and scorers in one file, each run compared with the last ([more](docs/using-the-lab.md#eval-suites)) | seconds per case |
186
+ | `chat` | A streamed conversation with the model, as one Langfuse session ([more](docs/using-the-lab.md#chat-with-the-model)) | interactive |
187
+ | `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](docs/connect.md)) | seconds |
188
+ | `usage` | Requests, tokens and spend per team and member, end user or model group, over UTC days ([more](docs/using-the-lab.md#usage)) | seconds |
189
+
190
+ 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.
191
+
192
+ ## Where to look
193
+
194
+ `llm-bonsai ui` opens the web pages until Ctrl-C, on these default URLs (`llm-bonsai config show` has yours). With [network exposure](docs/install.md#a-lab-host-and-a-workstation), an ingress serves them over HTTPS to other machines instead, and `ui` lists where. The passwords are in the platform's [credentials](docs/configuration.md#credentials): `llm-bonsai credentials show LITELLM_UI_PASSWORD` prints one.
195
+
196
+ | Page | URL | Log in with |
197
+ |---|---|---|
198
+ | Langfuse | http://localhost:3000 | `LANGFUSE_INIT_USER_EMAIL` / `LANGFUSE_INIT_USER_PASSWORD` |
199
+ | LiteLLM | http://localhost:4000/ui | `admin` / `LITELLM_UI_PASSWORD` |
200
+ | Prometheus (if installed) | http://localhost:9090 | no login |
201
+
202
+ A short tour:
203
+
204
+ 1. **Spend per team:** LiteLLM → Teams. `payments-ai` and `support-bot` each have a budget and their spend.
205
+ 2. **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.
206
+ 3. **A fallback:** after `probe fallback`, filter Tracing by the user id it prints: an `ERROR` generation for the dead backend, then the one that succeeded, milliseconds later.
207
+ 4. **App and gateway in one trace:** follow the link `probe app` prints. Its spans and the gateway's call share a trace through one `traceparent` header.
208
+ 5. **Prompt versions and experiments:** Langfuse → Prompts → `support-answer`. Then `probe eval` and `probe eval --prompt strict`: the second prints a link comparing the two runs side by side.
209
+ 6. **Your own eval suite:** `llm-bonsai eval init capitals`, then `llm-bonsai eval run capitals`. Edit `[prompt]` in `evals/capitals.toml` (in the lab home) and run it again: Langfuse → Prompts → `eval-capitals` has both versions, and the run prints a link comparing it with the first.
210
+ 7. **Metrics:** with `[prometheus] enabled = true` in the lab config and `llm-bonsai apply`, Prometheus → Status → Targets shows the gateway pod `UP`. [Using the platform](docs/using-the-lab.md#metrics) has queries to paste.
211
+
212
+ ## At scale
213
+
214
+ 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:
215
+
216
+ - a gateway with several replicas sharing a highly available Redis (`probe replicas` shows why);
217
+ - vLLM on GPU node pools, scaled on queue depth rather than CPU (`probe load` shows why);
218
+ - Langfuse on a replicated ClickHouse cluster, and eval suites run in CI on every prompt change;
219
+ - single sign-on in front of every page, where the platform's network exposure has each page's own login;
220
+ - Argo CD applying all of it from git.
221
+
222
+ [The same platform, at scale](docs/at-scale.md) goes through it piece by piece.
223
+
224
+ ## Learn more
225
+
226
+ - [How it's built](docs/how-its-built.md): 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.
227
+ - [At scale](docs/at-scale.md): what each piece would change on a bigger platform, and which probe shows why.
228
+ - [Using the platform yourself](docs/using-the-lab.md): `chat`, `curl` and the OpenAI SDK against the gateway, `usage` per team, member and model, your own eval suites, and PromQL for its metrics.
229
+ - [Connecting your own tools](docs/connect.md): Claude Code, Codex, aider, `llm`, the SDKs and your scripts on the platform's model groups, each with a key of its own.
230
+ - [Installing](docs/install.md): step by step, on one machine, or on a lab host on your network used from a workstation.
231
+ - [Configuration](docs/configuration.md): the lab home, every setting in `bonsai.toml` (ports, models, teams) and `host.toml` (the cluster's size, what it publishes), and how the platform stays in its own cluster.
232
+ - [Memory budget](docs/memory.md): what each piece uses, idle and at peak.
233
+ - [Troubleshooting](docs/troubleshooting.md): known symptoms, causes and fixes.
234
+ - [Pinned versions](docs/pinned-versions.md): every chart, image and tool version.
235
+ - [Contributing](CONTRIBUTING.md): the dev loop, the ground rules and the repository layout.
236
+ - [Releases](https://github.com/cauabernardino/llm-bonsai/releases): the changelog.
237
+
238
+ ## Security
239
+
240
+ 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](docs/configuration.md#a-providers-models-with-your-key) 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](docs/install.md#a-lab-host-and-a-workstation), 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](docs/hardening.md) 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.
241
+
242
+ ## License
243
+
244
+ [Apache License 2.0](LICENSE). Use, change and share it as you like, including commercially. If you redistribute it or something built on it, keep the [NOTICE](NOTICE) file, which credits the original project, and mark the files you changed.