This article is an automated translation of the Spanish original. Read the original
At one of our clients, the finance department answers by hand the questions about the income statement that no report covers, using Excel workbooks connected to the semantic model, tables and the odd external source. What repeats already has its report; the hard part is what's new. The question nobody had foreseen, the simulation of a scenario, the year-end forecast. On top of that, they are in the middle of a change, discovering and adapting metrics, reporting and KPIs.
To speed up this work we built an AI assistant in a month. It is a prototype that a small group in the finance department is trying out. This is a case of AI governance, not just a client that has been plugged into the analytics database. Usage policies say who can use what, with which data and with which budget. In this prototype, those rules live in the architecture.
The architecture
The person asks in a chat. The chat talks to an AI gateway, the single door to the models and tools. The gateway checks which application is calling, which user, with which model and with how much budget, and logs every call. To reach the data, the model currently has a closed set of read-only tools, served over MCP, on top of the official semantic model of the income statement.
There are five main components:
A chat with corporate single sign-on (SSO): only authorised people can get in, and their identifier travels with every request to the gateway.
An AI gateway, the door every request to the models goes through. In this prototype it is open source and runs in containers in the client's cloud.
An MCP server (Model Context Protocol, the open standard for connecting AI models with tools and data). It exposes the allowed queries on the semantic model and on public indicators.
Three AI models, split by task.
A dashboard that reads the gateway's log and the trace of every answer.
A single control gate
The gateway sits between the chat, the data and the AI models. Each application or agent calls the gateway with a virtual key, a pass that carries its identity, its budget and the models it may use. Within that key, each user has their own budget.
Compared with connecting each application straight to the provider, this pattern brings three controls that are critical for effective governance:
One point of control. If an application misbehaves, its key is revoked without touching the others.
A complete log. Every call is stored with person/agent, model, usage, cost and time.
Switching models without touching the applications. Applications ask for a generic model and the gateway decides which actual model sits behind it.
The gateway itself can be replaced too, because the applications don't depend on it. People's identity comes from the corporate directory, not from the gateway. And the applications' code uses the model provider's official library, where only the address changes so that it points to the gateway: changing gateways would mean changing that address. What does depend on it today is the log of traces and activity, and with it the dashboard.
There are market platforms that include AI gateways (IBM, Microsoft, CData), with different capabilities. We decided to start with an unsupported open-source gateway to test at a lower cost and with more agility.
The free version has known limits that don't allow the finest-grained control. We'll go step by step: when we reach that limit, we'll evaluate the Enterprise version.
Three models, each with its own job
Every question first goes through a small model, which classifies it as an income statement query, as an analysis (simulation or forecast) or as out of scope. Queries are answered by a medium model, and simulations and forecasts by a large model.
Applications call a generic model defined in the gateway, not a specific model. Depending on how the small model classifies the question, the request goes to one or the other, and the gateway decides which actual model sits behind each one. So, to add a model or move to a new version, it is enough to change a gateway setting and run the test bank. The application stays the same.
What the model can touch
The model doesn't write queries and holds no credentials. It picks a tool and passes it parameters. The server builds the query from templates and checks each value against a catalogue before running it. Everything is read-only and the assistant writes to no system.
The model does receive the results of those queries, which are official figures and travel to the model provider. Which data may leave the company, how personal data is masked and where it is processed are decisions for the security officer that can be set according to criticality, but it is possible to mask data or limit which figures reach the model.
The chat doesn't use the provider's conversation storage either. The history lives in a database of our own.
Every answer leaves a trace with the question, the tools called with their arguments (including the generated query), the usage, the cost and the time. When the finance department doubts a figure, you can see where it came from and replay the whole journey to validate it end to end.
How the tools evolved during the trial
The first version had tools designed for the questions we expected. In the first demo they asked about a dimension we hadn't opened, and the assistant replied that it didn't have that data. The data was in the semantic model but the right tool was missing.
Something similar happened several times. We realised that opening dimensions one by one wasn't viable. So we changed the design to a catalogue generated from the semantic model itself, with a detail tool that filters and breaks down by any available dimension.
The assistant also tripped over names. Hundreds of items shared a name, and the assistant, which grouped by name, added up different items as if they were one. It now identifies cost centres and accounts by name and code.
Spending control
The budget is controlled from the gateway, at two levels.
Per application. The chat and the test bank have separate keys ever since one full run of the bank used up the chat's budget and left it unable to answer. So they had to be split.
Per person. About 9 euros every 30 days by default. Whoever exceeds it is left without service until the next period. The client prefers progressive warnings before the cut-off, and that's what comes next.
In model usage alone, each answer costs about 4 euro cents. The fixed cost of the infrastructure is expected to be higher at this stage, and we haven't measured it in the client's environment yet. Cost per answer says little on its own. What we want to measure is the cost per useful answer: the period's spend divided by the answers the user rates as useful or doesn't correct. With the rating buttons, the dashboard will be able to separate spend that brings knowledge from spend that only burns tokens, by person, by question type and by model.
Improving fast without breaking anything
The piece that has saved us the most time is the question bank. Each question carries its reference query, which is computed on the spot against the semantic model, so the bank stores no figures that go stale. A checker compares the assistant's figure with the reference one and allows a 0.5% difference, or whatever matches the rounding the assistant writes the figure with, up to 5%, so that rounding doesn't count as a failure. In the latest runs there wasn't a single wrong figure. We write the questions ourselves, plus the ones the finance department asked in the demos, and they measure whether the figure and the behaviour are correct. The quality perceived by the person using it is outside the tests. For that the chat has rating and correction buttons, designed for a continuous improvement cycle in which whatever is flagged goes back into the question bank and the instructions.
In October the bank reached 100% correct answers and stopped being so useful, because if everything passes it doesn't point to improvements. We made it more demanding, with follow-up questions within the same conversation, tools the assistant is required to use and real questions from the finance department. Even so, the bank doesn't catch everything, and it has to keep evolving with the finance department's help.
Two more lessons from this part:
Test the whole circuit. An update to the provider's library (SDK), which we hadn't pinned, changed the way tools are called, and those questions started to fail. The local tests didn't go through the whole circuit via the gateway. Now there is a test that does.
Users also correct the language and terms. The assistant expressed the comparison with the budget as a percentage of achievement, and the finance department works with variance. We changed it in the instructions.
Living alongside the office suite's AI (Microsoft Copilot)
There are two ways of using corporate AI. Personal productivity uses Copilot, with the governance the security officer already has in place. Corporate assistants on official data go through the gateway and, when they arrive, so will the agents that carry out tasks in automated processes, each with its own key, budget and log.
For the income statement we chose an assistant of our own for three reasons: it lets us choose the model, it lets us set rules, and it leaves every request traced. Vendors are already building part of this into their platforms, and the final decision will be made when it moves to production.
Expanding to other business areas
We started with the finance department because it has official data, demanding questions and little tolerance for error. The design is meant to extend to other areas, such as customer service, sales and so on, each with its own assistant, its own MCP tools on its own data and its own budget.
The gateway, the log, the dashboard and the testing method are reused. The data, the systems, the risks and the way of evaluating change. Customer service brings personal data and free-text answers, which can't be checked by comparing figures. Each department will have different tuning and validation methods, adapted to its goals.
Next steps
Row-level security per person, which is an extension of the current prototype.
Retention period for the technical log.
Which data may go to an external model, how personal data is masked and where it is processed.
AI governance is proven in the architecture. A new version of the model is switched with a setting. What has to be designed from day one is the door everything goes through, the tools that limit what the model can do, and a question bank that warns you when a new version gets worse.
