1. Create an Open WebUI identity
In the SafetyRouter tenant portal, create an API key such as OpenWebUI-Finance. Add the team and project tags you want managers to see. To receive tokens as the model generates them, select Direct chat streaming. Copy the key when it is displayed.
Input safety still runs before the request leaves SafetyRouter. Directly streamed output is captured for audit, tokens, and cost, but it cannot be inspected or blocked before the user sees it. Leave the option off when output filtering is required.
A standard Open WebUI connection uses one provider key for the instance. SafetyRouter will attribute requests to that API-key identity, not automatically to individual Open WebUI usernames. Use a separate Open WebUI deployment or connection key for each accountability boundary you need.
2. Store secrets outside Compose
Create a .env file beside compose.yml. Do not commit it.
SAFETYROUTER_API_KEY=sr_live_...
WEBUI_SECRET_KEY=replace-with-a-long-random-secret
3. Add Open WebUI to Docker Compose
This cloud example routes chat and model discovery through a TLS-enabled SafetyRouter tenant. Replace the hostname with your tenant.
services:
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
ports:
- "3000:8080"
environment:
OPENAI_API_BASE_URL: https://your-company.safetyrouter.io/v1
OPENAI_API_KEY: ${SAFETYROUTER_API_KEY}
WEBUI_SECRET_KEY: ${WEBUI_SECRET_KEY}
AIOHTTP_CLIENT_TIMEOUT: "900"
AIOHTTP_CLIENT_TIMEOUT_OPENAI_MODEL_LIST: "30"
volumes:
- open-webui-data:/app/backend/data
restart: unless-stopped
volumes:
open-webui-data:
Start the interface, then open http://your-server:3000 and create the initial Open WebUI administrator.
docker compose up -d
docker compose logs -f open-webui
4. Pick the correct URL for your network
The URL must end in /v1. Inside a container, localhost means the Open WebUI container itself.
- Caddy and public/private DNS:
https://your-company.safetyrouter.io/v1 - SafetyRouter on another LAN server:
http://192.168.166.105:8000/v1 - SafetyRouter on the same Linux Docker host:
http://host.docker.internal:8000/v1 - Both services on one Compose network: use the SafetyRouter service name, such as
http://safetyrouter:8000/v1
For the same-host Linux option, add this beneath the Open WebUI service:
extra_hosts:
- "host.docker.internal:host-gateway"
5. Configure an existing Open WebUI installation
Open WebUI saves connection settings in its data volume. If it has already been launched, sign in as an administrator and use Settings → Admin → Connections. Under Manage OpenAI API Connections, add:
- URL: your SafetyRouter URL ending in
/v1 - API key: the
sr_live_...key created for this instance
Save the connection. SafetyRouter's allowed models should load automatically from GET /v1/models.
6. Verify the protected route
- Select one of the models allowed by the SafetyRouter tenant.
- Send a simple chat message in Open WebUI.
- Open the tenant dashboard and confirm the Open WebUI API identity, tokens, cost, theme, and capture appear.
- Test a company-policy phrase and confirm the expected green, yellow, or red decision.
Buffered keys wait until output inspection is complete; direct-streaming keys can still pause during input review or a slow provider connection. The Compose example allows up to 15 minutes for either protected path.
Do not compress or buffer the tenant's SSE route. SafetyRouter's bundled Caddy configuration uses immediate flushing and sends no-transform headers. If you maintain Caddy yourself, use flush_interval -1 inside the tenant's reverse_proxy block and do not apply encode to that site.
Pin Open WebUI to a release tag you have tested, protect port 3000 with authentication and TLS, restrict direct access to SafetyRouter port 8000, and keep the provider key out of source control. Do not disable certificate verification to work around an internal CA—mount the correct CA bundle instead.
Connection fields, Docker networking, persistence, and timeout behavior verified against the official Open WebUI Quick Start, OpenAI-compatible provider guide, and environment reference.