Ideas · Builder Notes

Building an OpenAI-compatible AI gateway that decides before it forwards

Kognita alpha's AI gateway sits in front of a model provider, decides before any byte is forwarded, redacts on egress and refuses when the evidence store cannot record the call.

Before

Agents talk to model providers directly, and policy never sees the prompt. I wanted one explicit place where every model call is authorised and evidenced.

After

Agents point base_url at kognita serve with an upstream URL. There is no TLS interception and no certificate. Each request becomes an envelope with the model as the subject, missing attributes are filled by the classifier-derived envelope, and decide() runs before anything leaves.

On allow, the egress guard redacts, the gateway forwards, the spans are restored and the response is classified before it is returned. Evidence keeps hashes and byte counts, not prompt or response text.

Why it matters

Fail closed when the evidence store is down. If the call cannot be recorded, it does not happen. Anonymous agent paths and self-asserted agent identity are both denied.

The wire format is OpenAI-compatible only. I left other provider formats for later instead of half-supporting them.

Put governance where the traffic already flows. Most teams will accept a base URL change. Few will accept an SDK rewrite.

Sources

Kognita is an open-source alpha. This note comes from Kognita PR #12 in the Kognita repository.

All ideasEmail Ahmed