Decouple, Buffer & Spoof LLM Gateways

A lightweight, zero-dependency reverse proxy in Go that queues incoming requests in-memory to prevent rate-limit failures, logs requests to SQLite, and injects customized headers or API keys dynamically.

Core Use Cases

Understand how adding this proxy centralizes controls, improves resiliency, and simplifies multi-app deployments.

🔑

API Key Decoupling

Remove upstream API keys (e.g. OpenAI, Anthropic) from client code. Configure downstream clients to send virtual API keys, and map them to secret upstream keys centrally on the proxy server.

🔄

Dynamic Model Swapping

Upgrade model versions (e.g., swapping `gpt-3.5-turbo` with `gpt-4o-mini`) centrally. The proxy intercepts requests and dynamically modifies the URL paths and payload body parameters on the fly.

🕵️

Header Spoofing

Bypass restrictions enforced by upstream firewalls or gateways. Spoof official SDK client signatures (e.g., custom User-Agents) and inject security context headers globally.

Queueing Rate Limits

Rather than failing downline applications with hard `429 Too Many Requests` errors, the proxy buffers and queues requests in-memory, releasing them gradually to fit upstream rate limits.

📊

Centralized Auditing

Keep a comprehensive audit log of prompt bodies, response text, costs, latencies, and HTTP status codes in a local SQLite database without embedding telemetry code into client applications.

Zero-Dependency Binary

Built purely in Go with zero dependencies. Runs natively, inside containers (Docker/Podman), or as a systemd service, requiring tiny resources (under 15MB RAM).

Interactive Configuration Playground

Adjust variables to see changes in real-time. Copy the generated terminal commands or configuration scripts instantly.

Proxy Settings

Loading...

Central SQLite Audit Trail

The proxy automatically saves request and response bodies asynchronously. This lets you write simple SQL scripts directly on the `gatepass.db` file to review usage patterns or monitor errors.

No libraries, cloud SaaS dependencies, or complex setup needed.

Example Audit Query

-- Calculate average latency & errors by route SELECT path, COUNT(*) as total_requests, AVG(duration_ms) as avg_latency_ms, SUM(CASE WHEN response_status >= 400 THEN 1 ELSE 0 END) as errors FROM api_logs GROUP BY path ORDER BY total_requests DESC;

Deployment Options

Spin up the proxy on your server, desktop, or cloud instances using your preferred environment model.

  • 1

    Clone and Build

    Download the source code and compile the Go project into a single, compact binary.

    git clone https://github.com/Rat-S/gatepass.git cd gatepass go build -o gatepass main.go
  • 2

    Define Variables & Run

    Provide environment parameters and start the compiled executable binary.

    export PROXY_TARGET_URL="https://api.openai.com" export RATE_LIMIT_RPM=30 export HEADER_User_Agent="CustomClient/2.0" ./gatepass
  • 1

    Build Container Image

    Generate a secure, lightweight, multi-stage image using the project's Dockerfile.

    docker build -t gatepass .
  • 2

    Run Container

    Mount the SQLite directory and run the proxy in detached mode.

    docker run -d \ -p 8318:8318 \ -v ./data:/data:Z \ -e PROXY_TARGET_URL="https://api.openai.com" \ -e PROXY_LOGS_DB="/data/logs.db" \ -e RATE_LIMIT_RPM=20 \ --name gatepass \ gatepass
  • 1

    Create Service Unit

    Write a systemd configuration file inside `/etc/systemd/system/gatepass.service`:

    [Unit] Description=Gatepass LLM Proxy After=network.target [Service] ExecStart=/usr/local/bin/gatepass Restart=always Environment=PROXY_TARGET_URL=https://api.openai.com Environment=PROXY_PORT=8318 Environment=HEADER_User_Agent=CustomAgent/1.0 Environment=API_KEY_REPLACE="internal-client-key:sk-proj-..." [Install] WantedBy=default.target
  • 2

    Enable and Start

    Reload systemd configurations and launch the background daemon service.

    sudo cp gatepass /usr/local/bin/ sudo systemctl daemon-reload sudo systemctl enable --now gatepass
  • 1

    Create Quadlet Container File

    Write a container service definition file inside `/etc/containers/systemd/gatepass.container` (or `~/.config/...` for rootless running):

    [Unit] Description=Gatepass LLM Proxy Container After=network.target [Container] Image=ghcr.io/rat-s/gatepass:latest PublishPort=8318:8318 Volume=/srv/gatepass/data:/data:Z Environment=PROXY_TARGET_URL=https://api.openai.com Environment=PROXY_PORT=8318 Environment=HEADER_User_Agent=CustomClient/1.0 [Service] Restart=always [Install] WantedBy=default.target
  • 2

    Reload and Activate Service

    Launch the service using standard user systemctl controls.

    systemctl --user daemon-reload systemctl --user enable --now gatepass