Quick revision
The short answer
I would decide per task, not once for the company: measure quality on our own evaluation sets, add up the full cost including the people and GPUs that self-hosting needs, and let data sensitivity rule out options where it must. In practice this usually leads to a mix, so the Java code stays provider-neutral behind Spring AI or LangChain4j and a routing layer, and we revisit the decision on a fixed cadence because prices and models change every few months.
What to remember
In this answer, we saw that the choice between hosted frontier models, self-hosted open-weight models or a mix is made per task. We compare quality on our own evaluation sets, count the full ongoing cost of GPUs, serving and people, and let data sensitivity rule out options first. Keeping Java code neutral with Spring AI or LangChain4j and a routing layer lets the mix change, and a regular review keeps the decision current as prices and models move.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would decide per task, not once for the company: measure quality on our own evaluation sets, add up the full cost including the people and GPUs that self-hosting needs, and let data sensitivity rule out options where it must. In practice this usually leads to a mix, so the Java code stays provider-neutral behind Spring AI or LangChain4j and a routing layer, and we revisit the decision on a fixed cadence because prices and models change every few months.
Why this question is asked
Choosing where models run is one of the few AI decisions that is expensive to reverse. Self-hosting means buying or reserving GPUs and building a team that can operate them; going all-in on one hosted vendor means our prompts, contracts and data terms depend on them. Interviewers ask senior leaders this question to see whether they can reason about quality, cost, risk and change together rather than picking a favourite. In this answer, we will recap the three options, then go through how to compare quality, how to count the real cost, how data rules shape the choice, why the code must stay neutral, and how often to revisit.
1A Quick Recap of the Three Options
Hosted frontier models are the largest commercial models, offered through a vendor's API. We pay per token, the vendor runs the hardware, and we get the best general quality available, but our data goes to the vendor (under contract) and the vendor decides when a model changes or is retired.
Open-weight models are models whose weights are published, so we can run them on our own GPUs or in our cloud account. We pay for hardware whether we use it or not, and we need people to run it, but the data never leaves our environment and the model only changes when we change it. A mix uses each where it fits, for example a self-hosted model for sensitive document classification and a hosted frontier model for complex customer answers.
| Concern | Hosted frontier | Self-hosted open-weight |
|---|---|---|
| Quality on hard tasks | usually highest | often close on narrow tasks |
| Cost shape | per token, scales with use | fixed GPUs plus a team |
| Operations | vendor runs it | serving, scaling, patching are ours |
| Model changes | vendor updates and retires | only when we upgrade |
| Data location | vendor, under contract | stays in our environment |
2Compare Quality on Our Own Evaluation Sets
Public benchmarks measure general skills on public questions. Our tasks are specific: classify insurance claims, answer questions about our product manuals, extract fields from our invoices. A model that ranks fifth on a leaderboard may tie the first one on our extraction task, and the reverse happens too. So for each task we build an evaluation set of a few hundred real examples with expected outputs or a grading rubric, and we run each candidate model on it.
The result is usually uneven. For example, on intent classification a self-hosted 8 billion parameter model scores 94 percent against 95 for the frontier model, while on multi-step policy questions it scores 71 against 88. That tells us exactly where the expensive model is earning its price.
3Count the Real Cost of Self-Hosting
Self-hosting looks cheap when we compare a GPU hour with a token price, but that comparison leaves out most of the cost. We need enough GPU capacity for peak traffic plus a failover, a model serving stack such as vLLM or a managed inference service, people with ML operations skills to tune batching, quantisation and autoscaling, and a routine for security patches to drivers, containers and the serving software. These are ongoing costs, not a one-time setup.
A rough worked example: two GPU nodes for redundancy at about 4,000 dollars a month each, plus half of two engineers' time at about 15,000 dollars, is about 23,000 dollars a month before any traffic. If the same workload costs 6,000 dollars a month on a hosted API, self-hosting only pays if volume grows several times or data rules require it. At very high steady volume the picture flips, which is why we model both at current and expected traffic.
4Data Sensitivity, Residency and Contracts
Some workloads are decided before cost is discussed. Health records, legal documents or data that must stay in a specific country may be ruled out for a general hosted API by regulation or by our customers' contracts. For those, the options are self-hosting or a private deployment offered by a cloud provider in the required region, with contract terms that forbid training on our data and set retention limits. We classify each AI task by the data it touches and let that classification remove options first.
- Does the data allow a hosted API?residency, regulation, customer contractsYesContinueNoSelf-host or private deployment
- Run the evaluation set on candidates
- Does a cheaper model meet the quality bar?YesUse the cheaper modelNoUse the frontier model
- Compare full monthly cost at expected volumeinclude GPUs and people
- Record the decision and the review date
5 steps in order. Play them, or step through them one at a time.
5Keep the Java Code Provider-Neutral
Whatever we choose today will change, so the application code must not care where the model runs. Spring AI gives us ChatClient on top of a ChatModel, and the same ChatClient code works whether the ChatModel talks to a hosted vendor or to a self-hosted server with an OpenAI-compatible API. LangChain4j offers the same separation with its ChatModel interface. On top of that, a small routing layer of our own picks the model per task from configuration.
But there is a catch: prompts are not neutral. A prompt tuned for one model often needs adjusting for another, so we keep prompts and evaluation sets per model and treat a model switch as a tested change.
6Plan for Change and Revisit on a Cadence
Hosted vendors release new versions and retire old ones, often with a few months' notice, so even if we never change vendor we will migrate prompts regularly. Open-weight models improve quickly too, and a model that was not good enough last year may pass our bar now. So we put the decision on a fixed cadence, every quarter or half year, and rerun the evaluation sets and the cost model each time. Because the code is neutral and the evaluations exist, each review is a few days of work instead of a project.
7Follow-up questions
When would you recommend going fully self-hosted?
When data rules forbid hosted APIs for most workloads, or when steady volume is so high that fixed GPU cost per token falls well below API prices, and only if we can staff the operations work. Without the team, self-hosting becomes the riskiest option.
How do you handle a vendor retiring a model?
Treat it as a scheduled migration: run the evaluation set on the replacement, adjust prompts, compare structured output and tool calling, and roll out gradually behind the routing layer. The cadence review should already have tested likely successors.
Is an OpenAI-compatible API enough for portability?
It helps for the request format, but behaviour, tool calling details, context limits and structured output support still differ. Portability comes from the abstraction plus per-model prompts and tests, not from the wire format alone.
8Conclusion
In this answer, we saw that the choice between hosted frontier models, self-hosted open-weight models or a mix is made per task. We compare quality on our own evaluation sets, count the full ongoing cost of GPUs, serving and people, and let data sensitivity rule out options first. Keeping Java code neutral with Spring AI or LangChain4j and a routing layer lets the mix change, and a regular review keeps the decision current as prices and models move.
Open with
I would not make one decision for the whole company. I would decide per task, using three inputs. First, quality on our own evaluation sets, because public benchmarks rarely match our tasks; often a small open-weight model is just as good for classification or extraction while the frontier model clearly wins on complex reasoning.
Then, if they want more
Second, full cost: self-hosting needs GPU capacity with redundancy, a serving stack, ML operations skills and ongoing security patching, so I compare that monthly total with API prices at our expected volume, not a GPU hour with a token price.
Third, data: if regulation, residency or customer contracts rule out a hosted API for a workload, that decides it, and the options become self-hosting or a private regional deployment. This usually ends in a mix.
So I keep the Java code provider-neutral, with Spring AI's ChatClient or LangChain4j on top and a small routing layer that picks the model per task from configuration, and I keep prompts and evaluations per model because prompts do not transfer for free.
Hosted vendors also retire models, so I plan for migrations, and I revisit the whole decision every quarter or half year because the market moves fast.
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 "As the senior technical leader, how would you decide between using hosted frontier...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/e67d0b420b/