Skip to content

Route /v1/models to ai-gateway-discovery for per-key filtering - #799

Closed
johnl-amd wants to merge 2 commits into
bump_version_envoy_and_ai_gatewayfrom
ai-gateway-per-key-models
Closed

Route /v1/models to ai-gateway-discovery for per-key filtering#799
johnl-amd wants to merge 2 commits into
bump_version_envoy_and_ai_gatewayfrom
ai-gateway-per-key-models

Conversation

@johnl-amd

Copy link
Copy Markdown
Contributor

Summary

  • Adds an exact-path GET /v1/models HTTPRoute on the ai-gateway Gateway that routes the OpenAI model-list call to ai-gateway-discovery's new per-key models handler (Service :8082), plus the cross-namespace ReferenceGrant for that backendRef.
  • A more-specific HTTPRoute overrides Envoy AI Gateway's built-in /v1/models aggregator, so the caller gets a list scoped to the models their key can use instead of the whole fleet.

Why: the built-in /v1/models returns every declared model to any valid key. The companion ai-gateway-discovery change serves a per-key list; this routes the endpoint to it.

Non-obvious decisions:

  • The call stays authenticated by the existing gateway-scoped ai-gateway-default-deny SecurityPolicy + body-aware ext_authz (which target the whole ai-gateway Gateway) — no new auth wiring needed; the handler always sees a valid key.
  • Both manifests render only under aiGateway.enabled + routeHostname, so they ship and retract atomically with the rest of the AI gateway.
  • Port 8082 is hardcoded (like the ext_authz 8083 in the default-deny SP) and must match the discovery chart's controller.modelsPort.

Base branch

Targets `bump_version_envoy_and_ai_gateway` — the AI-gateway templates (`ai-gateway` Gateway, default-deny SP) live on that line, not main.

Risk

Low. Gated behind `aiGateway.enabled`; no change to existing routes/policies.

Test plan

  • `helm template` renders both manifests as valid YAML when enabled + routeHostname set, and renders nothing when gated off.
  • Deferred to a live cluster: confirm the exact-path `/v1/models` HTTPRoute (backendRef) actually overrides the extproc's built-in ImmediateResponse and proxies to the discovery Service; then the live auth matrix.

Dependencies

  • Requires the companion core PR (silogen/core#4322) that adds the `/v1/models` handler + `modelsPort` to the discovery chart. Deploy together.
  • Related: EAI-226, EAI-6835.

Envoy AI Gateway's built-in /v1/models returns every model to any valid
key. Add an exact-path GET /v1/models HTTPRoute on the ai-gateway that
routes the call to ai-gateway-discovery's models handler, which returns
only the models the caller's key can use. A more-specific HTTPRoute
overrides the gateway's built-in handling; the call stays authenticated
by the existing gateway-scoped default-deny + ext_authz. Includes the
cross-namespace ReferenceGrant for the discovery Service backendRef.

Both render only under aiGateway.enabled + routeHostname, so they ship
and retract atomically with the rest of the AI gateway.
The gateway-scoped ai-gateway-default-deny applies both extAuth and an
authorization RBAC deny to every route on the ai-gateway. The static
/v1/models HTTPRoute has no per-model SecurityPolicy to override it, so a
valid key passed extAuth but was then refused by the RBAC deny (HTTP 403,
verified on app-dev). This route-scoped policy overrides the gateway one
for /v1/models: it keeps extAuth (missing/invalid key still 401'd, valid
key forwarded with x-api-key-id) but carries no authorization block, so
the request reaches the models handler. Verified end-to-end on app-dev:
a key bound to one of two deployed models now gets a 200 filtered to that
model.
@johnl-amd johnl-amd closed this Aug 5, 2026
@johnl-amd
johnl-amd deleted the ai-gateway-per-key-models branch August 5, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant