Run OpenClaw as a personal assistant on Lens Agents Lens Agents published a guide for running OpenClaw, a personal AI assistant with a web Control UI, inside a Lens Agents sandbox so the UI is never exposed on an open port, addressing the hundreds of thousands of exposed OpenClaw instances the post cites as a security problem. The setup binds the OpenClaw gateway to 127.0.0.1 on port 18789 and publishes it as a private port that requires a Lens Agents login and forwards the user's identity in a header, while the model runs through managed inference on OpenRouter with a placeholder key so the sandbox holds no API key. The configuration pins the image ghcr.io/openclaw/openclaw:2026.10.8 with 2 CPUs, 4Gi of memory and a 10Gi volume, and defaults to the anthropic/claude-opus-5.5 model. TL;DR - OpenClaw https://openclaw.ai is a personal AI assistant with a web Control UI. Put that UI on an open port, and anyone who finds it can talk to your assistant. - In a Lens Agents sandbox, the Control UI has no open port. It is a private port behind your Lens Agents login, and OpenClaw knows who you are from the platform. - The model comes through managed inference with OpenRouter, so the sandbox holds no API key. You decide what else on the network it can reach. OpenClaw is useful because it acts for you: it remembers, it runs tools, it does things. That's also why hundreds of thousands of exposed instances https://lenshq.io/blog/banning-ungoverned-ai-agents/ are a problem. An assistant with your context and your keys, on an open port, is an assistant for anyone who finds it. This post runs OpenClaw for one person, in a Lens Agents sandbox, with none of that exposed. How the pieces fit OpenClaw runs a gateway that serves the Control UI and talks to the model. In the sandbox, the gateway listens only on 127.0.0.1 . The sandbox publishes that port as private : Lens Agents gives it a URL, asks you to log in, checks your project access, and then forwards the request with your identity in a header. OpenClaw trusts that header, so it knows who you are without a second password. The model is managed inference . The sandbox gets an OpenRouter endpoint and a placeholder key. The platform adds the real key at the boundary and meters the spend. OpenRouter is the easiest backend to set up: one API key, no cloud account, and hundreds of models behind it. What you need - The latest Lens Agents release, with OpenRouter enabled for your org. An org admin adds the OpenRouter API key on the org's Inference keys page. If you don't have a platform yet, follow the getting started guide https://docs.lenshq.io/lens-agents/getting-started/ . - nexusctl , installed from your Lens Agents platform and logged in with nexusctl auth login . - The email address you log in to Lens Agents with. OpenClaw makes that identity the admin of the gateway. Step 1: Define the sandbox name: OpenClaw image: ghcr.io/openclaw/openclaw:2026.10.8 cpu: "2" memory: 4Gi volumes: - mountPath: /data size: 10Gi exposedPorts: - name: web port: 18789 auth: private env: LENS SANDBOX WRITABLE DIR: /data OPENCLAW CONFIG PATH: /data/openclaw.json OPENCLAW STATE DIR: /data/state OPENCLAW WORKSPACE DIR: /data/workspace OPENCLAW NO AUTO UPDATE: "1" OPENCLAW MODEL: anthropic/claude-opus-5.5 OPENCLAW ADMIN: ${OPENCLAW ADMIN} files: - path: /home/node/start-openclaw.sh content: | -n "$NEXUS INGRESS IDENTITY HEADER WEB" || { echo "publish the web port as private" &2; exit 1; } origins="\"$ printf '%s' "$NEXUS INGRESS ORIGINS WEB" | sed 's/,/","/g' \"" openclaw config unset gateway.auth.identityScopes /dev/null 2 &1 openclaw config set gateway "{ \"mode\": \"local\", \"bind\": \"loopback\", \"port\": 18789, \"trustedProxies\": \"127.0.0.1\" , \"auth\": { \"mode\": \"trusted-proxy\", \"trustedProxy\": { \"userHeader\": \"$NEXUS INGRESS IDENTITY HEADER WEB\", \"allowLoopback\": true, \"deviceAutoApprove\": { \"enabled\": true, \"scopes\": \"operator.read\", \"operator.write\", \"operator.approvals\", \"operator.questions\" } }, \"identityScopes\": { \"$OPENCLAW ADMIN\": \"operator.admin\" } }, \"controlUi\": { \"allowedOrigins\": $origins , \"dangerouslyAllowHostHeaderOriginFallback\": false, \"dangerouslyDisableDeviceAuth\": true } }" --strict-json --merge || exit 1 openclaw config set update '{"checkOnStart": false, "auto": {"enabled": false}}' --strict-json --merge openclaw config set models.providers.nexus "{ \"api\": \"anthropic-messages\", \"baseUrl\": \"$ANTHROPIC BASE URL\", \"apiKey\": \"nexus-managed\", \"models\": {\"id\": \"$OPENCLAW MODEL\", \"name\": \"$OPENCLAW MODEL\"} }" --strict-json openclaw config set agents.defaults.model "{\"primary\": \"nexus/$OPENCLAW MODEL\"}" --strict-json --merge openclaw config set memory.search "{ \"enabled\": true, \"provider\": \"openai\", \"model\": \"openai/text-embedding-3-small\", \"fallback\": \"none\", \"remote\": { \"baseUrl\": \"$OPENAI BASE URL\", \"apiKey\": \"$OPENAI API KEY\" } }" --strict-json --merge openclaw config set mcp.servers.nexus "{ \"command\": \"/.lens/nexus-mcp\", \"enabled\": true, \"env\": { \"NEXUS MCP URL\": \"$NEXUS MCP URL\", \"HTTPS PROXY\": \"$HTTPS PROXY\", \"HTTP PROXY\": \"$HTTP PROXY\", \"SSL CERT FILE\": \"$SSL CERT FILE\" } }" --strict-json exec openclaw gateway command: sh /home/node/start-openclaw.sh policy: name: OpenClaw networkDefaultVerdict: deny managedInference: enabled: true provider: openrouter allowedDomains: - pattern: " " verdict: allow transport: direct description: Read-only internet rules: - { method: GET } - { method: HEAD } A few things to note: - The image is pinned , and OPENCLAW NO AUTO UPDATE plus the update setting keep it pinned. An assistant that upgrades itself is no longer the one you reviewed. - State lives on the /data volume : config, memory, and workspace. A restart picks up where the assistant left off. LENS SANDBOX WRITABLE DIR gives the volume to the image's own user before the gateway starts. - The start script writes OpenClaw's settings on every boot with OpenClaw's own config set , then starts the gateway. Settings you change in the Control UI stay, except the ones the script owns. - The gateway trusts only the platform. It binds to loopback and reads your identity from the header that the private port adds. The allowed origins are the URLs of this sandbox, so another site can't drive the Control UI from your browser. - Only you administer it. OPENCLAW ADMIN gets the admin scope: channels, devices, gateway settings. Anyone else in the project who opens the port can chat and answer approvals, but can't change the gateway. - You decide what the assistant can reach. The policy denies by default. OpenClaw talks to the model through managed inference, which the policy grants separately. The one rule in allowedDomains gives read-only internet: GET and HEAD pass, so the assistant can read the web but can't post to it. That can also let OpenClaw read its model catalog and download skills from ClawHub. Remove the rule to block all of it, or add domains with the methods you trust. - Memory search uses OpenRouter too. OpenClaw indexes its memory with an embedding model, and the script points it at the same managed OpenRouter endpoint, through OpenRouter's OpenAI-compatible API. - OPENCLAW MODEL is any OpenRouter model id. Change it to try another model. Step 2: Create the sandbox OPENCLAW ADMIN=you@example.com nexusctl sandbox create --project