# Install the Gateway (https://powercontext.oceanbase.io/en/docs/operate/install-gateway/)

The Gateway is a separate executable named `pc-gateway`. It connects to a running PowerContext Server (Core);
installing the Python package does not install the Gateway. Releases built with the Gateway distribution workflow
attach four native archives to the same [PowerContext GitHub Release](https://github.com/oceanbase/powercontext/releases).
Older releases without these attachments require a source build. Select a release with all four archives and a
successful **Gateway distribution** verification; an existing tag alone does not mean publication has finished.

## Supported platforms [#supported-platforms]

| System | Architecture | Archive target | Runtime baseline |
| --- | --- | --- | --- |
| Linux | x86_64 | `x86_64-unknown-linux-gnu` | glibc 2.28+ |
| Linux | arm64 | `aarch64-unknown-linux-gnu` | glibc 2.28+ |
| macOS | Intel | `x86_64-apple-darwin` | macOS 15+ |
| macOS | Apple Silicon | `aarch64-apple-darwin` | macOS 15+ |

Linux archives are not Alpine/musl builds. macOS archives are unsigned and not notarized; macOS may require
approval under its normal security controls. Windows archives and a Gateway container image are not provided.
CLI-backed subscription routes still require their provider CLI and sign-in on the Gateway host.

Linux release checks cover native Ubuntu 22.04 and Rocky Linux 8 container userspace on both architectures.
Containers share the runner's kernel, so these checks do not establish compatibility with historical kernels or
entire older distributions. Core's Python and SQLite requirements and each provider CLI's requirements apply
separately from the Gateway's glibc baseline.

### Windows [#windows]

There is no native Windows executable in this release. The Gateway currently depends on Unix socket transport and
Unix signal handling; adding a Windows build runner alone does not provide Windows support.
On Windows, use a WSL2 Ubuntu 22.04 or newer distribution and follow the Linux instructions **inside WSL2**.
Run Core and any provider CLI in the same Linux environment. This uses the Linux package, not a native Windows build;
the distribution CI validates Ubuntu runners, not WSL2 host integration.

## Download and verify [#download-and-verify]

The example selects 1.6.0. Use the same release version as Core. No Rust compiler or repository checkout is needed.
Download the archive and its checksum from the selected release, then verify before extracting or installing:

```bash
set -eu
version=1.6.0
case "$(uname -s)/$(uname -m)" in
  Linux/x86_64) target=x86_64-unknown-linux-gnu ;;
  Linux/aarch64|Linux/arm64) target=aarch64-unknown-linux-gnu ;;
  Darwin/x86_64) target=x86_64-apple-darwin ;;
  Darwin/arm64) target=aarch64-apple-darwin ;;
  *) echo "Unsupported platform" >&2; exit 1 ;;
esac
archive="powercontext-gateway-$version-$target.tar.gz"
base="https://github.com/oceanbase/powercontext/releases/download/powercontext-v$version"
mkdir -p "gateway-$version-$target"
cd "gateway-$version-$target"
curl --fail --location --output "$archive" "$base/$archive"
curl --fail --location --output "$archive.sha256" "$base/$archive.sha256"
if command -v sha256sum >/dev/null 2>&1; then
  sha256sum --check "$archive.sha256"
else
  shasum -a 256 --check "$archive.sha256"
fi
tar -xzf "$archive"
./pc-gateway --version
mkdir -p "$HOME/.local/bin"
install -m 755 pc-gateway "$HOME/.local/bin/pc-gateway"
export PATH="$HOME/.local/bin:$PATH"
```

`--version` prints the PowerContext release version, full source commit and Rust target; `--help` works without Core.
The archive also contains `manifest.json` with the binary SHA256 and platform baseline, the project license, and
Gateway documentation. The Release provides `powercontext-gateway-SHA256SUMS` and
`powercontext-gateway-manifest.json` for all four platforms. Checksums detect changed bytes; they are not code signatures.
Add `$HOME/.local/bin` to your shell's PATH if it is not already present.

## Connect to Core [#connect-to-core]

Start Core first using [Server deployment](https://powercontext.oceanbase.io/en/llms.mdx/docs/operate/deploy-server/content.md). For a standalone Gateway connected to Core over HTTP,
configure an accessible Scope and a matching approved upstream profile, then run:

```bash
PC_GATEWAY_CORE_BASE=http://127.0.0.1:8000 \
PC_GATEWAY_CORE_TOKEN="$POWERCONTEXT_DEPLOYMENT_TOKEN" \
PC_GATEWAY_DEFAULT_SCOPE=your-scope \
PC_GATEWAY_UPSTREAM_PROFILE=approved-provider \
PC_GATEWAY_UPSTREAM_URL_CHAT=https://provider.example/v1/chat/completions \
PC_GATEWAY_UPSTREAM_API_KEY_CHAT="$PROVIDER_API_KEY" \
pc-gateway
```

The default Gateway listener is loopback. For a combined deployment, replace `PC_GATEWAY_CORE_BASE` with
`PC_GATEWAY_CORE_UDS=/path/to/core.sock`; Core must already be listening on that private socket.
`PC_GATEWAY_API_KEY` protects model routes and is required for a non-loopback listener. It does not replace Core's
credentials for forwarded API, MCP or Dashboard routes. See [authentication boundaries](https://powercontext.oceanbase.io/en/llms.mdx/docs/operate/deploy-server/content.md#gateway-authentication-boundaries).

`curl --fail http://127.0.0.1:8787/healthz` checks the Gateway listener only. In a combined UDS deployment, an authenticated
request to `/v1/server-info` through the Gateway should return the same Server identity as Core. Standalone HTTP mode
does not forward Core routes. Provider/model acceptance remains separate from startup and connection checks.

For an upgrade, stop the Gateway, download and verify the matching release, replace the executable, then restart with
the existing configuration. Follow the Server's database maintenance requirements separately. Keep the previous binary
for operational rollback; replacing a Gateway binary does not roll back Core's database.

## Build from source [#build-from-source]

Check out the matching release tag and run `cargo build --locked --manifest-path gateway/Cargo.toml --release -p pc-gateway-app`.
The executable is `gateway/target/release/pc-gateway`. Source builds without distribution metadata report the Cargo package
version and an unknown commit; official release builds embed the release identity. See the
[Gateway README](https://github.com/oceanbase/powercontext/blob/master/gateway/README.md) for development and tests.
