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

ItemRequirement
HostLinux x86_64, at least 2 cores and 4 GB recommended
SoftwareDocker, Docker Compose v2, Git, OpenSSL
NetworkAccess to Docker Hub, an SMTP server, and the upstream APIs you need
DomainsOne 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.yml

The 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

  1. In x-site, replace the example domains with your own hostnames, such as api.example.com.
  2. Under xsirouter-xsi, replace [email protected] in INIT_USERS and XAI_MAIL with your administrator email address.
  3. 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, set SIGN_ENABLE to "false" under xsirouter-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 OK

The 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

ServiceImagePortsDescription
xsirouter-xsiproxyxai/xsi5443 β†’ 3443API for model requests and account management
xsirouter-pagesproxyxai/xsi-pages5080 β†’ 8080, 5081 β†’ 8081Configuration and account consoles
xsirouter-mailproxyxai/mailβ€”Delivers signup verification and account notifications over SMTP
xsirouter-postgrespostgres:19β€”Business data, named volume mounted at /var/lib/postgresql
xsirouter-redisredis:alpineβ€”Configuration, cache, usage, and queues, named volume mounted at /data
xsirouter-postgres-backuppostgres:19β€”Daily pg_dump to backups/postgres/
xsirouter-redis-backupredis: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 pointPublic URLSame-host target
APIhttps://api.example.comhttp://127.0.0.1:5443
Configuration consolehttps://admin.example.comhttp://127.0.0.1:5080
Account consolehttps://manage.example.comhttp://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

  1. Open the Admin Console and sign in with the root key (the sk-Xvs... value in INIT_USERS).
  2. 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_MAPPER automatically based on the provider.
  3. Under "System Config", check LEVEL_MAPPER and set MODEL_MAPPER, SWITCH_OVER, and so on as needed; see Routing and failover.
  4. Review the default prices in the model catalog or with GET /x-pricing, and override them with the tenant PRICING if needed.
  5. In the account console, create the sub-accounts that will actually make calls and allocate credit to them; applications use the sub-account keys.
The root key has full platform privileges. Use it only for administration, never for routine model calls or distribution to applications. 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

NeedSetting
Self-registered users become independent tenants (bringing their own upstream keys)API environment variable SINGLE_TENANT=false
Scale out with multiple API instancesAll 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.