# Quickstart

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

<!-- Editors: CI runs this page with scripts/run-quickstart.py (T182). The line right above each bash fence is a comment holding run: ID (it runs, in order) or no-run: REASON (shown only); `python3 scripts/run-quickstart.py check` lists problems. -->

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](#choose-your-deploy) for a real environment, and keep the [tips](#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.

## What you need

- **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](#ports)).
- **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.

## 1. Get the deployment files

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

<!-- no-run: the version is a placeholder -->
```bash
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
```

## 2. Get the gateway image

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:

<!-- no-run: no public release yet; release candidates are private -->
```bash
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](https://github.com/m7gtw/gateway/blob/main/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:

<!-- run: build -->
```bash
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:

<!-- run: image-version -->
```bash
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](/docs/operate/deployment-modes/#building-the-image).

## 3. Generate the local secrets

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

<!-- no-run: placeholder for the reader's own key -->
```bash
export OPENAI_API_KEY=sk-...
```

<!-- run: secrets -->
```bash
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](/docs/operate/operations/#upgrading-from-001-rc2-infrastructure-names)).

## 4. Start the gateway

<!-- run: up -->
```bash
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:

<!-- run: health -->
```bash
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](/docs/features/observability/#metrics-prometheus)). 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](/docs/features/analytics-store/)).

## 5. Make your first call

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:

<!-- run: first-call -->
```bash
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:

```python
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](/docs/reference/sdk-compatibility/).

## 6. Open the console

The console is served by the gateway itself:

<!-- run: console -->
```bash
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:

<!-- run: admin-token -->
```bash
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](/docs/features/console/) describes every page.

## 7. Create a key for an app

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](/docs/features/key-policy/)).

## 8. Explore the API reference

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

<!-- run: swagger -->
```bash
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](/docs/operate/deployment-modes/#documentation-site).

## 9. Look after it

The commands you will use day to day:

<!-- run: status -->
```bash
docker compose --env-file deploy/docker/.env.local -f deploy/docker/compose.yaml ps
```

<!-- run: logs -->
```bash
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):

<!-- run: validate -->
```bash
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:

<!-- run: backup -->
```bash
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.

## 10. Shut it down

<!-- run: down -->
```bash
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:

<!-- run: down-volumes -->
```bash
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.

## Choose your deploy

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](/docs/operate/deployment-modes/#docker-compose) for the variables |
| **Compose with your own infrastructure** | the gateway in a container, your PostgreSQL and Collector | [external infrastructure](/docs/operate/deployment-modes/#external-infrastructure) |
| **Helm** | Kubernetes, with values, a bundled or external PostgreSQL, Ingress and ServiceMonitor | [installing with Helm](/docs/operate/operations/#installing-with-helm) |
| **Kustomize** | Kubernetes from plain manifests and your overlays | [installing with Kustomize](/docs/operate/operations/#installing-with-kustomize) |
| **Native binary** | a VM or a host without containers; no Node or Docker needed | [binary and NPX](/docs/operate/deployment-modes/#binary-and-npx), [CLI](/docs/reference/cli/) |
| **NPX** | the same binary, launched through Node | [binary and NPX](/docs/operate/deployment-modes/#binary-and-npx) |
| **Offline bundle** | an environment without internet access | [offline bundle](/docs/operate/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](/docs/operate/managed-postgres/)). Before production, read [security and trust](/docs/security/trust/) and [operations](/docs/operate/operations/); on Kubernetes, then follow [run on Kubernetes in production](/docs/operate/kubernetes-production/), from several zones to several regions.

## Tips

### Ports

- 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](/docs/security/hardening/)).

### Health checks

- `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](/docs/reference/cli/#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 and telemetry

- 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](/docs/features/observability/)).
- Every answer carries `X-Request-Id`; give it to whoever reads the logs, and find the call in **Logs → Requests**.

### Your configuration

- `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](/docs/reference/configuration-parity/) 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.

### Upgrades

1. Read the [changelog](https://github.com/m7gtw/gateway/blob/main/CHANGELOG.md) of the new version.
2. Back up the database ([step 9](#9-look-after-it)).
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.

<!-- no-run: needs a newer version than the one running -->
```bash
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](/docs/operate/operations/#upgrading-and-rolling-back)).

### Where the parameters are documented

- [Parameter registry](/docs/reference/parameter-registry/): every setting, with its default, bounds, YAML key, environment variable and console place.
- [What to configure where](/docs/reference/configuration-parity/): the YAML, the API and the console, and which one wins.
- [Inference flags](/docs/reference/inference-flags/) and [edition defaults](/docs/operate/edition-defaults/): the feature flags and their defaults.
- [CLI](/docs/reference/cli/): the commands and the process variables (`GATEWAY_CONFIG`, `GATEWAY_DATABASE_URL`, ...).
- [Deployment modes](/docs/operate/deployment-modes/): the variables of each mode (`GATEWAY_IMAGE`, `GATEWAY_PORT`, `GATEWAY_CONFIG_FILE`, `GATEWAY_ENV_FILE`).

## Next steps

- [Concepts](/docs/start/concepts/): providers, models, keys, teams and flags.
- [Providers and models](/docs/features/feature-providers/): connect other providers and create aliases.
- [Access and governance](/docs/features/feature-access/): teams, roles, SSO and budgets.
- [Security and trust](/docs/security/trust/): before you go to production.
