Docker Compose Deployment
The official Compose template runs the API, both consoles, mail delivery, PostgreSQL, Redis, and daily backups on one host. Download docker-compose.yml
Requirements
| Item | Requirement |
|---|---|
| Host | Linux x86_64, at least 2 cores and 4 GB recommended |
| Software | Docker, Docker Compose v2, Git, OpenSSL |
| Network | Access to Docker Hub, an SMTP server, and the upstream APIs you need |
| Domains | One each for the API, configuration console, and account console; HTTPS is provided by the reverse proxy |
1. Get the deployment files
mkdir xsi && cd xsi
umask 077
curl -fsSL https://xsirouter.com/deploy/docker-compose.yml -o docker-compose.yml
sed -i "s/CHANGE_ME_POSTGRES_PASSWORD/$(openssl rand -hex 24)/g" docker-compose.yml
sed -i "s/CHANGE_ME_ROOT_KEY/sk-Xvs$(openssl rand -hex 24 | cut -c1-45)/" docker-compose.ymlThe two sed commands generate the database password and the root account's API key. The root key lives in INIT_USERS and must be exactly 51 characters (the 6-character sk-Xvs prefix plus 45 random characters). The file holds passwords and keys; keep the 600 permissions that umask 077 gives it.
2. Edit docker-compose.yml
- In
x-site, replace the example domains with your own hostnames, such asapi.example.com. - Under
xsirouter-xsi, replace[email protected]inINIT_USERSandXAI_MAILwith your administrator email address. - Under
xsirouter-mail, enter your SMTP host, port, username, and password. Set TLS as required by your mail provider. Email signup is enabled by default. To turn it off, setSIGN_ENABLEto"false"underxsirouter-xsi.
Write a literal $ in a configuration value as $$. The template binds ports to 127.0.0.1. If the reverse proxy runs on another host, bind the ports to an address it can reach, restrict inbound access, and set TRUSTED_PROXY_CIDRS to the trusted proxy ranges. Reverse proxy
3. Start
docker compose config --quiet # Validate the configuration
docker compose up -d
docker compose ps
curl --fail http://127.0.0.1:5443/healthz # Returns OKThe template uses pull_policy: always, so every start pulls the latest images. /healthz returning OK only means the HTTP service is ready; calling models also requires the upstream setup below.
Services
| Service | Image | Ports | Description |
|---|---|---|---|
xsirouter-xsi | proxyxai/xsi | 5443 β 3443 | API for model requests and account management |
xsirouter-pages | proxyxai/xsi-pages | 5080 β 8080, 5081 β 8081 | Configuration and account consoles |
xsirouter-mail | proxyxai/mail | β | Delivers signup verification and account notifications over SMTP |
xsirouter-postgres | postgres:19 | β | Business data, named volume mounted at /var/lib/postgresql |
xsirouter-redis | redis:alpine | β | Configuration, cache, usage, and queues, named volume mounted at /data |
xsirouter-postgres-backup | postgres:19 | β | Daily pg_dump to backups/postgres/ |
xsirouter-redis-backup | redis:alpine | β | Daily RDB snapshot to backups/redis/ |
PostgreSQL and Redis are reachable only on the internal Compose network and publish no host ports.
4. Configure HTTPS entry points
Point the three domains at the reverse proxy and configure certificates:
| Entry point | Public URL | Same-host target |
|---|---|---|
| API | https://api.example.com | http://127.0.0.1:5443 |
| Configuration console | https://admin.example.com | http://127.0.0.1:5080 |
| Account console | https://manage.example.com | http://127.0.0.1:5081 |
The API entry point must support streaming responses and WebSocket upgrades; see Reverse proxy for Nginx and Caddy examples. Each console's English interface is at its /en/ path.
5. Connect upstreams and create calling accounts
- Open the Admin Console and sign in with the root key (the
sk-Xvs...value inINIT_USERS). - Under "Model Providers", add upstream keys with Provider, SecretKey, and Level, for example OpenAI in Level 1 and Anthropic in Level 2. XSI generates
LEVEL_MAPPERautomatically based on the provider. - Under "System Config", check
LEVEL_MAPPERand setMODEL_MAPPER,SWITCH_OVER, and so on as needed; see Routing and failover. - Review the default prices in the model catalog or with
GET /x-pricing, and override them with the tenantPRICINGif needed. - In the account console, create the sub-accounts that will actually make calls and allocate credit to them; applications use the sub-account keys.
INIT_USERS only creates accounts that do not exist yet; editing docker-compose.yml does not reset an existing root key.6. Verify
export XSI_BASE_URL="https://api.example.com"
export XSI_API_KEY="<sub-account key>"
curl "$XSI_BASE_URL/dashboard/status" -H "Authorization: Bearer $XSI_API_KEY"
curl "$XSI_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $XSI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6.2-sol", "messages": [{"role": "user", "content": "Hello"}]}'Multi-tenant and multi-instance
| Need | Setting |
|---|---|
| Self-registered users become independent tenants (bringing their own upstream keys) | API environment variable SINGLE_TENANT=false |
| Scale out with multiple API instances | All instances share the same PostgreSQL and Redis, with SINGLE_MODE=false |
For a multi-instance deployment, all API instances share the same PostgreSQL and Redis, and each API container must explicitly set SINGLE_MODE: "false" in its environment (the template does not pass this variable by default); sticky bindings, rate limit counters, and change notifications are then shared through Redis. Before scaling out on the same host, remove the fixed container_name and 5443 port mapping from the template.