Reiki

Security proxy for agent and LLM traffic: isolates keys, filters what leaves, keeps access reliable

View the Project on GitHub ddproxy/reiki

Reiki logo

Security proxy for agent and LLM traffic: isolates keys, filters what leaves, keeps access reliable.

Reiki sits between a client and the LLM providers it calls. The client can be an agent such as opencode or Claude Code, or an application that would otherwise hold provider API keys. The client gets a stream token. Reiki keeps the keys.

Start with the overview for how the parts fit together.

Isolation

Upstream keys and secrets stay out of the client. Keys live in files that only Reiki reads. The client authenticates with a revocable stream token. See security for what this does and does not cover, and configuration for the key and stream tables.

Control

Reiki filters what leaves. The placeholders plugin masks credentials and listed terms. The phi, finance and controlled plugins block or report identifiers. Upstreams come only from the config, and the optional tunnel allows only listed destinations. Read placeholders, phi, finance, controlled and tunnel.

Reliability and visibility

Access stays up and you can see it. A stream’s chain of keys, and an optional fallback upstream, takes over on a rate limit, an exhausted quota or a disabled key (failover). Traffic shaping (shaping) keeps each key inside its budget. The request log (requestlog), reiki top (top), peers (peers) and /metrics (monitoring) show what happened.

Install

From a checkout (Rust 1.99 or newer), make install builds with reiki top and puts reiki in ~/.local/bin, or in /usr/local/bin as root. PREFIX=/opt/reiki make install picks another prefix.

Or download a prebuilt archive from the releases page (Linux static musl and macOS, x86_64 and aarch64; reiki top included), check it against its .sha256 file and copy reiki onto your PATH.

Plugin selection and order are build arguments; see docs/plugins.md.

Quick start

This takes one upstream, one key and one stream. Replace each placeholder.

  1. Write the provider key to a file that only Reiki’s user can read.

    umask 077
    printf '%s' "$PROVIDER_KEY" > /path/to/keys/example-a
    
  2. Choose a client token of at least 16 characters and hash it.

    printf '%s' "$CLIENT_TOKEN" | reiki hash-token
    
  3. Save reiki.toml, with the hash from step 2 in token_sha256.

    [upstream.example]
    base_url = "https://api.example.com/v1"
    
    [keys.example-a]
    upstream = "example"
    file = "/path/to/keys/example-a"
    
    [streams.client-a]
    token_sha256 = "<64 hex characters from hash-token>"
    chain = ["example-a"]
    
  4. Check the setup, then run Reiki. It listens on 127.0.0.1:4097 unless listen says otherwise.

    reiki --config reiki.toml check
    reiki --config reiki.toml
    
  5. From another terminal, send a request through Reiki. Only the stream token goes to Reiki.

    curl -s http://127.0.0.1:4097/example/chat/completions \
      -H "Authorization: Bearer $CLIENT_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"model": "example-model", "messages": [{"role": "user", "content": "ping"}]}'
    

To point a client at Reiki, set its base URL to http://127.0.0.1:4097/<upstream> and send the stream token where it would send its API key. Clients may send the token as Authorization: Bearer, x-api-key, x-goog-api-key or a ?key= query parameter, in that order of preference. Provider setup is in providers.

Documentation

Start

Keys and providers

Plugins

Egress

Operations

Security

Develop

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test

License

MIT