Environment Variables
These configure the gateway process. Provider keys are on Provider Keys.
The CLI reads two variables to talk to a gateway instead of Dari’s hosted API. Setting
DARI_GATEWAY_URL switches the launchers and subscription commands to the gateway.
Storage
The gateway keeps a SQLite database atDARI_GATEWAY_DB, created with owner-only permissions. It holds:
- Connected subscriptions. Access tokens, in plaintext. Back the file up like a secret, and never commit it.
- Conversation state. Prefix hashes, conversation ids, serving models, and token counts, so a conversation keeps its model and provider caches warm. Rows older than about an hour are deleted.
- Session pins. For routers with
sessionPinning: true. - Saved model lists. Set with
dari setup <agent>. They are served in place of the config file’s.
sqlite3 .backup so the copy is consistent.
Network Exposure
The gateway serves plain HTTP. It has no TLS and no authentication beyond the gateway keys, so the defaults keep it on this machine.- Bare process. Listens on
127.0.0.1. SetDARI_GATEWAY_HOST=0.0.0.0only on a network you trust. - Container. Listens on all interfaces inside the container. Publish it on loopback with
-p 127.0.0.1:8080:8080. Docker publishes ports on all host interfaces unless you give an address.
Rotating Keys
DARI_GATEWAY_KEYS accepts several keys, and any one of them authenticates. To rotate without downtime:
- Add the new key to
DARI_GATEWAY_KEYS, separated by a comma, and restart. - Update each client to the new key.
- Remove the old key and restart.
Data Handling
- Provider requests go from the gateway to the providers you configured, under your keys or subscriptions. The gateway sends no telemetry to Dari. Apart from Auto Routing, it makes no calls to Dari’s services.
- Dari Auto Routing runs only when
DARI_AUTO_ROUTING_API_KEYis set. Eachdari/routingrequest sends the conversation context, up to about 32,000 characters, to Dari’s selector atrouting.dari.dev. The chosen model is then called with your own keys. - Leave the variable unset to keep conversations off Dari’s servers.
dari/routingthen serves the first listed model that has a credential. - Zero data retention is set per router with
zdr: true. The gateway drops free-text fields, such as routing reasons and selector output, before they reach its database. It also asks providers for zero data retention where they support it. Retention is a provider setting, so confirm each provider’s policy before you rely on it.
Health And Logs
GET /healthz returns {"status":"ok"} without a key, for load balancers and container health checks.
Logs go to the console. Standard output has the startup summary, a warning for each router with a missing credential, and a summary line with token counts and cost for every routed request. Server errors (5xx) go to standard error.
Upgrading
Pin the version you run:bunx @mupt-ai/dari-gateway@<version>, or a specific image tag. Each release updates the model catalog. Read the release notes first, then check your config against the Models page.