All articles

Who Asked the Model? Why I Put a Gateway in Front of AI Apps

One door for every model call, and what it gives you that the app cannot.

Diagram with three zones left to right: two team apps, a gateway that checks the key, applies budgets and keeps one audit trail, and two models behind it.
Look at the middle zone: identity, budget and logging live in the gateway, so apps and models can change without touching them.

Lately I have been thinking about how a team shares one local model between a few apps. Usually each app gets its own key, keeps its own logs and picks its own model. So, here is the question that bothered me. If one of those keys leaked tomorrow, how would you know who used it, and for what?

The apps cannot answer that well. Each app writes its own log, so it tells you only what it chooses to tell you.

Simply put, an AI gateway is one door that every model call must walk through. Apps no longer talk to the model directly. They talk to the gateway, and the gateway talks to the model.

Why not just log inside the app?

Think of a building with ten side doors and no reception desk. Each door has its own lock and its own notebook. When something goes missing, you have ten notebooks to read, and the person who owns each notebook is also the person you are checking.

That is the problem with in-app logging. The app controls its own logs, so it cannot prove who asked what. A gateway is the reception desk. It is the only place that sees every application, can tie each call to a person or a team, and keeps a record that does not depend on the app. It can also switch off one key for everybody at once.

OWASP lists "Excessive Agency" as a risk for LLM apps, and its advice is that controls should be enforced independently of the model. A check at the gateway or the tool layer does that. I read it in the OWASP Top 10 for LLMs 2025 notes from HackerOne. That is a secondary source, so please read the original OWASP list too.

What does a gateway actually give you?

Let me use LiteLLM as one example. I am reading this from its documentation, not from my own tests. As of November 2026, its proxy supports virtual keys with a model allow-list, rate limits and spend budgets, per-key and per-team spend tracking, and fallbacks to another model. There is also a guardrail framework, including PII masking with Presidio. The LiteLLM enterprise page and its GitHub repository are the places to check, because the split between free and paid features can change. Virtual keys need a PostgreSQL database. Organisations and teams are listed as an enterprise feature, so check that before you plan around them.

Here is a made-up example, not a real setup. Two teams share one local model. Team A gets a key that can call only the small model, with a low daily budget. Team B gets a key for both models and a higher budget. When Team A's key leaks, you turn off that one key. Team B keeps working, and the log shows which calls came from the leaked key.

The same door also helps when models change. New models arrive often, and a model on your shortlist this month may not be there next month. If every app calls the gateway by a name you control, switching models is a change in one config file, not in ten apps. I wrote about choosing between new local models in "Would I Run Inkling, Bonsai or Ornith Locally?".

Where does WSO2 API Manager fit?

I work with WSO2 API Manager, so this idea did not feel new to me. An API gateway already does identity, throttling and analytics for ordinary APIs. Model calls are one more kind of API call.

WSO2 has been adding AI features to it. According to the November 2025 release blog, version 4.6 added an LLM proxy with Bedrock, Azure AI Foundry, Gemini and Anthropic integrations, guardrails, and an MCP gateway. The APIM 4.7 release notes add MCP governance rulesets, MCP-aware analytics and model routing.

In my case, I have a Docker Compose lab for APIM 4.7.0 on my Mac, with PostgreSQL and Traefik in front. My test script already creates an API, publishes it and calls it. I have not yet run the AI or MCP parts, so I will not claim any results here. That is the test I plan to run next, and I will fill in this table when I have real results.

Test What I will look at Result
Two keys, two budgets, one local model Does the low-budget key get rejected? lab result needed
Revoke one key Does the other key keep working? lab result needed
Swap the model behind one name Do the apps need any change? lab result needed

There is a note to take here. A gateway does not fix bad data or bad retrieval. If the answer is wrong because the documents are wrong, the gateway will log the wrong answer faithfully. It tells you who asked, not whether the model was right.

What can you try this week?

Pick one small app that calls a model today. Put a gateway in front of it, even a laptop one, and give the app a key that is not the real provider key. Then set a small budget on that key and send requests until it is refused.

If you already run an API gateway at work, check whether your model calls go through it. Some teams find they do not.

If you are choosing a WSO2 release for this, the support dates matter. I covered how I read them in "Your WSO2 Version Has an End Date. How I Read the Support Table".

Next, I will look at what happens once the model can call tools, in "Which Tools Should Your AI Assistant Not Call Without a Person?"