Setup guide
CrapTrap Guide
CrabTrap is an open-source LLM-as-a-judge HTTP/HTTPS proxy built by Brex. It sits between your blocking requests based on your security policy. No SDK changes or wrappers needed.
CrabTrap × OpenClaw
Simplified Setup Guide | May 2026
What is CrabTrap?
CrabTrap is an open-source LLM-as-a-judge HTTP/HTTPS proxy built by Brex. It sits between your
OpenClaw agent and every external API call it makes - intercepting, evaluating, and either allowing or
blocking requests based on your security policy. No SDK changes or wrappers needed.
How It Works with OpenClaw
You set HTTP_PROXY and HTTPS_PROXY env vars in OpenClaw's environment to point at CrabTrap. Every outbound call (Slack, Gmail, GitHub, etc.) is intercepted. CrabTrap applies fast static rules first, then uses an LLM judge for anything ambiguous – then forwards or blocks the request in real time.
Prerequisites
- Docker & Docker Compose – Required to run CrabTrap + PostgreSQL
- OpenAI / Anthropic API Key – Used as the LLM judge
- OpenClaw running locally or on server – The agent whose traffic you want to secure
- curl + jq (optional) – Helpful for setup commands
Pull & Start CrabTrap
Run CrabTrap alongside PostgreSQL using Docker Compose
docker compose up -d
- This starts the proxy on port 8080 and the admin UI on port 8081.
Generate CA Certificate
Copy the generated TLS certificate authority from the container
docker compose cp crabtrap:/app/certs/ca.crt ./ca.crt
You'll need this certificate in every agent service that routes traffic through CrabTrap.
Create Admin User
Generate an admin token to access the web UI
admin_token=$(docker compose exec -it crabtrap ./gateway create-admin-user my-admin
\ | tail -n1 | cut -d" " -f2)
Create an Agent User & Get Gateway Token
Create a user for your OpenClaw agent and capture its gateway auth token:
token=$(curl -sX POST http://localhost:8081/admin/users \ -H "Content-Type:
application/json" \ -H "Authorization: Bearer ${admin_token}" \ -d '{"id": "openclaw@example.com", "is_admin": false}' \ | jq -r '.channels[] | select(.channel_type=="gateway_auth") | .gateway_auth_token')
Point OpenClaw at CrabTrap
In your OpenClaw environment config (e.g. .env or Docker environment block), add the following
variables
HTTP_PROXY=http://${token}:@localhost:8080
HTTPS_PROXY=http://${token}:@localhost:8080 SSL_CERT_FILE=/path/to/ca.crt
Replace ${token} with the actual token value from Step 4.
Test the Connection
Verify traffic is routing through CrabTrap
curl -x http://${token}:@localhost:8080 \ --cacert ca.crt https://httpbin.org/get
A successful response means CrabTrap is intercepting traffic correctly.
Set Your Security Policy
Open the admin UI at http://localhost:8081 and log in with your admin token. Use the Policy Builder to
either
- Write a natural-language policy (e.g. "Allow Slack and GitHub, block everything else")
- Click Bootstrap Policy to auto-generate one from observed traffic
- Run evals against past traffic before going live
Optional – Enforce Proxy-Only Traffic
For stronger security, add iptables rules in OpenClaw's container to block any direct outbound connections
that bypass the proxy
iptables -A OUTPUT -m owner --uid-owner agent-user -j DROP # Allow only traffic
going to CrabTrap proxy port iptables -I OUTPUT -m owner –uid-owner agent-user -d
localhost –dport 8080 -j ACCEPT
Architecture Overview
Component Role
Default Port
OpenClaw Agent
Your AI agent making API calls
–
CrabTrap Proxy
Intercepts & judges all traffic 8080
CrabTrap Admin UI
Policy config & traffic review 8081 PostgreSQL Stores audit logs & policies 5432
LLM Judge
Evaluates ambiguous requests
External API
Key Features
Per-IP Rate Limiting
Token bucket algorithm, no agent overload
Circuit Breaker
Trips after 5 consecutive LLM failures
Fallback Mode
Configurable: deny or passthrough when LLM unavailable
Policy Evals
Test policies against real traffic before deploying
No SDK Changes
Works via standard HTTP_PROXY env variables
Final checklist
- The required app, command, or service opens correctly.
- Credentials are stored outside public files and screenshots.
- A small test run completes before you use the setup for real work.
- You know where logs, output files, and error messages are stored.