gateway.yaml is the configuration file for a self-hosted ManyLayers deployment. The gateway, workspace and deployer services all read the same file, passed with -config. Copy configs/gateway.example.yaml to gateway.yaml and edit it. The container image ships configs/gateway.container.yaml at /etc/manylayers/gateway.yaml as its default. ManyLayers Cloud is configured through the console, not this file.
Interpolation. ${ENV_VAR} and ${ENV_VAR:-default} are expanded when the file loads. An unset variable becomes an empty string, so a key like upstream_api_key: ${OPENAI_API_KEY} with the variable missing is empty, and an empty team API key stops startup. HashiCorp Vault references also work: ${vault:secret/data/path#key} (requires VAULT_ADDR and VAULT_TOKEN); one that cannot be resolved fails startup.
The file is parsed strictly. A key that is not listed on this page makes startup fail with a parse error, rather than being ignored.
These environment variables override the file: GATEWAY_PORT (server.listen), DATABASE_URL (database.url), REDIS_URL (redis.url), SHUTDOWN_TIMEOUT (server.shutdown_timeout), MANYLAYERS_ENCRYPTION_KEY (connectors.encryption_key) and MANYLAYERS_PII_VAULT_KEYS / MANYLAYERS_PII_VAULT_KEY_VERSION (pii.vault). See Self-hosting for the full list.

server

listen applies to the gateway only. A request over max_body_bytes is refused with 413 body_too_large. Changes to this section require a restart.

database

Postgres is the only supported database. If url is empty it defaults to postgres://postgres:test@localhost:5532/manylayers?sslmode=disable, the local dev stack. The long-running services do not migrate the schema. Run dbtool migrate -config <file> (the compose migrate job) before first start and before every upgrade; a service whose schema is behind refuses to start. Changes to this section require a restart.

redis

When configured, Redis shares rate limits, budgets, the exact-match cache and event fan-out across all gateway replicas. It is required for correct limits with more than one replica. If Redis is configured but unreachable at startup, the service fails to start. Changes to this section require a restart.

auth

API-key authentication is always enabled. Configuring OIDC adds JWT bearer-token support: a token with three dot-separated parts that does not start with ml- is verified against the issuer. audience is required once issuer is set, and audience or jwks_url without issuer is an error.

audit

The audit log is hash-chained with SHA-256 for tamper evidence. A deployment operator can verify the chain with GET /admin/audit/verify, which checks the most recent 10,000 records. See Request Logging & Audit.

pii

The builtin detector uses regex-based entity recognition (email, phone, SSN, credit card and similar). The http detector calls a Presidio-style sidecar at http_url. With vault.keys set, each redacted value becomes a numbered token and is stored encrypted beside the trace, so authorized administrators can reveal it. current_key may be omitted when exactly one key is configured. See PII redaction.

firewall

Prompt-injection detection. In audit mode, detections are recorded but not blocked. In enforce mode, a request over the threshold is refused with 403 prompt_injection. A team can override the default with its own firewall_mode. See Prompt injection.

cache

The exact-match cache keys on the redacted request. The semantic cache embeds the prompt and matches near-duplicates; the embedding model must be one the requesting team may use. store: qdrant shares the semantic cache across replicas and requires rag.qdrant.url. A request is cached only when the cache is enabled here, caching is enabled for its team (cache_enabled), and the request has temperature: 0 or the model sets cache: true. See Caching.

async

Workers run in the gateway service and serve /v1/async/*. See Async requests.

queue

The db backend uses Postgres and needs no extra infrastructure. The kafka backend uses consumer groups with at-least-once delivery: a message that fails 5 times is published to <topic>.dlq. Changes to this section require a restart.

router

Controls how the gateway chooses among the endpoints of one model and when it ejects an unhealthy one. Per-request behavior (fallback, retries, load balancing) comes from named routing configs.

rag

Backs the knowledge-base API (/v1/kb). The memory store is per process and lost on restart; use qdrant for anything persistent.

connectors

Seals provider API keys pasted into the console, knowledge-base connector credentials (Confluence, Google Drive, SharePoint, S3). Web-crawl connectors need no key. MANYLAYERS_ENCRYPTION_KEY overrides this value. When neither is set, each service generates a key in data/credentials.key (or MANYLAYERS_ENCRYPTION_KEY_FILE); with more than one service or replica, set the key explicitly so they can all read each other’s credentials. Changing the key makes existing sealed credentials unreadable.

suite

Enables the workspace service’s console sign-in (/auth/*) and the /w/* endpoints for chat, agents, workflows, evals and knowledge bases. Leave it false and the Workspace service serves neither. public_url is your own console address; if empty, invitation links use the origin the inviting administrator was on.

deployer

Used by the Deployer service. See Deployment.

telemetry

Deployment-wide labels for OpenTelemetry traces. The trace destinations themselves are configured per workspace in the console, not in this file. See Tracing.

Other sections

billing (billing webhooks and the on-prem license file), saas (signup_approval_required), notifications.slack and staff (Staff Portal session length) configure operator features of the control plane. The mode: key is accepted and ignored. See Deployment Model.

models

Each entry maps a logical name (what clients send) to one or more upstreams (where requests go):
Provider types that exist only in the console (for example bedrock_mantle, sagemaker or databricks) cannot be declared in gateway.yaml.

aliases

A model may declare additional names that resolve to it. Aliases let callers keep sending a name they already use while you change what serves it:
Aliases appear in GET /v1/models, work on GET /v1/models/{model}, and a team policy naming either the alias or the model grants both. A model name always wins over an alias of the same name, so an alias can never reroute traffic away from a real model. See Providers for per-provider configuration and OpenAI Compatibility for what each provider can honor.

teams

Seeds teams, their limits and API keys:
Teams and limits are upserted on every load. A key is created only if its SHA-256 hash is not already stored, and the plaintext never leaves the file or environment. Per-key limits, budgets and expiry are not set here; issue keys with POST /admin/keys or the console’s API Keys page to set them. Every name in models must be a logical_name defined above (or *). Send SIGHUP to a running service to reload models and teams without downtime. Other sections are read at startup. Sections that the console’s Settings page manages are seeded from this file on first boot and then owned by the database; see Settings & Configuration Precedence.