# How to Add AI Features to Your SaaS: Use Cases, Architecture, and Real Costs

> How to add AI to your SaaS without a gimmick: which features pay off, where the LLM call sits, real per-request cost math, privacy, evals, and rollout.

Author: [Pavle Aleksic](https://pavlealeksic.com/about)
Published: 2026-11-03
Source: https://pavlealeksic.com/blog/adding-ai-features-to-your-product

Every SaaS founder I talk to this year has the same item on the roadmap: "add AI." Usually it arrives as a board question or a competitor's launch post, not as a user problem. That is the wrong starting point, but it does not have to lead to a wrong outcome. If you want to add AI to your SaaS in a way that customers actually use and that does not quietly eat your margin, the work is mostly ordinary product and engineering discipline applied to a component that happens to be non-deterministic.

This post is for founders and product leads who are semi-technical: you can read a code snippet and a pricing table, but you are not training models. I will cover which AI features deliver value and which are decoration, how to pick your first one, whether to build or buy, where the LLM call sits in your architecture, what it costs per request (with the math shown, using prices I checked on the vendors' pages today), and how to ship it without leaking data or embarrassing yourself.

The direct answer: start with one narrow feature that works on data you already own, such as search over your help docs, summarizing a long record, or extracting fields from uploaded documents. Call a hosted model API from your backend, never from the browser. Measure quality with a small test set before launch, stream the output, put hard limits on spend, and roll it out behind a feature flag. For most products that first feature costs cents or fractions of a cent per request, and the engineering is weeks, not quarters.

## The short answer

If you only read one section, read this one.

- **Good first AI features** are boring: answering questions from your own content (RAG), summarizing, extracting structured data from documents, drafting text a human edits, and classifying or routing incoming items. They are cheap to run, easy to evaluate, and users understand them.
- **Agents with tools** can be valuable, but they are the most expensive and the hardest to make reliable. Do them second, not first.
- **Architecture:** your backend calls the model API, with your auth, your tenant scoping, your logging, and your rate limits wrapped around it. The model is a stateless function you rent.
- **Cost:** a typical RAG answer on a mid-tier model is around two cents. A classification call on a small model is about a hundredth of a cent. Agents run tens of cents per task. The math is below.
- **Privacy:** paid API traffic at OpenAI, Anthropic, and Google's paid Gemini tier is not used to train their models by default, but retention and data residency differ. Read the terms before you send customer data.
- **Timeline (estimate):** two to four weeks for a single well-scoped feature, one to three months for production RAG or a tool-using workflow.

## AI features that actually earn their keep

I have built, inherited, and ripped out a fair number of LLM features. The survivors share a trait: they remove a tedious step from a job the user was already doing. The ones that die were bolted on because "we need AI."

### The six that deliver

| Feature | What it does | Why it works | Difficulty |
| --- | --- | --- | --- |
| Search and Q&A over your data (RAG) | Answers questions using your docs, tickets, or records, with citations | Users already search; this makes search answer instead of list | Medium |
| Summarization | Condenses long threads, records, calls, or reports | Saves reading time; easy to verify against the source | Low |
| Extraction from documents | Pulls structured fields out of PDFs, emails, invoices, contracts | Replaces manual data entry, which nobody wants to do | Low to medium |
| Drafting | Writes a first version of a reply, description, or report for a human to edit | Human stays in the loop; mistakes are cheap | Low |
| Classification and routing | Tags, prioritizes, or routes tickets, leads, or documents | High volume, small outputs, cheap models do it well | Low |
| Agents with tools | Takes multi-step actions through your APIs | Can automate whole workflows | High |

**RAG over your business data** is the one I get asked about most. The idea is simple: when a user asks a question, you retrieve the relevant chunks of your own content and give them to the model along with the question, so it answers from your data instead of its training. The hard parts are chunking, retrieval quality, and citations, which I covered in detail in [building production RAG](/blog/building-production-rag). If you are wondering where to store the embeddings, my take on [choosing a vector database](/blog/choosing-a-vector-database-2026) is that Postgres with pgvector is enough for most SaaS products.

**Extraction** is underrated. Turning an uploaded invoice into typed JSON replaces manual data entry, and it is easy to measure: the field is right or it is not. The reliability trick is constrained output (structured outputs or strict tool schemas), which I walk through in [structured outputs and tool calling](/blog/structured-outputs-and-tool-calling).

**Classification and routing** is the highest-volume, lowest-cost win: tagging tickets by topic and urgency, scoring leads, flagging documents for review. The output is one label or a short JSON object, so cost is tiny and evaluation is trivial.

**Agents** are where the hype lives. An agent is a model in a loop that can call your tools (search orders, issue a refund, update a record) until a task is done. They can be worth it, but each step multiplies cost, latency, and the number of ways things go wrong. I wrote separately about [LLM agents that actually work](/blog/llm-agents-that-work); the short version is that most "agents" should be fixed workflows with one or two model calls, not open-ended loops.

### The gimmicks

These show up in demos and get quietly removed six months later:

- **A generic chatbot in the corner** with no access to the user's data and no ability to do anything. It answers questions worse than your docs search and costs money doing it.
- **Fully autonomous actions on high-stakes data** (sending emails to customers, changing billing) with no human review step.

The test I use: if the feature disappeared tomorrow, would anyone open a support ticket? If not, it is decoration.

## Picking your first feature, and whether to build or buy

### How to choose the first one

Score candidate features on four questions. The best first feature gets a yes on all four.

1. **Is there a measurable job today?** Someone already spends time reading, typing, tagging, or searching. You can count it.
2. **Do you own the data?** The inputs live in your database or your users upload them. No scraping, no third-party data you are not allowed to send to a model vendor.
3. **Is a wrong answer cheap?** A human reviews the draft, or the summary links back to the source, or a misrouted ticket gets re-routed. Avoid first features where an error costs money or trust immediately.
4. **Can you evaluate it in a spreadsheet?** You can write 50 examples of input and expected output (or expected properties of the output) in an afternoon.

Summarization, extraction, and classification usually score highest. RAG scores well if your content is in decent shape. Agents usually fail question 3.

### Build vs buy

"Buy" here means three different things, and it is worth separating them.

| Option | Examples | Good when | Watch out for |
| --- | --- | --- | --- |
| Buy a finished tool | Help-desk AI add-ons, vendor chat widgets | The feature is generic (support deflection on public docs) and not core to your product | Per-seat or per-resolution pricing, limited access to your data, no control over quality |
| Build on hosted model APIs | OpenAI, Anthropic, Google Gemini APIs | The feature uses your data and your workflow, which is most cases | You own prompts, evals, and guardrails |
| Self-host open-weight models | Running a model on your own GPUs | Strict data residency, very high volume of simple tasks, or a team with ML ops experience | GPU cost, ops burden, and usually lower quality per dollar at small volume |

My default recommendation for a SaaS product is the middle row. The feature that differentiates you is the one that touches your data and fits your workflow, and an off-the-shelf widget cannot do that. Self-hosting rarely makes sense for a first feature: at low and moderate volume the hosted APIs are cheaper than idle GPUs, and you skip a whole class of operational work. Revisit it if volume grows a lot or a customer contract forces it.

## How to add AI features to an app: the architecture

The architecture for adding AI to a SaaS is less exotic than people expect. The model is a remote, stateless, somewhat slow, somewhat expensive function. Everything around it is normal backend engineering.

### Where the LLM call sits

The call lives in your backend: an API route, a server action, or a background worker. Never in the browser. The browser would need your API key, and you would lose every control you need: auth, tenant scoping, rate limits, logging, and cost caps.

The data flow for a typical request looks like this:

```text
Browser
  -> your API (auth, tenant check, rate limit, feature flag)
    -> load context from YOUR database (scoped to this tenant)
    -> (optional) retrieve relevant chunks from vector index
    -> build prompt: system instructions + context + user input
    -> call model API (stream)
    -> validate output (schema, length, policy checks)
    -> log: tokens, cost, latency, model, prompt version
  <- stream tokens back to browser
```

Interactive features (chat, drafting, Q&A) run in the request and stream. Bulk work (summarizing every ticket overnight, extracting fields from 5,000 uploaded PDFs) goes through a queue and a worker, which also lets you use batch APIs at a discount. If you do not have a job system yet, [background jobs and queues](/blog/saas-background-jobs-queues) is the pattern to set up first.

### A small TypeScript example

Here is a Next.js route handler that summarizes a support ticket thread for the logged-in user's organization and streams the result. It uses the official Anthropic SDK; the shape is nearly identical with OpenAI's or Google's SDKs.

```ts
// app/api/tickets/[id]/summary/route.ts
import Anthropic from "@anthropic-ai/sdk";
import { getSession } from "@/lib/auth";
import { db } from "@/lib/db";
import { checkAiBudget, recordAiUsage } from "@/lib/ai-usage";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY on the server only

const SYSTEM = `You summarize customer support threads for support agents.
Write 3-6 bullet points: the customer's problem, what has been tried,
current status, and the next action. Use only facts from the thread.
If something is unclear, say so instead of guessing.`;

export async function POST(
  _req: Request,
  { params }: { params: Promise<{ id: string }> },
) {
  const session = await getSession();
  if (!session) return new Response("Unauthorized", { status: 401 });

  const { id } = await params;

  // Tenant scoping happens HERE, in your code, not in the prompt.
  const ticket = await db.ticket.findFirst({
    where: { id, orgId: session.orgId },
    include: { messages: { orderBy: { createdAt: "asc" } } },
  });
  if (!ticket) return new Response("Not found", { status: 404 });

  if (!(await checkAiBudget(session.orgId))) {
    return new Response("AI usage limit reached", { status: 429 });
  }

  const thread = ticket.messages
    .map((m) => `[${m.author}] ${m.body}`)
    .join("\n\n")
    .slice(0, 60_000); // hard cap on input size

  const stream = client.messages.stream({
    model: "claude-sonnet-5-5",
    max_tokens: 2000,
    system: SYSTEM,
    messages: [
      { role: "user", content: `<thread>\n${thread}\n</thread>` },
    ],
  });

  const encoder = new TextEncoder();
  const body = new ReadableStream({
    async start(controller) {
      try {
        for await (const event of stream) {
          if (
            event.type === "content_block_delta" &&
            event.delta.type === "text_delta"
          ) {
            controller.enqueue(encoder.encode(event.delta.text));
          }
        }
        const final = await stream.finalMessage();
        await recordAiUsage({
          orgId: session.orgId,
          feature: "ticket-summary",
          model: final.model,
          inputTokens: final.usage.input_tokens,
          outputTokens: final.usage.output_tokens,
        });
        controller.close();
      } catch (err) {
        controller.error(err);
      }
    },
  });

  return new Response(body, {
    headers: { "Content-Type": "text/plain; charset=utf-8" },
  });
}
```

The model call is ten lines. The rest is auth, tenant scoping, a budget check, an input cap, streaming, and usage recording. That ratio is normal, and it is the part prototypes skip.

For extraction, you want typed output instead of prose. With the same SDK you pass a schema and get parsed, validated JSON back:

```ts
import Anthropic from "@anthropic-ai/sdk";
import { z } from "zod";
import { zodOutputFormat } from "@anthropic-ai/sdk/helpers/zod";

const Invoice = z.object({
  vendorName: z.string(),
  invoiceNumber: z.string(),
  issueDate: z.string(), // ISO date
  currency: z.string(),
  total: z.number(),
  lineItems: z.array(
    z.object({ description: z.string(), amount: z.number() }),
  ),
});

const client = new Anthropic();

export async function extractInvoice(invoiceText: string) {
  const res = await client.messages.parse({
    model: "claude-haiku-5-5",
    max_tokens: 4000,
    messages: [
      {
        role: "user",
        content: `Extract the invoice fields.\n<invoice>\n${invoiceText}\n</invoice>`,
      },
    ],
    output_config: { format: zodOutputFormat(Invoice) },
  });

  if (!res.parsed_output) throw new Error("Extraction failed validation");
  return res.parsed_output; // typed as z.infer<typeof Invoice>
}
```

Schema validation guarantees the shape, not the truth. A total can be valid JSON and still wrong. That is what evals are for, and for money fields I add arithmetic checks in code (do the line items sum to the total?) before anything is saved.

## Choosing a model in late 2026

All three major vendors sell a family of models at very different price points, and the most important decision is not which vendor but which tier. Here are the current list prices I checked on 2026-11-03 on the official pricing pages for [Anthropic](https://platform.claude.com/docs/en/about-claude/pricing), [OpenAI](https://developers.openai.com/api/docs/pricing), and [Google Gemini](https://aistudio.google.com/docs/pricing). Prices are per million tokens, standard tier, short-context; a token is roughly three quarters of an English word.

| Vendor | Model | Input $/1M | Output $/1M | Rough tier |
| --- | --- | --- | --- | --- |
| Anthropic | Claude Opus 5.5 | $4.00 | $20.00 | Top |
| Anthropic | Claude Sonnet 5.5 | $2.00 | $10.00 | Mid |
| Anthropic | Claude Haiku 5.5 (prompts up to 100K tokens) | $0.10 | $0.50 | Small |
| OpenAI | gpt-6-astra | $10.00 | $50.00 | Top |
| OpenAI | gpt-6.1-sol | $2.00 | $10.00 | Mid |
| OpenAI | gpt-6.1-terra | $1.00 | $5.00 | Mid |
| OpenAI | gpt-6-luna | $0.10 | $0.50 | Small |
| Google | Gemini 3.1 Pro Preview (up to 200K tokens) | $2.00 | $12.00 | Mid to top |
| Google | Gemini 3.8 Flash | $0.75 | $3.75 | Small to mid |
| Google | Gemini 3.1 Flash-Lite | $0.25 | $1.50 | Small |

Model prices move every few months, and some of these are launch or promotional rates, so check the linked pricing pages before you put a number in a budget. The tiers matter more than the exact figures.

A few things on those pages matter more than the headline numbers:

- **Output costs five to six times input** on most models. Long answers are what you pay for, not long prompts.
- **Reasoning ("thinking") tokens are billed as output** on models that think before answering. A short visible answer can carry a lot of hidden output tokens, so measure real usage instead of estimating from the text you see.
- **Prices change.** Google's page lists scheduled increases: Gemini 3.8 Flash goes to $1.50 input and $7.50 output on January 1, 2027. Build your cost tracking so a price change is a config edit.
- **Batch processing is half price** at both Anthropic and OpenAI for work that can wait (Anthropic documents a 50% discount on input and output; OpenAI lists batch at half the standard rate).
- **Cached input is much cheaper.** Repeated prompt prefixes (system instructions, shared documents) are billed at a fraction of the input rate once cached; Claude Sonnet 5.5 lists cache hits at $0.10 per million versus $2.00 for fresh input.

How I pick: start every feature on a mid-tier model to find out whether the task is solvable at all. Once you have an eval set, try the small model on the same set. For classification, extraction from clean documents, and short summaries, the small tier is often good enough, at a twentieth of the price. Keep the top tier for genuinely hard reasoning, long agent runs where a mistake is expensive, or features where measured quality on your evals justifies it. I go deeper on routing traffic between tiers in [cutting LLM cost and latency](/blog/cutting-llm-cost-and-latency).

## What AI integration costs: per-request math

This is the section founders actually want. All numbers below use the list prices from the table above and explicit token assumptions. They are estimates: your real token counts will differ, so treat them as order-of-magnitude, then measure.

The formula is the same for every model:

```text
cost per request = (input tokens  x input price  / 1,000,000)
                 + (output tokens x output price / 1,000,000)
```

### Example 1: RAG answer over your help docs (Claude Sonnet 5.5)

Assumptions: 1,500-token system prompt, 4,000 tokens of retrieved chunks, a 200-token question, and 800 output tokens including any reasoning.

```text
input:  5,700 x $2.00  / 1,000,000 = $0.0114
output:   800 x $10.00 / 1,000,000 = $0.0080
total per answer                    = $0.0194  (about 2 cents)

50,000 questions / month x $0.0194  = $970 / month
```

Caching the 1,500-token system prompt saves 1,500 x ($2.00 minus $0.10) / 1,000,000, about $0.0029 per request, or roughly $140 a month at that volume. Shrinking retrieval from 4,000 to 2,000 tokens of better-ranked chunks saves another $0.004 per request. Retrieval quality and cost are the same lever.

### Example 2: Ticket classification (Claude Haiku 5.5 or gpt-6-luna)

Both list at $0.10 input and $0.50 output. Assumptions: 800 tokens of instructions plus ticket text, 50 tokens of JSON output.

```text
input:  800 x $0.10 / 1,000,000 = $0.00008
output:  50 x $0.50 / 1,000,000 = $0.000025
total per ticket                = $0.000105

100,000 tickets / month         = $10.50 / month
```

Ten dollars a month. This is why classification and routing are such good first features: the run cost is a rounding error and the value is easy to see.

### Example 3: Contract extraction (Claude Sonnet 5.5, batch)

Assumptions: a 20-page contract at roughly 750 tokens per page as extracted text (15,000 tokens), 1,500 tokens of structured JSON output. Sending PDFs as page images changes the token count, so measure with your real documents.

```text
standard:
input:  15,000 x $2.00  / 1,000,000 = $0.030
output:  1,500 x $10.00 / 1,000,000 = $0.015
total per contract                   = $0.045

batch (50% off)                      = $0.0225
2,000 contracts / month, batch       = $45 / month
```

### Example 4: An agent that resolves a support request (Claude Opus 5.5)

Agents resend the growing conversation on every step, so input adds up fast. Assumptions: 6 model turns, averaging 12,000 input tokens per turn (instructions, tool definitions, history, tool results) and 500 output tokens per turn.

```text
input:  6 x 12,000 = 72,000 x $4.00  / 1,000,000 = $0.288
output: 6 x    500 =  3,000 x $20.00 / 1,000,000 = $0.060
total per task                                    = $0.348

5,000 tasks / month                               = $1,740 / month
```

Prompt caching cuts this considerably, because most of each turn's input is the same prefix as the previous turn. Still, this is three orders of magnitude more per task than classification, and it is why I do not recommend agents as a first feature.

### Embeddings are nearly free

For RAG you also embed your content once (and again when it changes). OpenAI lists text-embedding-3-small at $0.02 per million tokens. Embedding 10,000 documents of 2,000 tokens each is 20 million tokens, which is $0.40. The cost in RAG is the generation call and the engineering, not the embeddings.

### What moves the bill

| Lever | Effect |
| --- | --- |
| Model tier | Mid to small is often a 20x drop |
| Output length | Biggest per-token cost; cap `max_tokens`, ask for concise formats |
| Context size | Retrieve fewer, better chunks; trim history |
| Prompt caching | Large discount on repeated prefixes |
| Batch processing | 50% off for anything that can wait |
| Volume per user | Free-tier abuse is the classic surprise; rate-limit per user and per org |

If your pricing is per seat, divide your expected monthly AI cost by active seats and check it against margin before launch. For heavy features, consider metered usage or credit packs. If you bill through Stripe, usage-based add-ons are covered in [Stripe billing for SaaS](/blog/stripe-billing-for-saas).

## Data privacy, retention, and compliance

The first question your larger customers will ask is "does our data train your AI?" You need a precise answer, and it depends on the vendor and tier.

What the vendors state today:

- **OpenAI:** data sent to the API is not used to train or improve OpenAI models unless you opt in. Abuse monitoring logs are kept for up to 30 days by default. Zero Data Retention is available to eligible customers with OpenAI's approval, and data residency (including the US and Europe) is a per-project setting arranged through sales. Source: [OpenAI's data controls documentation](https://developers.openai.com/api/docs/guides/your-data).
- **Anthropic:** by default, inputs and outputs from commercial products are not used to train models ([Anthropic Privacy Center](https://privacy.claude.com/en/articles/7996868-is-my-data-used-for-model-training)). API inputs and outputs are deleted on the backend within 30 days, with exceptions such as zero data retention agreements, usage policy enforcement, and legal requirements ([retention article](https://privacy.claude.com/en/articles/7996866-is-my-data-used-for-model-training)). Note that feedback you submit (thumbs up or down) can be used for training.
- **Google Gemini API:** the pricing page shows, per model, that free-tier content is used to improve Google's products and paid-tier content is not. Do not prototype with real customer data on a free key.

What I do on every project:

1. **Send the minimum.** Strip fields the task does not need. A ticket summary does not need the customer's billing address.
2. **Keep tenant isolation in code.** The model never decides which data it is allowed to see. Your query filters by organization before anything reaches the prompt, as in the example above.
3. **Sign the paperwork.** Get the vendor's DPA in place, list the model provider as a subprocessor in your own DPA and privacy policy, and tell enterprise customers before you ship, not after.
4. **Decide what you store.** Your own logs of prompts and outputs are now customer data with retention obligations. Log token counts and metadata by default; store full prompts only where you need them for debugging, with a retention window.
5. **Regulated data needs a specific answer.** Health, financial, or children's data, and EU customers with residency requirements, need the vendor's specific programs (zero retention, regional processing, BAAs where offered). Check the current terms with the vendor rather than assuming.

Let organization admins switch AI features off. Some enterprise buyers require it, and it costs you a boolean.

## Evaluation: knowing whether it works

The difference between an AI feature that gets better and one that drifts is an eval set. Without one, every prompt change is a guess and every model upgrade is a gamble.

Minimum viable evals for a first feature:

1. **Collect 50 to 200 real inputs.** Real tickets, real documents, real questions, anonymized if needed. Include the ugly ones: long, short, multilingual, malformed.
2. **Define "good" per case.** For extraction, the expected field values. For classification, the expected label. For summaries and answers, a short list of properties: mentions the refund, does not invent an order number, cites a source.
3. **Score automatically where you can.** Exact match for labels and fields, code checks for format and length, and an LLM-as-judge with a written rubric for prose, spot-checked by a human.
4. **Run it on every change.** Prompt edits, model swaps, retrieval tweaks. Treat a drop in the score like a failing test.
5. **Feed production back in.** Thumbs down, edits users make to drafts, and escalations become new eval cases.

I cover the mechanics, including how to keep an LLM judge honest, in [evaluating LLM apps](/blog/evaluating-llm-apps). For a first feature you do not need a platform: a script, a JSON file of cases, and a results table are enough.

In production, track usage, acceptance (did the user keep the draft or accept the label), error rate, p95 latency, and cost per request per feature. Acceptance is the honest one.

## Latency and UX

Users tolerate a model that takes a few seconds if they can see it working. They do not tolerate a spinner.

- **Stream interactive output.** Time to first token is what users perceive. Streaming turns a several-second wait into text appearing almost immediately. The route handler above does exactly this, and the frontend side is the same idea as [streaming with Suspense](/blog/nextjs-streaming-suspense-app-router): show something useful early.
- **Run non-interactive work in the background.** Summaries of every closed ticket, extraction of uploaded files, nightly classification. Show results when they are ready; nobody needs to watch it happen.
- **Pick smaller models for latency-sensitive paths.** They are usually faster as well as cheaper.
- **Design for being wrong.** Show sources for answers. Make drafts editable, not auto-sent. Label AI output as AI output. Give a one-click way to report a bad result, and wire it into your eval set.
- **Handle failure gracefully.** Vendor APIs have outages and rate limits. Time out, retry with backoff, and fall back to the non-AI experience.

## Guardrails and prompt injection

Prompt injection is the security problem specific to LLM features, and it is first on the [OWASP Top 10 for LLM Applications](https://genai.owasp.org/llm-top-10/) (LLM01:2025). The model cannot reliably tell your instructions apart from instructions hidden in the content it reads. A support ticket, an uploaded PDF, or a web page can contain "ignore your instructions and..." and the model may comply.

You cannot prompt your way out of this. You design around it:

- **Limit what the model can do.** A summarizer with no tools can, at worst, write a bad summary. An agent that can issue refunds can be talked into issuing refunds. Give each feature the smallest set of tools it needs.
- **Enforce permissions in code, not in the prompt.** Tools run with the current user's permissions and tenant scope, checked by your backend on every call. "Only access this customer's data" in a system prompt is not access control.
- **Require confirmation for consequential actions.** Sending email, changing billing, deleting records: the model proposes, a human approves.
- **Validate outputs.** Schemas for structured data, allowlists for labels, length limits, and checks that links and IDs in the output actually exist in your system.
- **Do not render model output as raw HTML**, and treat links in it with suspicion. Output can carry injected markup or exfiltration URLs.
- **Rate-limit and cap spend** per user and per organization, so abuse costs you a capped amount. The patterns in [rate limiting strategies](/blog/rate-limiting-strategies) apply directly.

The deeper treatment, including the rest of the OWASP list, is in [securing LLM applications](/blog/securing-llm-applications).

## Rollout plan and ongoing cost control

### Rolling it out

The rollout I use for a first AI feature:

1. **Internal only.** Your team uses it on real data for a week or two. Bad outputs become eval cases.
2. **Beta flag for a handful of friendly customers.** Ideally ones who asked for it. Watch acceptance, errors, and cost per request daily.
3. **Percentage rollout** to all customers, with the feature flag as a kill switch and per-org spend caps on.
4. **General availability**, with an org-level setting to turn it off, documentation that says which vendor processes the data, and a feedback button.

At each step, decide in advance what number makes you stop: acceptance below a threshold, cost per request above a threshold, or any data-handling incident.

### Keeping cost under control after launch

The bill is small the first month and becomes a line item later, usually because usage grew or someone widened a prompt. Habits that keep it boring:

- **Record tokens and cost per request**, tagged by feature, model, organization, and prompt version. You cannot fix a cost you cannot attribute.
- **Set budgets and alerts** at the vendor level (spend limits in the provider console) and in your app (per-org monthly caps).
- **Cache aggressively.** Prompt caching for shared prefixes, and your own cache for identical requests such as the summary of an unchanged record.
- **Route by difficulty.** Small model by default, larger model only where evals show it is needed.
- **Use batch for anything not interactive.**
- **Re-run evals when models change.** A newer small model may pass the eval that used to need a mid-tier one.

## Project timeline and budget ranges

These are estimates, not quotes. They assume a product with a working codebase, clean enough data, and one senior full-stack engineer doing the work. To turn weeks into money I use an assumed contractor rate of $80 to $150 per hour at roughly 30 to 40 billable hours per week; your rates, team, and codebase will move these numbers.

| Scope | Typical timeline | Budget estimate | What moves it |
| --- | --- | --- | --- |
| One narrow feature (summaries, classification, drafting) | 2 to 4 weeks | $5,000 to $24,000 | UI work, how many places it appears, admin settings |
| Document extraction pipeline | 3 to 6 weeks | $7,000 to $36,000 | Document variety, scans vs text, validation rules, review UI |
| Production RAG over your content | 4 to 10 weeks | $10,000 to $60,000 | Content quality and formats, permissions on documents, citation UX, eval set |
| Tool-using workflow or agent | 6 to 14 weeks | $15,000 to $84,000 | Number of tools, action risk, approval flows, eval and monitoring depth |

Run cost is separate and, for the first three rows, usually small next to the build. Budget for maintenance too: prompts and evals need attention when models change.

The most common overrun I see is not the AI part. It is the data: documents in five formats, or permissions that were never modeled cleanly. Fix a shaky data layer first.

## Frequently asked questions

### How much does it cost to add AI to a SaaS app?

Two parts: building and running. Building a single focused feature is typically a few weeks of senior engineering (my estimate is $5,000 to $24,000 at common contractor rates), and production RAG or agents run higher. Running costs depend on model tier and volume: from about $0.0001 per classification on a small model to around two cents per RAG answer on a mid-tier model, and tens of cents per agent task.

### Will the AI vendor train on my customers' data?

Not by default on paid API usage at OpenAI and Anthropic, and Google states that paid-tier Gemini API content is not used to improve its products (free-tier content is). Retention still applies, typically up to 30 days for abuse monitoring, and zero retention requires approval. Read the current terms, sign the DPA, and disclose the vendor as a subprocessor.

### Should I use OpenAI, Anthropic, or Google?

List prices at the mid and small tiers are close, so decide on your own evals, not public benchmarks. Wrap the model behind your own functions (`summarize()`, `answer()`) so switching vendors is a one-file change, test two on your real cases, and pick the best scorer at the lowest tier that passes.

### Do I need a vector database to add AI search?

Only if you are doing RAG, and even then usually not a separate one. Postgres with pgvector handles most SaaS-scale content and keeps your data and permissions in one place. A dedicated vector database earns its place at large scale or with specialized search needs.

### Do I need to hire an AI developer or an ML engineer?

For features built on hosted model APIs, you need a strong full-stack or backend engineer who understands LLM-specific concerns: evals, structured outputs, prompt injection, and cost tracking. You do not need someone who trains models. An ML specialist becomes relevant when you fine-tune, self-host models, or build custom ranking.

### How long does it take to add an AI feature?

A narrow, well-scoped feature on top of a healthy codebase takes about two to four weeks including evals and rollout. Production RAG takes one to two and a half months; tool-using workflows can take longer because each action needs permissions, confirmation, and testing.

### What is the best first AI feature for a SaaS product?

The one that removes a tedious step users already do, works on data you own, and is cheap to get wrong. In practice that is usually summarization, extraction from uploaded documents, or classification and routing. These are cheap to run and easy to measure, so you learn fast.

## Working with me

If you want to add AI to your product and would rather have it designed with evals, tenant isolation, and cost controls from day one, that is the work I do on [AI and LLM integration](/services/ai): scoping the first feature, building it into your existing stack, and setting up the measurement so it improves after launch. If you have a feature in mind, or just a pile of data and a hunch, [get in touch](/contact) and tell me what your users spend their time on.
