Skip to main content

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.

The AI Gateway page — gateways, providers, consumers and listeners of a project The AI Gateway page — gateways, providers, consumers and listeners of a project

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_proc filters 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​

  1. 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.
  2. Agent courier. Each change queues an AI_GATEWAY_DEPLOY job. 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.
  3. 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.
  4. Envoy. The AI listener's HTTP connection manager carries the AI filters; each provider is an elchi-aigw-<provider> cluster.
  5. 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 Host no gateway of the listener claims goes to the listener's default gateway; without a default it gets 404 with code gateway_not_found.
  • A model the gateway does not list gets 404 with code model_not_found and reaches no provider. GET /v1/models on the gateway's host lists the models it serves.
  • Envoy answers /v1/models and /anthropic/v1/models itself 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​

FeatureWhat it gives youPage
ProvidersTen provider types, credentials sealed in the control plane, custom endpoints, a client's own key, request body changesProviders
Gateways and modelsHost-selected gateways, the models each serves, several providers per model with weights, priority levels and failoverGateways and models
AI listenersHTTPS and/or plain HTTP on one listener, 308 redirect to HTTPS, gateways bound per listener, a default gatewayListeners
Consumers and keysVirtual keys (sk-elchi-…), allowlists of gateways, providers and models, disable without deletingConsumers and keys
Quotas, limits and costsToken, request and cost quotas per consumer, CEL token limits, model pricesQuotas, limits and costs
Calling the gatewayEndpoints, auth headers, OpenAI and Anthropic SDKs, coding agentsCalling the gateway
Sensitive dataFlag or block personal data and secrets in prompts and MCP trafficSensitive data
Request logOne row per request; optional content capture, masked and encrypted on the edgeRequest log
Usage and costsTokens, cost and provider health per gateway, provider, model and consumerUsage and costs
MCPAgents reach MCP servers' tools through the gateway with per-consumer grants, quotas and a call logMCP overview
OperationsDeploys, Sync, per-edge status, last-good, console commandsOperations
Security modelWhere secrets live, what each socket and port acceptsSecurity model

Supported provider types​

TypeTypical use
openaiOpenAI, and any OpenAI-compatible service or local server (set its host under Endpoint)
anthropicThe native Anthropic Messages API, for Anthropic SDK clients (/anthropic/v1/messages)
azure-openaiAzure OpenAI, with an API key or Microsoft Entra ID
aws-bedrock, aws-anthropic, aws-openaiAmazon Bedrock models, Claude on Bedrock, AWS's OpenAI-compatible endpoint
gcp-vertexai, gcp-anthropicGoogle Vertex AI models, Claude on Vertex AI
cohereCohere rerank (/cohere/v2/rerank)
typesafeTypeSafe 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_SECRET set on the controller. With it empty every AI gateway API call answers 503 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-client registered to the project and elchi-ai-gateway installed 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.yaml names. 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.