Skip to content

Quickstart

Last updated: 2026-11-27T14:53:32-03:00 (UTC-3)

In about ten minutes you run m7gtw on your machine with Docker Compose, make a first call through it, sign in to the console, create a key for an app and find the API reference. At the end, choose your deploy for a real environment, and keep the tips at hand.

Every command on this page runs from the root of the source tree, and continuous integration runs them, in this order, whenever this page, the Compose files or the image’s build files change, and before every version.

  • Docker with the Compose plugin (docker compose version answers): Docker Engine on Linux, or Docker Desktop or OrbStack on macOS and Windows. The gateway image is built for linux/amd64 and linux/arm64.
  • Git, to get the files; a local build also records the commit it came from.
  • Python 3 for the secrets script (standard library only).
  • The deployment files: the Compose file, the example configuration and the secrets script live at the root of the source tree.
  • Port 8080 free on 127.0.0.1, or another one through GATEWAY_PORT (tips).
  • An OpenAI API key for the example model. Without one the gateway still starts and everything but the call to OpenAI works; other providers come later, through the console.

Check out the version you deploy, so that the Compose file and the configuration match the image:

Terminal window
git clone https://github.com/m7gtw/gateway.git m7gtw
cd m7gtw
git checkout v<version> # the release you deploy; skip it to follow the latest source

Compose runs the image that the variable GATEWAY_IMAGE names, gateway:local when it is unset. Set it once in the shell you run Compose from.

The published image. Each release publishes the image to the GitHub Container Registry as ghcr.io/m7gtw/gateway:<version>, for linux/amd64 and linux/arm64, under its own version tag only: there is no latest, and a version is never rebuilt in place. The release candidates published so far (0.0.1-rc.N) are private; the first public release is 0.0.1. Once it is out:

Terminal window
export GATEWAY_IMAGE=ghcr.io/m7gtw/gateway:0.0.1
docker pull "$GATEWAY_IMAGE"

Pulling first shows a sign-in or name error on its own, before anything starts. The start command below never builds: when the image is not on the machine, Compose pulls it (its default pull_policy: missing), and when it cannot, the start fails instead of building something you did not choose under that name. In production pin the digest that RELEASED.md records for the version (ghcr.io/m7gtw/gateway@sha256:...). If you were given access to a private release candidate, sign in first with docker login ghcr.io and a GitHub token with the read:packages scope.

Build it locally. Until the first public release, this is the way; it needs only Docker and the checkout:

Terminal window
export GATEWAY_IMAGE=gateway:local
scripts/build-image.sh "$GATEWAY_IMAGE"

The first build downloads the build images and the dependencies and takes a few minutes; later builds reuse the cache. If the machine already has a gateway:local image, the build moves that tag to the new image and the old one stays behind untagged (<none> in docker images); to keep it, pick another name before building, such as export GATEWAY_IMAGE=gateway:quickstart. Either way, the image says what it is:

Terminal window
docker run --rm "$GATEWAY_IMAGE" version

It prints one JSON line with the version, the source revision, whether the tree had uncommitted changes (modified), and the platform. More on the image’s contents in building the image.

Put your OpenAI key in the environment first; the script copies it into an ignored local file, and nothing else keeps it:

Terminal window
export OPENAI_API_KEY=sk-...
Terminal window
python3 scripts/bootstrap-local-secrets.py --target docker

The script creates deploy/docker/.env.local and three tokens in deploy/docker/, all with 0600 permissions and ignored by Git:

  • admin-token.env.local: the console administrator’s sign-in;
  • viewer-token.env.local: a read-only sign-in;
  • client-token.env.local: a client key ready for the first call.

The gateway stores only the SHA-256 of these tokens, never the value. .env.local also holds GATEWAY_DATABASE_PASSWORD, the password of the Compose PostgreSQL, the GATEWAY_DATABASE_URL that uses it, the console session and provider encryption keys, and GATEWAY_ANALYTICS_STORE_PASSWORD, used only by the optional analytics store. Without OPENAI_API_KEY in the environment it writes a placeholder.

Running the script again keeps every value already there, so it never changes a password a volume was created with. A file written by 0.0.1-rc.2 or earlier has the passwords as GATEWAY_POSTGRES_PASSWORD and GATEWAY_CLICKHOUSE_PASSWORD: the script copies each to its new name with the same value, keeps the old key until you remove it, and warns if both names hold different values (the renamed infrastructure names).

Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml up --no-build -d --wait

Three services start: the gateway, a PostgreSQL with its data in the gateway_db volume, and an OpenTelemetry Collector. --wait returns once the gateway’s health check passes, which took about 40 seconds on the validation machine (the database migrations run on the first start). --no-build runs the image GATEWAY_IMAGE names, pulling it if it is not on the machine, and never builds one.

Check that it is ready:

Terminal window
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/health/ready

It prints 200. The bundled configuration also serves Prometheus metrics at http://localhost:8080/metrics (observability). An optional analytics store (ClickHouse) for large deployments starts only when you add --profile analytics-store to the start command; you do not need it here (analytics store).

The example configuration (config/gateway.yaml) routes the model alias chat-default to gpt-4o-mini on OpenAI, and accepts the client key from step 3:

Terminal window
export TOKEN=$(cut -d= -f2- deploy/docker/client-token.env.local)
curl -s http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"model":"chat-default","messages":[{"role":"user","content":"Hello!"}]}'

The answer is an OpenAI Chat Completions object. With the placeholder key, OpenAI refuses the call and the gateway answers with an error instead of a completion: put your key in OPENAI_API_KEY in deploy/docker/.env.local and run the start command again, which recreates the gateway with it.

Any OpenAI-compatible SDK works by changing the base URL:

import os
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key=os.environ["TOKEN"])
print(client.chat.completions.create(model="chat-default", messages=[{"role": "user", "content": "Hello!"}]).choices[0].message.content)

The Anthropic and Google SDKs work the same way; see official SDKs.

The console is served by the gateway itself:

Terminal window
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/ui/

Open http://localhost:8080/ui/ in a browser and sign in with the administrator token:

Terminal window
cut -d= -f2- deploy/docker/admin-token.env.local

In the console you:

  • see the call you just made in Logs → Requests, with tokens, latency and the team;
  • connect other providers in Providers (the Integrations tab lists the ready-made presets), then route a model alias to them in Model catalog;
  • try models in the Playground;
  • follow usage and cost on the home page, Usage.

The console guide describes every page.

In Virtual keys, create a key for the platform team, with the chat-default model and the chat route. The value is shown only once: store it in your vault or in the app’s secret store. The call from step 5 works the same way with it, and Logs → Requests shows the app’s name. Expiry is optional: the key never expires unless you choose a date or a duration (key lifecycle).

The interactive API reference (Swagger UI) and the OpenAPI contract are served by the gateway too:

Terminal window
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/docs/swagger/
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/openapi.yaml

Open http://localhost:8080/docs/swagger/. This documentation site is published apart from the gateway; see where the documentation site lives.

The commands you will use day to day:

Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml ps
Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml logs --tail 20 gateway

The gateway logs one JSON object per line and never logs prompts, responses or credentials; add -f to follow them.

Check a configuration change before you restart with it (configuration valid, or the error and a non-zero exit code):

Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml exec gateway /gateway validate

Back up the database, above all before an upgrade:

Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml exec -T db pg_dump -U gateway gateway > gateway-backup.sql

Keep deploy/docker/.env.local with the backup: without its GATEWAY_PROVIDER_ENCRYPTION_KEY, the provider credentials stored in the database cannot be opened.

Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml down

down keeps the database volume: the next start finds your keys, providers and logs. To delete everything, data included:

Terminal window
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml down -v

down -v cannot be undone; never use it as a rollback.

The same gateway, configuration format and console run in every mode; what changes is how the configuration, the secrets and PostgreSQL reach it.

Mode When Start here
Docker Compose one machine, evaluation, a small team this page; Docker Compose for the variables
Compose with your own infrastructure the gateway in a container, your PostgreSQL and Collector external infrastructure
Helm Kubernetes, with values, a bundled or external PostgreSQL, Ingress and ServiceMonitor installing with Helm
Kustomize Kubernetes from plain manifests and your overlays installing with Kustomize
Native binary a VM or a host without containers; no Node or Docker needed binary and NPX, CLI
NPX the same binary, launched through Node binary and NPX
Offline bundle an environment without internet access offline bundle

Every mode needs a PostgreSQL; Compose, the Helm chart, the Kustomization and the offline bundle bring one, and the binary and NPX use yours (managed PostgreSQL). Before production, read security and trust and operations; on Kubernetes, then follow run on Kubernetes in production, from several zones to several regions.

  • The gateway listens on 127.0.0.1:8080 only, so nothing outside your machine reaches it. GATEWAY_PORT=9090 before the start command moves it to another port.
  • PostgreSQL and the Collector publish no port to the host.
  • Behind a reverse proxy or on another machine, serve HTTPS at the edge and set admin.allow_insecure_http: false (hardening).
  • GET /health/live answers 200 while the process runs. GET /health/ready answers 200 once the configuration is loaded and the server is up (the port opens only after the database is reached and migrated), and 503 as soon as the replica starts shutting down. The Helm chart’s probes use the same two paths.
  • The image’s own health check is /gateway healthcheck (no shell in the image); Compose runs it every 10 seconds (healthcheck).
  • docker compose ... ps shows healthy once the check passes. A gateway stuck in starting or restarting usually names its problem in the first lines of its logs, such as a missing variable.
  • Logs go to stdout as JSON, and to the bundled Collector over OTLP; traces go there too. Point the Collector at your backend in deploy/base/collector.yaml (observability).
  • Every answer carries X-Request-Id; give it to whoever reads the logs, and find the call in Logs → Requests.
  • config/gateway.yaml is mounted read-only into the container. To use your own, copy it and point GATEWAY_CONFIG_FILE at the copy (an absolute path) before the start command; run the start command again to apply a change.
  • Many settings can also change from the console without a restart; what to configure where says which, and which need one.
  • Secrets never go in the YAML: the YAML names the variable (api_key_env: OPENAI_API_KEY) and .env.local or your secret store holds the value.
  1. Read the changelog of the new version.
  2. Back up the database (step 9).
  3. Check out the new version’s files, set GATEWAY_IMAGE to its image and pull it (or build it), then run the start command again: Compose recreates the gateway, which applies the new migrations on start.
Terminal window
export GATEWAY_IMAGE=ghcr.io/m7gtw/gateway:<new version>
docker pull "$GATEWAY_IMAGE"
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml up --no-build -d --wait

A rollback does not undo migrations: going back means restoring the backup taken before the upgrade (upgrading and rolling back).

  • Parameter registry: every setting, with its default, bounds, YAML key, environment variable and console place.
  • What to configure where: the YAML, the API and the console, and which one wins.
  • Inference flags and edition defaults: the feature flags and their defaults.
  • CLI: the commands and the process variables (GATEWAY_CONFIG, GATEWAY_DATABASE_URL, …).
  • Deployment modes: the variables of each mode (GATEWAY_IMAGE, GATEWAY_PORT, GATEWAY_CONFIG_FILE, GATEWAY_ENV_FILE).

m7gtw[email protected]