D-14 API Gateway
Brick D: Tools, skills, plugins, MCP, connectors. French version: D-14-api-gateway
1. Role and responsibilities
North-south entry point: TLS, authentication, rate limiting, routing to the Control Plane and gateways.
- TLS and mTLS termination
- Keycloak JWT / API key validation
- Rate limit per tenant and key
- traceparent and X-Request-Id propagation
2. Position in the architecture and interactions
- Callers: All external clients.
- Execution path: Synchronous.
- Every interaction goes through the Control Plane API v1 (
/v1) behind the API Gateway (D-14).
3. Open source component and developed part
- Open source: Apache APISIX / Envoy
- Developed: Declarative configuration and auth plugins.
- External integration through an adapter
eai/integrations/<system>.pywith an in-process fallback when the URL is not configured.
4. Data model
Tables (schema eai, tenant_id RLS):
eai.api_keys(lecture)
Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.
5. Contract
- Applied contract: no manifest; API v1 cross-cutting rules
- Key fields:
Authorization, X-API-Key, X-Project, X-Environment, Idempotency-Key - Validation:
POST /v1/contracts/{name}/validate; manifest apply:POST /v1/manifests/apply.
6. API endpoints
GET /healthzGET /readyzGET /v1/meta
Request GET /v1/meta:
{}
Response:
{
"version": "1.0.0",
"features": [
"agents",
"tools",
"rag"
],
"locales": [
"en",
"fr"
]
}
7. SDK examples
Python:
from enterprise_ai import EnterpriseAI
client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
meta = client.system.meta()
TypeScript:
import { EnterpriseAI } from "@enterprise-ai/sdk";
const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
const meta = await client.meta.get();
Java:
EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
JsonNode meta = client.meta().get();
Go:
c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
meta, _ := c.Meta(ctx)
8. Configuration
- Environment variables:
EAI_DATABASE_URL - Helm values keys:
global.namespaces
9. Security controls
- WAF and size limits
- Tenant resolved from the credential, never from the body
- Every request carries the tenant resolved from the credential; PostgreSQL RLS
- Every mutation and policy decision writes a hash-chained audit event
10. Observability
- Prometheus metrics:
apisix_http_status,envoy_http_downstream_rq_total - Traces: OpenTelemetry spans with GenAI semantic conventions (
gen_ai.operation.name,gen_ai.agent.id,gen_ai.tool.name), attributeseai.tenant_id,eai.run_id,traceparentpropagation. - Audit actions: no dedicated action; APISIX rejections (authentication, rate limit) are logged by APISIX and accepted calls produce the actions of the called domain, for example
model.invoke.
11. FinOps units
- API requests.
- Emitted as Usage Event (
POST /v1/finops/usage) with tenant, project, agent and run.
12. Failure modes and resilience
- Active health checks; retry on 503 for GET only
- Normalized errors (error envelope, message_i18n en/fr)
13. Standalone adoption (client of a client)
- Can front any brick; Helm apiGateway.enabled.
- SDK:
enterprise_ai.tools / mcp / skills / plugins / connectors / channels - Minimal deployment: Helm chart with
controlPlane.enabled=trueand PostgreSQL; disabled external components use their in-process fallback.
14. Acceptance tests
- Without credential -> 401
- Rate limit exceeded -> 429
- Cross-tenant access refused
- Error returned in fr with Accept-Language: fr
Kit L3 proof
Offline validation: tests/test_apisix_config_schema.py checks deploy/apisix/apisix.yaml against the APISIX 3.x object and plugin schemas (limit-count, ip-restriction, request-id, openid-connect, limit-req) and the ingress policy (authentication, rate limit, request id on every /v1 route, IP restriction on health routes). Starting the APISIX runtime needs root or Docker, unavailable on the test host. Egress: tests/test_security_egress.py, tests/test_security_egress_wiring.py.