Lesson 28.7 · 7 of 7 · 8 min read · Reviewed 24 Nov 2026
Build, buy or self-host: total cost of ownership
By the end, you can
- Compare a hosted model API, a managed agent platform and self-hosted open weights on total cost of ownership.
- Make a build, buy or self-host recommendation that names its assumptions.
Architects are paid to make this call, and it’s rarely about which model is smartest. It is about who runs what, and what that costs over a few years.
Three options
| Hosted model API, build the rest | Managed agent platform | Self-hosted open weights | |
|---|---|---|---|
| Examples | A provider’s API behind your own orchestrator and gateway (72.7) | Amazon Bedrock AgentCore, Vertex AI Agent Engine, Microsoft Foundry Agent Service | vLLM or similar on your own or rented GPUs (30.3) |
| You run | Orchestration, tools, evals, gateway | Your agent code and tools; the platform runs sessions, memory, identity, scaling and tracing | Everything, down to the GPUs |
| Strengths | Best models, fast start, full control of the design | Less plumbing, built-in security and observability, fits your cloud | Data never leaves you, fixed costs, full customisation |
| Watch for | Rate limits, provider changes (72.4) | Lock-in to the platform’s runtime, features that differ by region | Ops burden, keeping up with new models, GPU supply |
These mix. Many teams use a hosted API for the main model, a managed platform for runtime pieces, and a small self-hosted model for one high-volume route.
Total cost of ownership
Price per tokenToken: The unit a model reads and writes: a word, part of a word, a space or a symbol, mapped to an integer id. is the easy line. The rest is where the comparison is won or lost:
| Cost | Hosted API | Managed platform | Self-hosted |
|---|---|---|---|
| Model usage | Per token | Per token plus platform fees | GPUs, paid whether busy or idle |
| Engineering to build | Medium | Lower | Highest |
| Operations and on-call | Your app only | Your app only | Your app and the serving stack |
| Model upgrades | Change a model id and run evals | Same | Download, test, re-tune, redeploy |
| Evals and safety work | Same everywhere | Same everywhere | Same, plus your own safety testing of the model |
| Compliance evidence | Provider’s reports plus yours | Same | All yours |
| Exit cost | Low if you kept a thin wrapper | Higher: platform-specific APIs | Low for models, high for the infrastructure |
A worked comparison
Illustrative numbers in credits per month, for one steady high-volume classification route:
hosted API self-hosted
model usage 100 40 (GPUs at good use)
engineering (amortised) 10 35
operations and on-call 5 30
total 115 105
At this volume, self-hosting is slightly cheaper. Halve the traffic and the hosted bill halves, while most of the self-hosted lines stay put: the answer flips. That’s the usual pattern. Self-hosting rewards high, steady utilisation, and punishes spiky or uncertain demand.
When the decision isn’t about cost
- Data can’t leave your network, or a region with no suitable hosted offering (70.4): self-host or use a cloud platform’s regional endpoints.
- Offline or on-device use: small local models (30).
- LatencyLatency: The time from sending a request until you get the response, or until the first token arrives when streaming. below what a network round trip allows.
- You need the best available model for a hard task: hosted APIs usually lead.
Build, buy or extend
- Build what differentiates your product: the workflowWorkflow: A system where LLM calls and tools follow a path defined in code, rather than chosen by the model., tools, data, evalsEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. and UX.
- Buy what is common: model hosting, tracing back ends, vector storesVector database: A database built to store embeddings and find the nearest ones to a query quickly., identity.
- Extend a platform when it covers most of the need, and keep your own thin layer for model calls and tools (MCPModel Context Protocol (MCP): An open protocol that standardises how AI applications connect to tools, data and prompts through servers., 35) so you can switch later.
Write the recommendation down
A one-page decision record: the options, the assumptions (volume, growth, data rules, team size), the TCOTotal cost of ownership: All the costs of a solution over its life: build, usage, evals, operations, support and upgrades. table, the risks, and what would make you change your mind, such as volume passing a threshold or a model leaving a region. Revisit it when an assumption changes.
Key points
- There are three broad options: call a hosted model API and build the rest, use a managed agent platform from a cloud provider, or self-host open-weight models.
- Total cost of ownership counts people, operations, evals and risk, not just price per token.
- Self-hosting usually pays off only at high, steady volume, or when data, latency or offline needs leave no choice.
- Build what differentiates you, buy what is common, and keep a thin layer of your own so you can switch.
Write a build, buy or self-host decision record
Compare a hosted API, a managed agent platform and self-hosting for one workload, with total cost of ownership and the assumptions behind it.
You will have: A one-page decision record with options, assumptions, a TCO table, risks, a recommendation, and the conditions that would change it.
Steps
- Pick one workload and write its assumptions: monthly volume and growth, latency need, data rules and team size.
- Fill in a TCO table for the three options, counting model usage, engineering, operations, upgrades, evals and exit cost.
- Recompute the totals at half and at double the expected volume.
- Note any requirement that decides the matter regardless of cost, such as data residency or offline use.
- Write the recommendation and the specific thresholds that would make you revisit it.
Done when
- The TCO table includes people and operations, not only price per token.
- The recommendation still holds, or the record says where it flips, at half and double volume.
- The record names at least one condition that would change the decision.
Finished the chapter? Take the chapter check.