Scrivio Interview library
LeadershipAdvanced7 min read · updated 12 November 2026

Ten teams in your company want to call LLM providers directly from their Java services with their own API keys. As the architect, what would you put in place before this spreads further?

Before it spreads further, I would put a central LLM gateway, or at least an approved client configuration, between the teams and the providers so that provider keys are held in one place, quotas are enforced and usage is logged per team. Alongside it I would publish data handling rules on which data classes may go to which providers under which contractual terms, a shared Spring Boot starter with standard timeouts, retries, observability and redaction, an approved model list with a review for new providers, and cost reporting per team and feature.

Why this question is asked

When ten teams each sign up for a provider with a company card and paste a key into their configuration, nobody can answer basic questions: how much are we spending, which customer data has gone to which vendor, and what happens when a key leaks. Interviewers ask architects this question because the right answer is neither to ban the tools nor to let them sprawl, but to make the safe path the easiest one. In this answer, we will look at the risks of the current state, design the gateway, write down the data rules, build the shared starter, set up model approval and cost reporting, and plan how to roll it out without stopping the teams.

1What Goes Wrong When Every Team Goes Direct

Let us picture the current state. Ten services, ten API keys stored in different places, some in environment files and at least one in a git history. Each team has its own retry logic, some with none, so when the provider has an incident, some services hammer it and all share the same organisation-wide rate limit. Nobody knows whether customer support tickets with names and addresses are being sent to a provider whose terms allow training on the data. The monthly invoice arrives as one number with no breakdown.

Each of these is manageable alone. Together they mean that the company cannot answer a regulator, an auditor or the finance team, and that one team's runaway batch job can stop every other team's feature. The goal is to restore control without slowing the teams down, because a slow, bureaucratic process simply pushes them back to their own keys.

2A Central Gateway for Keys, Quotas and Usage

The core of the design is a gateway: an internal service that exposes the providers' APIs, or a common subset, to internal callers. Services authenticate to it with their normal workload identity, such as a service account token, and never see a provider key. The gateway holds the keys in a secret store, adds them to outgoing requests, and records for every call the team, service, feature, model, input and output tokens, latency and status.

Because every call passes through one place, the gateway can enforce quotas per team, for example 200,000 tokens a minute for the support team, so one team's spike cannot exhaust the shared provider limit. It can route a model name to one of several provider accounts or regions, and it can switch providers during an outage. We can build it ourselves, as a Spring Cloud Gateway application, or adopt an existing LLM gateway product; either way it must be run as critical infrastructure with its own SLO, because every AI feature now depends on it.

If a full gateway is too much at first, an approved client configuration is the lighter version: keys issued per team from a central secret store, the shared starter below, and provider-side usage reports. It is weaker on quotas but much better than the current state.

Step throughControlled access to LLM providers
  1. Team servicesuse the shared Spring Boot starter
  2. Shared startertimeouts, retries, observations, redaction, gateway URL
  3. LLM gatewayworkload identity, quotas per team, usage log
  4. Policyapproved models, data classes allowed per provider
  5. Provider accountskeys in a secret store, contracts on retention and training

5 layers, from the top down. Step through them one at a time.

Teams never hold provider keys; every call is attributed and counted.

3Data Handling Rules

The most important rule is about data, not technology. We classify data, for example public, internal, confidential and restricted, and we decide which classes may go to which providers. Restricted data such as health or payment information might be allowed only on a model hosted inside our own cloud account, and confidential customer data only with providers whose contract says they do not train on our data and delete it within a set number of days. Legal and security own these decisions with us.

The gateway helps enforce the rules: each route can be tagged with the highest data class it accepts, and services declare the class of the feature when they register. The gateway can also run a redaction step for obvious identifiers. But redaction is never complete, so the rule and the review of each feature remain the real control.

4A Shared Spring Boot Starter

Developers adopt what is easiest. So we give them a company starter that does the right thing by default: it points Spring AI or LangChain4j at the gateway, configures timeouts and a single layer of retries for 429 and 5xx, registers Micrometer observations with team and feature tags, redacts prompts in logs and turns off HTTP header logging.

XML
<dependency>
<groupId>com.acme.platform</groupId>
<artifactId>acme-ai-starter</artifactId>
</dependency>
# application.yml in a team's service
acme:
ai:
team: support
feature: ticket-summary
data-class: confidential # the gateway rejects routes that do not allow it
model: standard-chat # an alias from the approved list, not a vendor name

Notice the model alias. Teams ask for standard-chat or small-fast, and the platform maps aliases to concrete models. When a model is retired or a better one is approved, we change the mapping after evaluation, and ten teams do not have to redeploy.

5Approved Models and Cost Reporting

An approved model list says which models may be used, for which data classes, and through which provider account. Adding a provider goes through a short review: security and legal check the contract and data handling, and the platform team checks the integration. The review should take days, not months, with a clear form and an owner, or teams will route around it.

Cost reporting comes almost for free from the gateway's usage log. Tokens per call multiplied by each model's price give a cost per team and per feature, published on a dashboard and sent monthly to each team lead. Seeing that the ticket summary feature costs 9,000 dollars a month, and that 70 percent of it is unnecessary context, changes behaviour faster than any policy.

6Rolling It Out Without Stopping Teams

I would sequence it so that teams see benefits early. First, an inventory: a short survey and the finance records to find every existing key and use. Second, publish the data rules immediately, because they reduce risk even before any tooling. Third, ship the gateway and starter with one or two friendly teams and fix their friction. Fourth, migrate the remaining teams with a deadline, after which the old direct keys are revoked, since a key that still works will keep being used. Throughout, explain the why: central keys mean teams no longer handle rotation, quotas protect them from each other, and the starter removes code they would otherwise maintain.

Step throughSequencing the programme
  1. Inventory existing keys and usessurvey plus finance records
  2. Publish data classification rulesrisk drops before any tooling
  3. Gateway and starter with two pilot teamsfix friction first
  4. Migrate remaining teamswith a clear deadline
  5. Revoke direct keysthe old path stops working
  6. Monthly cost and usage reportsper team and feature

6 steps in order. Play them, or step through them one at a time.

7Follow-up questions

Does the gateway become a bottleneck or a single point of failure?

It can, so we run it like any critical service: several instances in each region, stateless apart from quota counters in Redis, with its own SLO and on-call. It adds a few milliseconds to calls that take seconds, so latency is rarely the problem; availability is, and it is solved with redundancy.

What if a team needs a model that is not on the list?

They submit a short request with the use case and data class, the review has an owner and a target of about a week, and experiments with non-sensitive data can run in a sandbox account in the meantime. A fast, predictable exception path is what keeps people inside the system.

Should we force every team onto one framework, such as Spring AI?

Not necessarily. The control points are the gateway, the data rules and the observability conventions. A starter for the most common framework makes the easy path easy, but a team using LangChain4j can still point it at the gateway and follow the same rules.

8Conclusion

In this answer, we saw how ten teams with their own keys create risks in security, data protection, shared rate limits and cost visibility. We put a gateway in front of the providers to hold keys, enforce per-team quotas and log every call, wrote data classification rules with legal and security, gave teams a shared starter with safe defaults and model aliases, set up an approved model list with a quick review, reported cost per team and feature, and rolled it out with pilots, a migration deadline and key revocation.

What to say in the interviewAbout 80 seconds aloud

Open with

I would aim to make the safe path the easiest one rather than ban anything. The centre of it is an internal LLM gateway: services call it with their normal workload identity, the gateway holds the provider keys in a secret store, enforces quotas per team so one batch job cannot use up the company's rate limit, and logs every call with team, feature, model and tokens.

Then, if they want more

If that is too much at first, central key issuing plus a standard client configuration is the minimum. Next, data rules written with legal and security: which data classes may go to which providers, and only under contracts that rule out training on our data and limit retention.

Then a shared Spring Boot starter that points Spring AI at the gateway and sets timeouts, a single retry layer, Micrometer observations and log redaction, with model aliases so we can change models centrally. We keep an approved model list with a review for new providers that takes days, not months.

Cost per team and feature comes straight from the gateway's usage log. For the rollout, I would inventory existing keys, publish the data rules at once, pilot with two teams, migrate the rest with a deadline, and then revoke the direct keys.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring AI reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Ten teams in your company want to call LLM providers directly from their Java services...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/1d3e17b0ee/