AI Gateway Overview
Elchi AI Gateway is the LLM and MCP gateway of Elchi, a licensed add-on to Elchi Core. Applications call your edge, not the model providers. The edge picks a gateway by the request's Host, checks the caller's key and quotas, sends the request to the provider that serves the requested model with the provider's own credential, and records what happened.

You configure everything in the Elchi UI (Infrastructure → AI Gateway) or through the REST API under /api/v3/ai-gateway. Nothing is edited by hand on the edge.
What it is
- A project-scoped configuration in the control plane: shared providers (credentials, endpoints, prices), any number of gateways (hosts, models, limits, request-log policy), consumers with virtual keys and quotas, MCP servers, a sensitive-data policy, and the AI listeners that serve the gateways.
- Generated Envoy resources. The control plane generates the clusters, routes and filters each AI listener needs, per Envoy version. You never write Envoy configuration for it.
- An edge sidecar,
elchi-ai-gateway. One instance per edge (client) VM, shared by every AI listener on that VM. It supervises the engine, turns the delivered configuration into the engine's config bundle, answers the key and quota checks, scans for sensitive data, and exports usage and the request log to ClickHouse. - The engine: Agent Router extproc (formerly Envoy AI Gateway). Elchi runs the upstream extproc binary as the sidecar's child process. It parses OpenAI- and Anthropic-style requests, extracts the model, translates the request to the provider's API, injects the provider credential and counts tokens.
What it is not
- The sidecar is not in the request path. Envoy's
ext_procfilters connect straight to the extproc's Unix socket (/run/elchi-ai-gateway/extproc.sock); the supervisor only manages that process. Key and quota checks go to the sidecar's own socket (/run/elchi-ai-gateway/authz.sock). - Not a reimplementation of the engine. Request parsing, schema translation and token counting are the upstream extproc's. Elchi pins the version it renders for (v1.3.0).
- Not a model host. It routes to providers you configure: public APIs (OpenAI, Anthropic, Azure OpenAI, AWS, Google Cloud, Cohere, TypeSafe) or an OpenAI-compatible server of your own.
- Not a WAF. Shield (Shield overview) and the AI gateway can run on the same HTTP connection manager; they do different jobs.
The pieces
- Control plane. Stores the project's configuration in MongoDB (providers' credentials sealed), validates every change with the same rules the edge uses, and generates the Envoy resources for each Envoy version of the project.
- Agent courier. Each change queues an
AI_GATEWAY_DEPLOYjob. The agent (elchi-client) on every connected edge that runs the AI gateway receives the file set (00-providers.yaml,00-consumers.yaml,gw-<name>.yaml), has the gateway validate it, writes it, and confirms the exact configuration version the gateway reports. See Operations. - Edge sidecar. Hot-reloads
conf.d, renders the engine's config bundle, runs the extproc, serves the authorization socket, and keeps the last accepted configuration when a new one is refused. - Envoy. The AI listener's HTTP connection manager carries the AI filters; each provider is an
elchi-aigw-<provider>cluster. - ClickHouse. Usage, the request log, authorization decisions, provider answers and MCP calls go there; the control plane reads them for the Usage, Request log and MCP calls tabs and for quotas shared across edges.
One request through the filter chain
An AI listener's HTTP connection manager runs six AI filters before the router, in this order. Each provider cluster has its own upstream filter chain.
- A
Hostno gateway of the listener claims goes to the listener's default gateway; without a default it gets404with codegateway_not_found. - A model the gateway does not list gets
404with codemodel_not_foundand reaches no provider.GET /v1/modelson the gateway's host lists the models it serves. - Envoy answers
/v1/modelsand/anthropic/v1/modelsitself from the gateway's model list. - The engine's answer streams back through the same filters; the sidecar records the request log row from the engine's trace span and the serving provider from Envoy's access log.
Details of each refusal and its code: Error codes.
Features
| Feature | What it gives you | Page |
|---|---|---|
| Providers | Ten provider types, credentials sealed in the control plane, custom endpoints, a client's own key, request body changes | Providers |
| Gateways and models | Host-selected gateways, the models each serves, several providers per model with weights, priority levels and failover | Gateways and models |
| AI listeners | HTTPS and/or plain HTTP on one listener, 308 redirect to HTTPS, gateways bound per listener, a default gateway | Listeners |
| Consumers and keys | Virtual keys (sk-elchi-…), allowlists of gateways, providers and models, disable without deleting | Consumers and keys |
| Quotas, limits and costs | Token, request and cost quotas per consumer, CEL token limits, model prices | Quotas, limits and costs |
| Calling the gateway | Endpoints, auth headers, OpenAI and Anthropic SDKs, coding agents | Calling the gateway |
| Sensitive data | Flag or block personal data and secrets in prompts and MCP traffic | Sensitive data |
| Request log | One row per request; optional content capture, masked and encrypted on the edge | Request log |
| Usage and costs | Tokens, cost and provider health per gateway, provider, model and consumer | Usage and costs |
| MCP | Agents reach MCP servers' tools through the gateway with per-consumer grants, quotas and a call log | MCP overview |
| Operations | Deploys, Sync, per-edge status, last-good, console commands | Operations |
| Security model | Where secrets live, what each socket and port accepts | Security model |
Supported provider types
| Type | Typical use |
|---|---|
openai | OpenAI, and any OpenAI-compatible service or local server (set its host under Endpoint) |
anthropic | The native Anthropic Messages API, for Anthropic SDK clients (/anthropic/v1/messages) |
azure-openai | Azure OpenAI, with an API key or Microsoft Entra ID |
aws-bedrock, aws-anthropic, aws-openai | Amazon Bedrock models, Claude on Bedrock, AWS's OpenAI-compatible endpoint |
gcp-vertexai, gcp-anthropic | Google Vertex AI models, Claude on Vertex AI |
cohere | Cohere rerank (/cohere/v2/rerank) |
typesafe | TypeSafe SystemOne (/typesafe/v1/systemone) |
Which client API reaches which provider type is fixed by the engine. The common trap: /v1/chat/completions does not reach a native anthropic provider (422 unsupported API schema); OpenAI-format clients reach Claude through aws-anthropic or gcp-anthropic. The full matrix is on Providers and Calling the gateway.
What it needs
- Elchi Core with
ELCHI_JWT_SECRETset on the controller. With it empty every AI gateway API call answers503 AI gateway is disabled: ELCHI_JWT_SECRET is empty. - An Owner or Admin of the project to change the configuration. Members can read gateways, providers (credentials masked) and usage; only Owners and Admins see the Request log and MCP calls tabs and the per-edge status.
- An edge with the sidecar. A Linux amd64 edge (client) VM with
elchi-clientregistered to the project andelchi-ai-gatewayinstalled next to it. On Elchi OS 0.8.0 and later it ships in the image. See Installation. - ClickHouse for usage and the request log. The edge writes usage, the request log, authorization decisions, provider answers and MCP calls to the ClickHouse its
config.yamlnames. Without one the gateway still serves traffic, but the control plane shows no usage, cost or request log for that edge, and a consumer's quotas count only what that edge saw since it started.
Where to go next
- Getting started: a provider, a gateway, a key and a listener, and the first request.
- Installation: the sidecar on Elchi OS and on a plain Linux edge.
- Operations: how a change reaches the edges and how to check it did.