PromptLatch

Send the prompt. Keep the keys.

Coding agents read your .env, your logs, and your configs, then send them to a model. PromptLatch runs on your machine and blacks out the credentials before the request leaves.

uv tool install promptlatch

Try it: edit the prompt and watch what is sent

What the provider receives

DATABASE_URL=postgres://app:[REDACTED_SECRET]@db:5432/prod

1 redaction

    This demo runs the project's built-in patterns in your browser, and this page's content policy blocks requests to other sites. The installed engine adds bc-detect-secrets and your own rules, so it redacts more and can name a rule differently.

    Works with the agent you already run

    Start one local proxy, then launch your agent through it. The wrappers keep your login and do not edit your agent's config files.

    Start the proxy once

    uv tool install promptlatch
    curl -fsSO https://bvolpato.github.io/promptlatch/agents.yaml
    promptlatch serve --config agents.yaml

    It listens on 127.0.0.1:8000 and allows the official provider endpoints only.

    Run Claude Code through it

    claude-latch
    claude-latch -p "Review this repository"

    Works with a Claude login or ANTHROPIC_API_KEY. If the proxy is down or redaction is off, the wrapper stops instead of sending unredacted prompts.

    Start the proxy once

    uv tool install promptlatch
    curl -fsSO https://bvolpato.github.io/promptlatch/agents.yaml
    promptlatch serve --config agents.yaml

    It listens on 127.0.0.1:8000 and allows the official provider endpoints only.

    Run Codex through it

    codex-latch
    codex-latch exec "Review this repository"

    Uses your ChatGPT login or OPENAI_API_KEY. If the proxy is down or redaction is off, the wrapper stops instead of sending unredacted prompts.

    Start the proxy once

    uv tool install promptlatch
    curl -fsSO https://bvolpato.github.io/promptlatch/agents.yaml
    promptlatch serve --config agents.yaml

    It listens on 127.0.0.1:8000 and allows the official provider endpoints only.

    Run Gemini CLI through it

    gemini-latch
    gemini-latch -p "Summarize recent changes"

    Works with Google sign-in or GEMINI_API_KEY. Vertex AI and other modes that would bypass the proxy stop with an error.

    Start the proxy for OpenRouter

    uv tool install promptlatch
    curl -fsSL -o openrouter.yaml \
      https://raw.githubusercontent.com/bvolpato/promptlatch/main/examples/promptlatch-openrouter.config.yaml
    promptlatch serve --config openrouter.yaml

    This config allows OpenRouter only and keeps the key in OpenCode's environment.

    Add the provider to your project

    curl -fsSL -o opencode.json \
      https://raw.githubusercontent.com/bvolpato/promptlatch/main/examples/opencode-openrouter-promptlatch.json
    export OPENROUTER_API_KEY="<openrouter-upstream-key>"
    opencode run "Say ok" \
      -m promptlatch-openrouter/openai/gpt-oss-120b

    Use one default provider

    promptlatch init --target-base-url https://api.openai.com/v1
    export OPENAI_API_KEY="<openai-upstream-key>"
    promptlatch serve

    Then set OPENAI_BASE_URL=http://127.0.0.1:8000/v1 for any OpenAI-compatible client. Chat Completions, Responses, Anthropic Messages, and Gemini routes pass through in their own format, with streaming and tool calls.

    OpenRouter request

    curl http://127.0.0.1:8000/v1/responses \
      -H "X-Target-Base-URL: https://openrouter.ai/api/v1" \
      -H "X-Target-API-Key: $OPENROUTER_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"model":"openai/gpt-oss-120b","input":"Say ok"}'

    Choose a provider per request. The configured key is never sent to another host. To limit the hosts, list each one in the config:

    target:
      allowed_base_urls:
        - https://api.openai.com/v1
        - https://openrouter.ai/api/v1

    Add the library

    uv add promptlatch

    Or use python -m pip install promptlatch. No proxy needed. Four helpers cover text, messages, SDK parameters, and raw payloads. They return a redacted copy and leave your input unchanged.

    Redact at the SDK call

    from openai import OpenAI
    from promptlatch import redact_params
    
    client = OpenAI()
    response = client.responses.create(
        **redact_params(
            model="gpt-6-sol",
            input="Read this: GITHUB_TOKEN=example-value-123456",
        )
    )

    The same call works with LiteLLM. Use redact_messages for Anthropic and LangChain.

    Docker

    docker run -d --name promptlatch --rm \
      -p 127.0.0.1:8000:8000 \
      --env-file "$HOME/.config/promptlatch/provider.env" \
      ghcr.io/bvolpato/promptlatch:0.3.0
    
    curl --retry 10 --retry-all-errors --retry-delay 1 \
      -fsS http://127.0.0.1:8000/healthz

    provider.env holds PROMPTLATCH_TARGET_BASE_URL and PROMPTLATCH_TARGET_API_KEY.

    Helm

    kubectl create secret generic promptlatch-env \
      --from-env-file="$HOME/.config/promptlatch/kubernetes.env"
    
    helm install promptlatch \
      https://github.com/bvolpato/promptlatch/releases/download/v0.3.0/promptlatch-0.3.0.tgz \
      --set env.PROMPTLATCH_TARGET_DEFAULT_BASE_URL=https://api.openai.com/v1 \
      --set existingSecret=promptlatch-env

    kubernetes.env holds PROMPTLATCH_TARGET_API_KEY and PROMPTLATCH_SERVER_API_KEY. See the deployment guide.

    What happens to one request

    A request from a coding agent, line by line, on its way to the provider.

    POST /v1/responses?token=[REDACTED_SECRET]

    Scanned Query parameters, including signed URLs.

    Authorization: Bearer local-client-key

    Dropped Client credentials, unless you enable forwarding.

    Cookie: session=abc

    Dropped Cookies and secret-named headers.

    Authorization: Bearer $OPENAI_API_KEY

    Added Your provider key, and only for that provider.

    { "model": "gpt-6-sol", "stream": true,

    Kept The JSON shape and provider-specific fields.

    "input": [{ "role": "user", "content": "GITHUB_TOKEN=[REDACTED_SECRET]" },

    Scanned Prompts and the full conversation history.

    { "type": "function_call_output", "output": "password=[REDACTED_SECRET]" }] }

    Scanned Tool arguments and tool output, at any depth.

    ← data: {"type":"response.output_text.delta"}

    Kept Responses stream back unscanned.

    What it recognizes

    Deterministic rules, so the same input always gives the same result. No model calls and no entropy guessing.

    Not a complete list. Add an exact-tail or regex rule for internal formats, and store only the last few characters of a secret instead of the secret itself. See every pattern.

    See what was sent

    A local inspector shows each redacted request, what matched, and what it cost. Nothing in it leaves your machine.

    • Conversations grouped by session, with the redacted payload for each request.
    • Tokens, latency, and cost estimates for OpenAI, Anthropic, and Gemini traffic.
    • Redaction counts by rule, without storing secret values.
    • A size cap on disk, or metadata only if you prefer.
    promptlatch serve --dashboard
    promptlatch tail --follow
    promptlatch stats --days 7
    PromptLatch dashboard showing a captured conversation in which credentials appear as REDACTED_SECRET, next to a list of sessions
    Sample data. Secrets in the captured conversation appear as placeholders.

    Where the protection stops

    PromptLatch protects what goes into a request. Know what sits outside it.

    Covered

    • JSON, form, and text request bodies, plus query parameters.
    • gzip and zstd bodies, with limits on expansion.
    • Private and loopback targets are blocked by default.
    • Audit logs hold counts and rule names, never values.
    • No telemetry and no analytics.

    Not covered

    • Private token formats that no rule describes.
    • Provider responses, MCP servers, and tool subprocesses.
    • Multipart uploads. The proxy rejects them instead of guessing.
    • Names, source code, and other private text. Redaction is not anonymization.
    • --debug-requests prints raw bodies. Use it with fake data only.

    Check it yourself

    A model's reply cannot prove what was sent. Send a fake key to an echo server and read what arrived: GEMINI_API_KEY=[REDACTED_SECRET].

    Use the config from promptlatch init. agents.yaml rejects the echo server, because it allows the official provider endpoints only.

    FAKE_KEY="AI""zaSyFixtureToken000000000000000000000"
    curl --compressed -fsS http://127.0.0.1:8000/post \
      -H "X-Target-Base-URL: https://postman-echo.com" \
      -H "Content-Type: application/json" \
      -d '{"messages":[{"content":"GEMINI_API_KEY='"$FAKE_KEY"'"}]}' \
      | jq -r '.data.messages[0].content'