AI Gateway Ports, Files and Tables
This page is a lookup reference for Elchi AI Gateway on an edge (client VM or Elchi OS appliance) and in the control plane. Paths and modes are the ones the installer and the Elchi OS image create. On Elchi OS the same names apply unless a row says otherwise.
Sockets
All sockets live in /run/elchi-ai-gateway. systemd creates that directory at each start (RuntimeDirectory=elchi-ai-gateway, RuntimeDirectoryMode=2750, owner elchi:elchi, setgid). Envoy reaches the sockets because its user is in the elchi group.
| Socket | Served by | Envoy component | Mode | Flag / variable |
|---|---|---|---|---|
extproc.sock | Agent Router extproc | cluster elchi-ai-gateway: the AI ext_proc filter (router level) and the upstream ext_proc of every provider cluster | 0775 (set by the extproc) | --extproc-addr / ELCHI_AI_GATEWAY_EXTPROC_ADDR, default unix:///run/elchi-ai-gateway/extproc.sock |
authz.sock | the supervisor | cluster elchi-ai-gateway-authz: both ext_authz phases, the MCP result scan, the AI HCMs' gRPC access log | 0660 (set by the supervisor) | --authz-socket / ELCHI_AI_GATEWAY_AUTHZ_SOCKET, default /run/elchi-ai-gateway/authz.sock; empty disables it |
mcp.sock | the extproc's MCP proxy | cluster elchi-aigw-mcp__proxy, the gateways' /mcp routes | set by the extproc | --mcp-addr / ELCHI_AI_GATEWAY_MCP_ADDR, default unix:///run/elchi-ai-gateway/mcp.sock; empty disables MCP |
TCP ports
| Port | Bound by | Address | Purpose | Exposure |
|---|---|---|---|---|
9002 | supervisor | 127.0.0.1 | /healthz, /readyz, /configz, /metrics (and /debug/pprof with --pprof) | Loopback only. Another address needs --allow-non-loopback. |
9003 | supervisor | 127.0.0.1 | OTLP/gRPC receiver for the extproc's spans (the request log) | Refuses to start on a non-loopback address |
9064 | extproc | every interface | extproc admin: metrics and health, no authentication | Closed to non-loopback traffic by the nftables table inet elchi_ai_gateway |
10088 | Envoy (entry <listener>-mcp of every AI listener) | 127.0.0.1 | MCP egress: the extproc calls every MCP server through it | Only the gateway's processes connect, only Envoy's user answers (nftables). Present only while the project has MCP servers. |
6060 | — | — | The extproc's pprof port | Never opened: the extproc always runs with DISABLE_PPROF=1 |
Your AI listeners' own ports (HTTPS and/or HTTP) are the ones you set on the listener. 10088 is refused as a listener port.
Directories and files on the edge
| Path | Owner | Mode | Content |
|---|---|---|---|
/etc/elchi/bin/elchi-ai-gateway | root:elchi | 0755 | The supervisor binary |
/etc/elchi/elchi-ai-gateway/ | root:elchi | 0750 | The gateway's configuration directory. Read-only to the service. |
/etc/elchi/elchi-ai-gateway/config.yaml | elchi:elchi | 0600 | Operator-owned process settings, read once at start: project, ClickHouse DSN, request log, telemetry, extproc pin. Holds the ClickHouse credentials. |
/etc/elchi/elchi-ai-gateway/conf.d/ | elchi:elchi | 0750 | The configuration the agent delivers, hot-reloaded. Never edit by hand on a managed edge. |
conf.d/00-providers.yaml | elchi:elchi | 0600 | Providers with credentials, spec limits, prices, sensitive-data policy, request-log recipient, MCP servers and session seed |
conf.d/00-consumers.yaml | elchi:elchi | 0600 | Consumers with key hashes. Present only when the project has consumers. |
conf.d/gw-<gateway>.yaml | elchi:elchi | 0600 | One file per gateway |
conf.d/*.tmp | elchi:elchi | The agent's staging files during a push. The gateway ignores them. | |
/etc/elchi/elchi-ai-gateway/firewall.nft | root | 0644 | Plain Linux: the nftables table the installer writes |
/usr/lib/elchi/elchi-ai-gateway.nft | root | Elchi OS: the same table, plus the cgroup-based MCP egress chain | |
/var/lib/elchi/ai-gateway/ | elchi:elchi | 0700 | The service's only writable path |
/var/lib/elchi/ai-gateway/<version>/extproc | elchi | 0750 | A downloaded or placed extproc binary. The two most recent versions are kept. |
/var/lib/elchi/ai-gateway/<version>/extproc.version_string | elchi | 0640 | The binary's config version string (the "version gate") |
/var/lib/elchi/ai-gateway/<version>/extproc.sha256 | elchi | 0640 | The checksum verified at download, re-checked on every start |
/var/lib/elchi/ai-gateway/last-good.json | elchi | 0600 | The last accepted configuration. Restored when conf.d is unusable at start. |
/var/lib/elchi/ai-gateway/fileid.seed | elchi | 0600 | Files/Batch API id encryption seed, generated on first start, never on the command line |
/run/elchi-ai-gateway/bundle/index.yaml | elchi | 0600 | The extproc's config bundle index (version, uuid, checksum, parts) |
/run/elchi-ai-gateway/bundle/parts/<sha> | elchi | 0600 (directory 0700) | The rendered configuration, content-addressed. It carries provider credentials, so it lives on tmpfs. |
/run/elchi-ai-gateway/env, proxy.env | Elchi OS only: environment written at each start (the extproc version and index, and the egress proxy) |
systemd units
| Unit | Where | What |
|---|---|---|
elchi-ai-gateway.service | Plain Linux (written by the installer) and Elchi OS (in the image) | The supervisor. User=elchi, Restart=always, RestartSec=5, TimeoutStopSec=60, KillMode=mixed (SIGTERM reaches only the supervisor, which stops the extproc with a 20 s grace). ExecStartPre runs elchi-ai-gateway validate on conf.d (non-fatal). |
elchi-ai-gateway-firewall.service | Both | Oneshot, before network-pre.target. Loads the nftables table at boot, whether or not the gateway runs. |
elchi-ai-gateway.service.d/10-oom.conf | Elchi OS | OOMScoreAdjust=-300: the gateway sits in the request path of every AI listener |
On plain Linux the unit passes its settings as flags (--config-dir, --config-file, --extproc-addr, --http-addr, --log-format json, --log-level info). On Elchi OS it passes them as ELCHI_AI_GATEWAY_* variables. An operator-pinned older gateway ignores an unknown variable, but would stop at start on an unknown flag.
The journal identifier is elchi-ai-gateway (journalctl -u elchi-ai-gateway). On Elchi OS: show ai-gateway, logs ai-gateway, restart ai-gateway.
Environment variables and flags
Precedence: flag > ELCHI_AI_GATEWAY_* variable > config.yaml > built-in default. The extproc never inherits these variables.
| Variable | Flag | Default | Meaning |
|---|---|---|---|
ELCHI_AI_GATEWAY_INSTANCE_ID | --instance-id | <hostname>-ai-gateway | Stamped on logs, usage and request rows |
ELCHI_AI_GATEWAY_CONFIG_DIR | --config-dir | /etc/elchi/elchi-ai-gateway/conf.d | The hot-reloaded configuration |
ELCHI_AI_GATEWAY_CONFIG_FILE | --config-file | (none) | config.yaml, read once at start |
ELCHI_AI_GATEWAY_BUNDLE_DIR | --bundle-dir | /run/elchi-ai-gateway/bundle | Where the extproc reads its config bundle. Keep it on tmpfs. |
ELCHI_AI_GATEWAY_LAST_GOOD_PATH | --last-good-path | <extproc-base-dir>/last-good.json | The persisted last accepted configuration |
ELCHI_AI_GATEWAY_FILE_ID_SEED_FILE | --file-id-seed-file | <extproc-base-dir>/fileid.seed | The Files/Batch id seed |
ELCHI_AI_GATEWAY_USAGE_GATEWAY_HEADER | --usage-gateway-header | x-elchi-ai-gateway | The header naming the gateway (set by Envoy) |
ELCHI_AI_GATEWAY_HTTP_ADDR | --http-addr | 127.0.0.1:9002 | Status HTTP server |
ELCHI_AI_GATEWAY_ALLOW_NON_LOOPBACK | --allow-non-loopback | false | Allow --http-addr beyond loopback |
ELCHI_AI_GATEWAY_PPROF | --pprof | false | /debug/pprof on the status server |
ELCHI_AI_GATEWAY_ENTRA_DISABLE_INSTANCE_DISCOVERY | --entra-disable-instance-discovery | false | Skip Entra ID authority validation (a private authority set with AZURE_AUTHORITY_HOST) |
ELCHI_AI_GATEWAY_EXTPROC_ADDR | --extproc-addr | unix:///run/elchi-ai-gateway/extproc.sock | The extproc's socket |
ELCHI_AI_GATEWAY_MCP_ADDR | --mcp-addr | unix:///run/elchi-ai-gateway/mcp.sock | The MCP proxy's socket. Empty disables MCP. |
ELCHI_AI_GATEWAY_MCP_WRITE_TIMEOUT | --mcp-write-timeout | 15m | Longest an MCP answer or SSE stream may take |
ELCHI_AI_GATEWAY_MCP_EGRESS_ADDR | --mcp-egress-addr | http://127.0.0.1:10088 | The MCP egress. Must be 127.0.0.1. |
ELCHI_AI_GATEWAY_AUTHZ_SOCKET | --authz-socket | /run/elchi-ai-gateway/authz.sock | Consumer authorization. Empty disables it. |
ELCHI_AI_GATEWAY_AUTHZ_REFRESH_INTERVAL | --authz-refresh-interval | 1m | How often the quota counters re-read the other edges' usage from ClickHouse |
ELCHI_AI_GATEWAY_EXTPROC_ADMIN_PORT | --extproc-admin-port | 9064 | The extproc's admin port |
ELCHI_AI_GATEWAY_EXTPROC_VERSION | --extproc-version | (none) | The extproc release to download from the archive, e.g. v1.3.0 |
ELCHI_AI_GATEWAY_EXTPROC_BINARY | --extproc-binary | (none) | A pre-placed binary (offline installs; no download) |
ELCHI_AI_GATEWAY_EXTPROC_BINARY_SHA256 | --extproc-binary-sha256 | (none) | Its expected checksum |
ELCHI_AI_GATEWAY_EXTPROC_VERSION_STRING | --extproc-version-string | (none) | Override the version the extproc's config gate demands |
ELCHI_AI_GATEWAY_EXTPROC_FORCE_DOWNLOAD | --extproc-force-download | false | Download again even when cached |
ELCHI_AI_GATEWAY_EXTPROC_BASE_DIR | --extproc-base-dir | /var/lib/elchi/ai-gateway | Binary store, seed, last-good |
ELCHI_AI_GATEWAY_EXTPROC_INDEX_URL | --extproc-index-url | https://archive.elchi.io/index.json | The archive index (point it at a mirror when air-gapped) |
ELCHI_AI_GATEWAY_EXTPROC_KILL_TIMEOUT | --extproc-kill-timeout | 20s | SIGTERM → SIGKILL grace. Must exceed the extproc's fixed 15 s drain. |
ELCHI_AI_GATEWAY_EXTPROC_LOG_LEVEL | --extproc-log-level | --log-level | The extproc's log level. Bodies are always redacted. |
ELCHI_AI_GATEWAY_ENDPOINT_PREFIXES | --endpoint-prefixes | (upstream default) | e.g. anthropic:/ serves the native Anthropic API at /v1/messages |
ELCHI_AI_GATEWAY_WATCH_DEBOUNCE | --watch-debounce | 300ms | Quiet period before a conf.d change reloads |
ELCHI_AI_GATEWAY_USAGE_SCRAPE_INTERVAL | --usage-scrape-interval | 30s | How often token metrics are scraped for usage |
ELCHI_AI_GATEWAY_USAGE_PROJECT | --usage-project | (none) | Project id stamped on rows |
ELCHI_AI_GATEWAY_USAGE_CLICKHOUSE_DSN | --usage-clickhouse-dsn | (none) | ClickHouse for usage, request log and the other tables. Empty disables them all. |
ELCHI_AI_GATEWAY_USAGE_CLICKHOUSE_TABLE | --usage-clickhouse-table | elchi_ai_gateway_usage | Usage table |
ELCHI_AI_GATEWAY_USAGE_CLICKHOUSE_TTL_DAYS | --usage-clickhouse-ttl-days | 90 | Usage retention. Raised to at least 32. |
ELCHI_AI_GATEWAY_REQUESTS_ENABLED | --requests-enabled | true | Request-log kill switch |
ELCHI_AI_GATEWAY_REQUESTS_TABLE | --requests-table | elchi_ai_gateway_requests | Request-log table |
ELCHI_AI_GATEWAY_MCP_CALLS_TABLE | --mcp-calls-table | elchi_ai_gateway_mcp_calls | MCP call-log table |
ELCHI_AI_GATEWAY_UPSTREAM_TABLE | --upstream-table | elchi_ai_gateway_upstream | Provider-answers table |
ELCHI_AI_GATEWAY_DECISIONS_TABLE | --decisions-table | elchi_ai_gateway_decisions | Decision-log table |
ELCHI_AI_GATEWAY_REQUESTS_RECEIVER_ADDR | --requests-receiver-addr | 127.0.0.1:9003 | The loopback span receiver |
ELCHI_AI_GATEWAY_REQUESTS_FORWARD_ENDPOINT | --requests-forward-endpoint | (none) | An external OTLP/gRPC endpoint receiving policy-filtered spans |
ELCHI_AI_GATEWAY_REQUESTS_FORWARD_INSECURE | --requests-forward-insecure | false | Forward without TLS |
ELCHI_AI_GATEWAY_REQUESTS_FORWARD_HEADERS | --requests-forward-headers | (none) | k=v,k2=v2 |
ELCHI_AI_GATEWAY_METRICS_OTLP_ENDPOINT | --metrics-otlp-endpoint | (none) | Push the extproc's GenAI metrics over OTLP/gRPC |
ELCHI_AI_GATEWAY_METRICS_OTLP_INSECURE | --metrics-otlp-insecure | false | Push without TLS |
ELCHI_AI_GATEWAY_METRICS_OTLP_CA_CERT | --metrics-otlp-ca-cert | (none) | CA certificate file |
ELCHI_AI_GATEWAY_METRICS_OTLP_HEADERS | --metrics-otlp-headers | (none) | k=v,k2=v2 |
ELCHI_AI_GATEWAY_LOG_LEVEL | --log-level | info | debug, info, warn, error |
ELCHI_AI_GATEWAY_LOG_FORMAT | --log-format | json | json or text |
ELCHI_AI_GATEWAY_LOG_SOURCE | --log-source | false | Source file:line in logs |
ELCHI_AI_GATEWAY_SHUTDOWN_TIMEOUT | --shutdown-timeout | 30s | Graceful shutdown budget |
elchi-ai-gateway validate <dir> checks a configuration directory without starting anything. Exit 0 = valid (or empty), 1 = invalid (the error on stderr), 2 = usage error. Warnings go to stderr as warning: ….
ClickHouse tables
The gateway creates these tables in the database of its DSN and adds new columns on upgrade. The control plane reads the same names. An edge whose DSN is empty writes nothing.
| Table | One row per | TTL | Read by |
|---|---|---|---|
elchi_ai_gateway_usage | scrape interval × edge × gateway × provider × model × consumer × token type: tokens, requests, durations, time to first token | usage.clickhouse_ttl_days, default 90, at least 32 (the monthly quotas sum a whole month) | Usage page, cost, consumer quotas across edges |
elchi_ai_gateway_usage_1h | UTC hour × project × gateway × provider × model × consumer × token type (SummingMergeTree, filled by a materialized view) | same as usage | Usage page over days, weeks, months |
elchi_ai_gateway_requests | LLM request: ids, status, error, duration, token breakdown, and (at capture level full) encrypted content | per row: the gateway's retentionDays (default 7, 1–365) | Request log |
elchi_ai_gateway_requests_1h | UTC hour × project × gateway × provider × model × consumer × status × latency bucket | 90 days | Usage summary: error rate and latency percentiles |
elchi_ai_gateway_upstream | minute × edge × gateway × provider × class × HTTP code × retried: count | 30 days | Provider status (Providers tab) |
elchi_ai_gateway_decisions | Denial or flagged request: phase, status, code, sensitive types and counts (never values) | 90 days | Sensitive data tab, usage summary |
elchi_ai_gateway_mcp_calls | MCP call: gateway, consumer, server, method, tool, status, class, duration | usage.clickhouse_ttl_days, default 90, at most 365 | MCP calls tab, MCP call quotas |
elchi_ai_gateway_mcp_calls_1h | UTC hour × gateway × consumer × server × method × tool × class × latency bucket | 90 days | Hourly rollup of the call log, written by the gateway |
elchi_ai_gateway_rollups | (rollup, since): when each hourly rollup started | none | The control plane reads a rollup only for the whole hours after its earliest note |
The rollups are never backfilled. For hours before a rollup existed, the control plane reads the raw table.
Generated Envoy resources
All of these carry general.metadata.managed_by: elchi-ai-gateway. You can view them but not edit them. Names starting with elchi-aigw- or elchi-ai-gateway are reserved.
Defaults (seeded per project, per Envoy version):
| Name | Kind | Purpose |
|---|---|---|
elchi-ai-gateway | Cluster | The extproc socket (extproc.sock), HTTP/2 |
elchi-ai-gateway | HTTP filter (ExternalProcessor) | The AI ext_proc filter, fail-closed |
elchi-ai-gateway-credential | HTTP filter (HeaderToMetadata) | First AI filter: moves x-elchi-provider-key into metadata |
elchi-ai-gateway-header | HTTP filter (HeaderMutation) | Sets the gateway header per virtual host |
elchi-ai-gateway-authz | Cluster | The authorization socket (authz.sock) |
elchi-ai-gateway-authz-key | HTTP filter (ExtAuthz) | The key phase, before the extproc |
elchi-ai-gateway-authz-model | HTTP filter (ExtAuthz) | The model phase, after the extproc |
elchi-ai-gateway-mcp-guard | HTTP filter (ExternalProcessor) | The MCP result scan, inert until a route turns it on |
elchi-ai-gateway-als | Access log (gRPC) | The AI HCMs' access log to the authorization socket |
Generated by every deploy:
| Name | Kind | Purpose |
|---|---|---|
elchi-aigw-<provider> | Cluster | One per provider |
elchi-aigw-<provider>-tls | Upstream TLS context | Its TLS |
elchi-aigw-m-<gateway>-<hash> | Cluster | A model several providers serve (a pool) |
elchi-aigw-upstream-hpo | HttpProtocolOptions | The provider clusters' upstream filter chain |
elchi-aigw-upstream-extproc, elchi-aigw-upstream-cl, elchi-aigw-upstream-codec | Upstream HTTP filters | That chain: ext_proc, content-length, codec |
elchi-aigw-retry-previous-hosts, elchi-aigw-retry-prio-<n> | Retry extensions | Pool failover |
elchi-aigw-gw-<gateway>-header | HeaderMutation per route | Sets x-elchi-ai-gateway: <gateway> |
elchi-aigw-gw-<gateway>-authz-model | ExtAuthz per route | The model phase reading the body (sensitive data) |
elchi-aigw-gw-<gateway>-mcp-authz, elchi-aigw-gw-<gateway>-mcp-guard | Per route | A gateway's own MCP phase and result scan |
elchi-aigw-authz-key-off, elchi-aigw-authz-model-off, elchi-aigw-extproc-off | Per route (disabled) | Turn a filter off where it does not apply |
elchi-aigw-l-<listener> | Route | A listener's route: a virtual host per gateway bound to it |
elchi-aigw-unclaimed | Virtual host | A listener with no default gateway: 404 gateway_not_found |
elchi-aigw-mcp_<server> (_tls, _hpo, _cred, _inject, _generic) | Cluster, TLS, HPO, GenericSecret, credential injector | One MCP server and its shared credential |
elchi-aigw-mcp__proxy, elchi-aigw-mcp__authz, elchi-aigw-mcp__h2m, elchi-aigw-mcp__als, elchi-aigw-mcp__egress | Cluster, per-route, filter, access log, route | The MCP proxy and the egress |
Per AI listener (created by the listener call, named after it): the listener <listener>, its HCM <listener>-hcm, <listener>-redirect-hcm for a plain-HTTP port in redirect mode, and <listener>-mcp-hcm with the loopback entry <listener>-mcp while the project has MCP servers. That is why listener names may not end in -mcp or -redirect.
Route names inside a gateway's virtual host, as access logs show them in %ROUTE_NAME%: <gateway>/models/openai, <gateway>/models/anthropic, <gateway>/unrouted, <gateway>/model/<model>, <gateway>/not-served.
Metadata keys and headers
| Key | Where | Meaning |
|---|---|---|
aigateway.envoy.io → per_route_rule_backend_name | Provider endpoint metadata | The provider whose credential the extproc injects. Reserved: a user resource cannot write this namespace. |
aigateway.envoy.io → upstream_host | Provider endpoint metadata (DNS hosts) | The host AWS SigV4 signs |
aigateway.envoy.io → aigw_route_name | Route metadata | The gateway a route belongs to |
io.envoy.ai_gateway | Dynamic metadata | The extproc's own (cost, content_length) |
io.elchi.aigw.credential → provider_key | Dynamic metadata | A client's own provider key (credentialOverride) |
io.elchi.aigw.mcp → consumer, gateway, server, method, tool | Dynamic metadata on the MCP egress | The MCP call log's fields |
general.metadata.managed_by: elchi-ai-gateway | Every generated resource | Generated, read-only |
ai_gateway_version | Client registration metadata | The gateway version an edge reports. Edges without it get no configuration. Versions below v0.4.0 hold MCP back. |
x-elchi-authz-phase | gRPC metadata to the authorization | key or model |
aigw_phase: mcp | ext_authz context extensions on /mcp routes | The MCP phase |
x-elchi-ai-gateway | Request header | The gateway name, always set by Envoy |
x-elchi-consumer | Request header | The admitted consumer, set only by the authorization. A client's copy is removed. |
x-ai-eg-model | Request header | The model, set by the extproc. A client's copy is removed. |
x-elchi-provider-key | Request header | A client's own provider key, moved to metadata and removed |
x-elchi-mcp-token, x-elchi-mcp-token-<server> | Request header | A user's own MCP server token |