Reiki is a security proxy that keeps upstream API keys on the Reiki host and gives each client a revocable stream token, so agent and LLM traffic passes one inspectable point.
Dynamic streams ([stream_admin]), runtime Wasm plugins (plugin-wasm) and cost accounting (plugin-cost) are opt-in.
A client sends a stream token to the Reiki listener. Reiki matches the token to a stream, applies limits and plugins, sets the credential from a mode-0600 key file, and records the result. The admin listener exposes health, keys, failures and reload; peers publish read-only health. Traffic that never reaches a Reiki listener is outside its control; see limits and non-goals.
flowchart LR
client[Agent or CLI] -->|stream token| reiki[Reiki client listener]
reiki --> gate[Stream admission and plugins]
gate --> key[Key from mode 0600 file]
key --> provider[Provider API]
reiki --> admin[Admin listener: health, keys, metrics]
Full detail: overview.
Build from a checkout with Rust 1.99 or newer, or install a verified release archive:
git clone https://github.com/ddproxy/reiki.git
cd reiki
make installmake install builds with reiki top and installs one binary to ~/.local/bin (/usr/local/bin as root; PREFIX=/opt/reiki make install picks another prefix). Release verification, directory layout and service setup are in deploy.
This sets up one upstream, one key, one stream and an admin listener. The full walkthrough is docs/quickstart.md; the commands below are the same path. The example upstream is a placeholder: use a real base_url and model from providers.
-
Create key and token files. Config stores hashes; only the client and admin CLIs use raw tokens.
umask 077 printf '%s' "$PROVIDER_KEY" > /etc/reiki/keys/example-a chmod 0600 /etc/reiki/keys/example-a ADMIN_TOKEN=$(openssl rand -hex 32) CLIENT_TOKEN=$(openssl rand -hex 32) printf '%s' "$CLIENT_TOKEN" | reiki hash-token printf '%s' "$ADMIN_TOKEN" | reiki hash-token
Each
hash-tokenprints 64 hex characters. Put the client hash and the admin hash in the config. -
Write
/etc/reiki/reiki.tomlwith those hashes.listen = "127.0.0.1:4097" [admin] listen = "127.0.0.1:4098" token_sha256 = "<64 hex from the admin token>" [upstream.example] base_url = "https://api.example.com/v1" [keys.example-a] upstream = "example" file = "/etc/reiki/keys/example-a" [streams.client-a] token_sha256 = "<64 hex from the client token>" chain = ["example-a"]
-
Validate, then start in the foreground.
reiki --config /etc/reiki/reiki.toml check reiki --config /etc/reiki/reiki.toml
Expected
checkoutput with peers off:caps: client 1024 (256 per address), admin 64 (16 per address); loopback exempt from the per-address caps peers: disabled ok: 1 upstream(s), 1 key(s), 1 stream(s), listening on 127.0.0.1:4097, admin on 127.0.0.1:4098 -
Prove the listener checks tokens, and that the live admin API answers.
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:4097/example/chat/completions \ -H 'Authorization: Bearer $STREAM_ADMIN_TOKEN' -H 'Content-Type: application/json' \ -d '{"model":"example-model","messages":[{"role":"user","content":"ping"}]}') REIKI_ADMIN_TOKEN="$ADMIN_TOKEN" reiki --config /etc/reiki/reiki.toml keys REIKI_ADMIN_TOKEN="$ADMIN_TOKEN" reiki --config /etc/reiki/reiki.toml failures --limit 5 test "$code" = 401 && echo "PASS: wrong token rejected, live state answered"
Expected proof line and key table:
PASS: wrong token rejected, live state answered KEY UPSTREAM STATE COOLDOWN LAST STREAMS example-a example ok - - client-afailuresprintsno failuresbefore the first upstream attempt. The proof shows that the request reached Reiki and was checked against a stream hash; it does not prove the upstream works. UseSIGTERMto stop the foreground process. See quickstart for the health probe and a negative-test body.
One TOML file. Every table is optional except that each stream needs a chain and a token hash; unknown keys are errors. Reference: configuration, CLI and keys.
| Table | Default | Meaning |
|---|---|---|
listen |
127.0.0.1:4097 |
Client listener; --listen wins, then REIKI_LISTEN. |
[admin] |
none | Loopback admin listener and its token hash. |
[upstream.NAME] |
none | Base URL, credential header and transport for one provider. |
[keys.NAME] |
none | Key file and upstream; files must be mode 0600. |
[streams.NAME] |
none | Token hash, chain, strategy, limits and allowlists. |
[gateway] |
on_store_error = "closed", usage_rpm = 60 |
Admission defaults and the self-service usage budget; counter failures fail closed. |
[stream_admin] |
none | Opt-in dynamic stream API, audit log and state file; dedicated token. |
[server] |
1024 client connections (256 per address), 64 admin (16 per address) | Startup-only connection caps. |
[auth] |
10 bad tokens in 60 seconds | Login throttling on client and admin listeners. |
[service] |
shutdown_timeout_secs = 25 |
Drain window on SIGTERM. |
[log], [reload] |
stderr, info; watch off | Service log format and config reload. |
[plugins.NAME] |
built-in set chosen at build time | Compiled-in plugins; cost and Wasm plugins are opt-in. |
[peers] |
none | Read-only health sharing and reiki top. |
[tunnel], [tunnel.intercept] |
none | Opaque CONNECT allow-list and optional TLS interception. |
Minimal example (the quickstart config above) and a fuller example both validate with reiki --config FILE check:
listen = "127.0.0.1:4097"
[admin]
listen = "127.0.0.1:4098"
token_sha256 = "<64 hex from the admin token>"
[upstream.example]
base_url = "https://api.example.com/v1"
[keys.example-a]
upstream = "example"
file = "/etc/reiki/keys/example-a"
[streams.client-a]
token_sha256 = "<64 hex from the client token>"
chain = ["example-a"]listen = "127.0.0.1:4097"
strict_key_permissions = true
[server]
max_connections = 256
max_connections_per_addr = 64
[auth]
max_failures = 10
window_secs = 60
[service]
shutdown_timeout_secs = 25
[admin]
listen = "127.0.0.1:4098"
token_sha256 = "<64 hex from the admin token>"
[gateway]
on_store_error = "closed"
usage_rpm = 60
[upstream.example]
base_url = "https://api.example.com/v1"
[keys.example-a]
upstream = "example"
file = "/etc/reiki/keys/example-a"
[streams.client-a]
token_sha256 = "<64 hex from the client token>"
chain = ["example-a"]
weight = 1
[streams.client-a.limits]
rpm = 60
tpm = 100000
concurrent = 4
daily_tokens = 1000000
period_zone = "UTC"
[log]
level = "info"
format = "text"
[reload]
watch = false
interval_secs = 5
[plugins.metrics]Configuration examples are checked by make docs-check. Values written as <64 hex ...> are placeholders: generate them with reiki hash-token; never paste a real token into a config in a patch.
| Task | Reference |
|---|---|
| Install, service setup, reload, upgrade and rollback | deploy |
| Dynamic streams: create, rotate, revoke, expiry, audit, backup and restore | dynamic streams |
| Logs, metrics, health checks and exact failure messages | monitoring and troubleshooting |
| Release archive and attestation verification | security |
Health probe: GET http://127.0.0.1:4097/__reiki/healthz needs no token and answers ok while Reiki is up. A reload previews with reiki --config FILE reload --dry-run and applies with reiki --config FILE reload. Upgrade by installing the new binary and restarting; roll back by restoring the previous binary and config. Do not edit or truncate the state or audit files while the instance is running.
Reiki protects upstream credentials from the client, limits and records what a stream can send, and keeps a separate admin token off the client listener. Its trust boundary is the host and the Reiki user: any process with those privileges can read key files, and compiled-in plugins are trusted code. [stream_admin] adds a dedicated management token, optional two-party confirmation and a fail-closed hash-chained audit log; dynamic state and audit files are mode 0600. Reiki does not sandbox the client, detect every encoding of a secret, or stop traffic that bypasses its listeners. Details: security. Report a vulnerability privately as described in SECURITY.md.
| Item | Notes |
|---|---|
| Rust toolchain | 1.99 or newer, edition 2024. |
| Release archives | Linux musl x86_64 and aarch64; macOS x86_64 and aarch64. |
| Opt-in features | plugin-wasm, plugin-cost and top are off by default. |
| Client configs | Documented in clients; client source is not tested here. |
| Provider APIs | Tests use mock upstreams; see providers. |
- Not a client enforcer. A client that talks directly to a provider, or a sub-agent with its own config, bypasses Reiki. Enforce egress and client config outside Reiki.
- Not a host boundary. Key files are mode
0600but readable by the Reiki user and root. Separate accounts or hosts are needed against same-user processes. - Fail-closed by default where it counts. Gateway counter failures refuse with
503([gateway] on_store_error = "closed"); masking plugins skip closed; stream admin fails closed when the audit log cannot be written."open"andon_error = "pass_through"are explicit fail-open choices. - Plugin code is trusted. Built-in plugins run in the Reiki process without a sandbox. Runtime Wasm plugins are sandboxed behind
plugin-wasm; native plugins are not. - Opaque tunnels stay opaque. CONNECT destinations on the allow-list are not inspected unless
[tunnel.intercept]names the host. Plain CONNECT needs no token, so restrict access to the listener. - Finite redaction and detection. The scrubber covers a fixed set of encodings; detectors read request bodies only, not headers, query strings or responses. See security.
- Cost figures are estimates.
plugin-costuses the operator price table, not provider invoices.
make help # list targets
make build # release build with reiki top
make test # workspace tests, default and top features
make lint # fmt check and clippy with warnings denied
make check # workspace cargo check
make docs-check # validate documentation examples and linksCommit messages are terse and describe the change, not the process. Build-time plugin order is described in plugins; see AGENTS.md for the repo map and workflow.
MIT. Documentation index · Changelog · Releases · Security