Execution (3): Adding AI Features to Your Product#

A chip floating above an open product box, a scale weighing coins against a cloud, and a warmly glowing cache drawer

If the previous chapter was about “building a product with agents,” this chapter is about “putting AI inside the product.” They are different problems. The former is about the tools I use; the latter is about the structure and cost of my product calling a model on behalf of its users. In a one-person startup, mixing the two breaks your cost structure, and separating them simplifies your design.


Separate the Two Kinds of AI Cost#

① What I spend to do my own workCoding agents · chat services · CoworkFlat monthly plan (5-hour · weekly limits)Much cheaper than API for heavy individual useOnly holds inside the provider's own productNot usable as a product backend (terms · blocked)② What my product spends for its usersMy server calls the model APIAPI pay-per-use (input · output · cache)Must be treated as cost of goods and priced inOptimize with caching · batching · tier routingPer-user budget caps and usage limits are a mustTrack the two in separate cost accounts and your margins become visible.
A subscription is "my right to work"; the API is "the product's cost of goods." Same model, different products.

As Services and Tools, Chapter 2 said, a coding agent’s monthly subscription is so much cheaper than consuming the same volume through the that it is tempting to think “what if I connect my subscription account to my service’s backend and use it cheaply?” I looked into the technically possible routes myself, but the conclusion was clear. An AI subscription is not a discounted API product. A subscription carries time-based limits grounded in compute rather than exact token counts, and its economics hold only inside the provider’s own product, where the provider can control the workload. Routes where an unapproved calls the model with subscription have been blocked, and pooling the limits of multiple accounts to use them like server capacity violates the terms of service. Even the official bridges built in 2026 (bundled with higher-tier subscriptions, and OpenAI’s Sign in with ChatGPT) do not let you redirect subscription limits to your own server; they either add a fixed amount of API credit or let users spend their own subscription. When your business’s cost structure depends on a provider looking the other way, that is not optimization; it is .

So the principle is simple. Use subscriptions for development and conversation that a person performs directly, and from day one treat API cost as cost of goods for everything the product calls on behalf of users. The rest of this chapter is about who you make pay that API cost, and how to design and reduce it.


AI Features Cost Money Every Time They Run: Design Billing from Day One#

A product with AI features has a different cost structure from traditional software. With traditional , one more user barely added to server cost. That is why “gather users for free first and monetize later” worked, and many services grew that way. AI features are different. Every time a user presses a button, a model is called, and every call costs tokens. Usage is cost of goods.

This structure creates two problems.

  • Free users cost money too. If you open the product for free, cost grows along with the number of users. It can become a structure where the better the response, the bigger the loss.
  • Heavy users create losses. People who pay the same price use very different amounts. With a single flat-rate plan, a small number of heavy users can use up what everyone else paid. Agent features repeat model calls several times within a single request, which widens this gap further.

So a product with AI features has to settle its business model before launch. There are four things to decide.

  1. Who pays the cost. Decide whether users pay directly, whether advertisers or business customers pay, or whether the user’s agent calls the model so that the user’s own subscription pays (see the “Distribution” section below).
  2. What unit you charge for. Options include a monthly subscription with a usage limit, prepaid credits, pay-as-you-go, and users connecting their own API keys. Whichever you pick, the key is to make the unit of price and the unit of cost move together.
  3. How far free use goes. Cap free trials by period or by count, and put lighter models on the free tier. Treating free use as “the cost of getting the product known” and giving it a separate budget makes the decisions easier.
  4. When to add payments. Payments look like a feature you can bolt on later, but they come with plans and limits, usage metering, refunds, and tax handling. If you attach a from the start and record usage per user, you also have evidence when you later change prices.

I think this is the biggest wall a one-person startup has to get over. Building has become something you can do alone with agents. But the cost of AI features goes out from the first user, while revenue comes in only after users have confirmed the value. Unlike a company that bridges that gap with investment, an individual has to bridge it with their own money. So it is not “build a good product and the money will follow”; the structure for getting paid has to be part of the product design. The cost-cutting techniques in the rest of this chapter widen the margin on top of that structure; they cannot replace it.


Architecture: Calls on the Server, Models as Parts#

The basic structure for putting AI in a product is the “user app ↔ my server ↔ model API” we saw in Services and Tools, Chapter 2. On top of it, there are three design principles a one-person startup should follow from the start.

First, API keys live only on the server. Calling the model directly from the client exposes the key, makes usage impossible to control, and reveals your prompts and logic as-is. Every call goes through the server, and the server handles usage limits, logging, cost aggregation, and caching. Even for features where the browser must connect to the model directly, such as real-time voice, the server issues a short-lived temporary token instead of handing over the real key.

Second, wrap model calls in a single layer. Models change every few months, and so do prices. If your is bound directly to a particular ’s response format, switching providers becomes expensive. Wrap the call sites thinly, and “which model is cheap and good this month” becomes a single setting. Details such as how works and the tool-call response format differ by provider, though, so the adapter has to absorb those differences. Instead of building this layer yourself, you can also use a service or library that wraps models from several providers in one format.

Third, decide a tier for each call site. Even within one product, classifying user queries, summarizing documents, and generating the final answer require different levels of intelligence. Use the top-tier model for every call and your costs multiply; use a for every call and quality collapses. Decide “the minimum tier this task needs” at each call site, and confirm the choice with the evals covered in the next chapter. When designing a single feature, I fill in the table below first.

Call siteWhat it doesTierCacheable prefixBudget cap
Intent classificationSort user input into a few typesLightweightSystem instructions + classification criteriaVery low
Document retrieval summarySummarize chunks found via Lightweight or balancedSystem instructionsLow
Answer generationFinal answer grounded in evidenceBalancedSystem instructions + fixed documentsMedium
Complex analysis · planningMulti-step reasoning and tool callsTop-tierSystem instructions + tool definitionsHigh, with a per-task cap

The Heart of Cost Design: Prompt Caching#

Key AI Concepts, Chapter 1 said that a token is both a unit of length and a unit of currency. Once you put AI in a product, you learn that most of that currency goes to input tokens, and in particular to the leading part that repeats on every request: system instructions, tool definitions, fixed documents. Agent features are worse, because they resend the entire history every turn. Prompt caching is a feature where the model provider stores that repetition and charges a much lower rate for it, and used properly it removes a large share of input cost.

The most important fact I learned from digging deep into caching is that caching works on . The request has to be byte-for-byte identical to a previous request from the start up to some point for that span to be reused. Change even one character in the middle and everything after it is recomputed. So caching optimization is not a question of “what to cache” but of “what to put in front,” and the answer is to stack the prompt in layers (strata) with different rates of change.

Anatomy of one request (front → back)① Tool definitionsPer deploy only · shared by all users② System instructions (build-time constant)Per deploy only · no timestamps or names③ Fixed reference documentsChanges per session④ Conversation history (append only)Per turn · never edit the middle⑤ This search result + this questionPer request · at the very endFront = stable. Put the cache boundary at the last point you are sure will be identical on the next request.
The cache is a prefix match. If something that changes often sits in front, everything behind it is recomputed every time.

Ranked by impact, the practical rules come out as follows.

  1. Treat system instructions as a build-time constant. The moment you put values like the current time, the user’s name, or a session ID into the system instructions, your becomes permanently zero. This one mistake was the most common thing separating 0% from 90%.
  2. Fix the tool list so it is shared by all users. Tool definitions sit at the very front, so if you split the list by permission there is no way to recover. Give everyone the full set, and check permissions in the . If you have so many tools that their definitions alone make the front of every request heavy, look into the tool search feature of the model API. You register every tool but show the model only a few frequently used ones from the start; the rest enter the context only after the model searches for them by name and description mid-task and picks them. The Anthropic and OpenAI APIs support it, and because the definitions loaded through search do not change the tool list at the very front, the cache does not break either.
  3. Make deterministic. The cache key is the rendered bytes. If JSON key order wobbles, the same content becomes a different prompt.
  4. Only append to conversation history. Editing or trimming the middle invalidates everything after that point.
  5. Put search results at the very end. If something that changes with every query sits in front, everything behind it is recomputed every time.

And there is one trap. The cache hit rate is not the goal. A hit rate is a ratio; cost is an absolute. Carry a long history around and the hit rate approaches 99%, but the cost per request keeps rising. The cache discount applies equally to both sides, so a context ten times larger is still ten times more expensive after the discount. Use the hit rate as a diagnostic that catches “is the prefix wobbling,” and judge the final cost by total context volume. Whether to summarize and compress a long conversation is decided not by the hit rate but by “compression cost versus the cumulative savings afterward.” Depending on the provider and model, cache reads can also count in full against , so a long history can eat throughput as well as cost.

In other words, raising the cache hit rate and shrinking the context itself through are two axes that deserve equal weight. Watch only the hit rate and you miss the context growing ever larger; rush only to compress and every compression changes the middle of the history, losing the cache behind it. The goal is not to maximize either one, but to tune both together and find the point where the total cost per request is lowest.

Beyond caching, there are two more. Work that does not need a real-time response (overnight aggregation, bulk classification) can go through the , which often cuts the rate roughly in half. And every call gets a budget cap. The server enforces per-user and per-task caps, and a task that hits its cap is treated as a signal that “something is going wrong” before it is treated as a cost problem.


Where to Run It: Public APIs and Managed Platforms#

Most one-person startups can start with a model provider’s public API. It is the easiest, and you get the latest models immediately. But once your customers are companies and they start asking “does our data leave the building,” you have to move toward the right side of the deployment spectrum we saw in Services and Tools, Chapter 2.

Knowing precisely what a (Amazon Bedrock, Google Cloud’s Gemini Enterprise Agent Platform (formerly Vertex AI), Microsoft Foundry, and so on) means helps with sales here. I too initially thought Bedrock was “a dedicated line to the model provider,” but in reality it is a structure where the cloud provider loads the model onto its own infrastructure and runs inference directly. That is why it can guarantee that inputs are not sent to the company that built the model, can be processed in a you choose (if you turn on the option to spread processing across regions, data moves only within the geography you set), and are not used for training. In Bedrock’s case, the weights of closed models are delivered encrypted and decrypted only inside a verified execution environment, and by design there is no path by which even the cloud provider’s operators can reach them. It is not a “trust us” policy but a structure where “the access path itself has been removed.” That said, conditions differ by model and deployment type even within the same platform. For example, Claude in Microsoft Foundry can be hosted either on Azure or on Anthropic’s infrastructure, and with the latter the data is processed outside Azure. Before you promise anything to a customer, check the data handling terms for the specific model you plan to use. When pitching security-sensitive customers, prepare a checklist: no training on data, region pinning, network isolation, access control, , and .

Managed platform base pricing is usually the same as or close to the model provider’s direct API. Endpoints that pin processing to one region can carry a small premium, though, and new models or beta features sometimes arrive later than on the direct API. Still, you get the security guarantees without much extra cost, so if you have in mind, it is worth opening this route in the adapter layer from the start.


Adding an Agent to Your Product: Borrow the Execution Environment, Build Only Your Product’s Core#

To put “a feature that does work for the user” rather than “a feature that answers questions” into your product, you need an agent: a feature that, for a task the user hands over, finds material, creates files, runs commands, and checks the results. It needs an agent loop that calls the model repeatedly and runs tools, a sandbox, an isolated workspace where damage stays contained even if the agent makes a mess, and the infrastructure that actually runs the tools. As the previous chapter said, building this from scratch is irrational for a solo developer. There are two ways to borrow what already exists.

The first is to run a coding agent on your own server. You call an agent such as Claude Code or Codex through its SDK and run it in an isolated workspace you prepare (a , for example). You borrow the part that does the work, and the product handles creating tasks, getting the user’s approval, tracking cost, and recording results. Spinning up and managing the workspace remains your job.

The second is to use a hosted service where the model provider also takes care of the execution environment. Anthropic’s Managed Agents is an example. The developer only decides which model gets which instructions and tools, and which packages, network permissions, and the workspace has, then starts a task through the API. The provider handles the loop, the sandbox, saving task state, compressing long conversations, recovering from failures, and counting token usage. Because the task record is stored separately outside the workspace, even if the workspace stops midway, the task reads that record and picks up where it left off.

I compared whether the system we built ourselves at my company could move to a hosted service. What it could do was the same, but there was something to lose and something to gain.

  • What you lose: In the system we built, when the agent calls a tool, a function inside the same program runs right away. With a hosted service, if the tool lives on your server, the request has to travel over the network, which can be slower. And some branching you used to define precisely in code, like “if this result comes back, go to A, otherwise B,” may have to be written as instructions and left to the model’s judgment. Some features are still in beta.
  • What you gain: Deployment finishes with a single API call, and you do not have to write code to save task state or recover from failures yourself. For someone running things alone, that is a big advantage.

Whichever way you choose, what you have to build yourself is the same: the screens and flows users see, the structure that decides which tasks need a person’s approval, work records, per-user cost limits, security rules, and the data of your own field. Even if you borrow the machinery the agent works with, these are what set your product apart.


Distribution: Bringing Your Product into the User’s Agent#

Finally, there is an option that runs in the opposite direction from putting AI into your product: bringing your product into the AI. The MCP server from Key AI Concepts, Chapter 2 is the channel. Expose your service’s data and features as an MCP server, and users call your product from inside the agents they already use, such as Claude, ChatGPT, and Cursor. The user does not need to open a new app, and you do not need to build a separate one. For features that need a screen, such as tables or buttons, , which became an official MCP extension in early 2026, can even show a small interface inside the conversation.

This direction is attractive for two reasons. First, distribution cost. Instead of acquiring users from an app store or search, your feature sits inside the agent where the user spends the whole day. Providers also run directories that gather and apps, and those become a new storefront. Second, the shift in AI cost. The user’s agent calls the model, so your product only has to provide data and features, with no model cost. It is a structure where the user’s subscription pays for inference. Whether the path to handling AI requests with the user’s subscription inside your own app opens up widely remains to be seen (Sign in with ChatGPT has arrived, but it is still open only to a select few that are approved), but an MCP server itself can be built right now at almost no cost.

Of course, opening an MCP server brings security responsibilities. Who reads and writes your data with what permissions, how to prevent mistaken calls by agents, and how to limit usage are covered in the next chapter.


Checklist#

  1. Track subscriptions (my tools) and the API (product cost of goods) in separate cost accounts.
  2. Before launch, decide who pays the AI cost, what unit you charge for, and how far free use goes, and attach payments and per-user usage records from the start.
  3. Keep API keys only on the server, and route every call through the server.
  4. Wrap model calls in a single adapter layer, and decide a tier and a budget cap for each call site.
  5. Stack the prompt in order of rate of change. Put no variable values in the system instructions, and put search results at the very end.
  6. Judge cost by total context volume, not by cache hit rate.
  7. Send non-real-time work through the batch API.
  8. Once B2B customers appear, open the managed platform route in the adapter, and check the data handling terms of the models you plan to use.
  9. For agent features, borrow the execution environment and build only your product’s core, such as approval, cost limits, and work records.
  10. Consider exposing your data and features as an MCP server as a distribution channel.