
How to Add AI to an Existing SaaS Product Without Rewriting It (Architecture and Cost)
The sidecar architecture I use to add LLM features to a live SaaS without touching the core, the three integration patterns that cover most products, and what it costs to build and run.
You can add AI to existing SaaS product code in **3-8 weeks for $2,500-$25,000** without rewriting anything, by putting the LLM work in a separate service that talks to your current app through the APIs and database it already has. The mistake I see most often is treating "add AI" as a platform migration. It is a feature, and it should be built and shipped like one, behind a flag, to a subset of users first. I'm Md. Emamul Mursalin, a freelance AI product developer in Rajshahi, Bangladesh. Most of my AI integration work is exactly this: a live product, a team that cannot stop shipping, and a request to make it smarter. Here is the architecture I use, the patterns that cover most products, and honest numbers for build and running costs. ## Why "add AI to existing SaaS product" is a different problem from building new A greenfield AI product can put the model at the center. An existing product has customers, a data model, an auth system, and a deploy pipeline, none of which should change because you added a summarize button. The constraints that shape the architecture: - **Zero regression.** Existing features must keep working at the same latency. - **Reversibility.** If the AI feature underperforms, you must be able to turn it off in a minute. - **Data boundaries.** The model should see only the data the current user is allowed to see. - **Cost control.** LLM calls cost real money per request, unlike your existing CRUD endpoints. - **Team velocity.** Your developers should not need to learn LangChain to keep shipping. ## The sidecar architecture The pattern I use on nearly every integration: a separate AI service that sits beside the existing application. ``` [Next.js / your frontend] | v [Existing API] <----> [AI service (NestJS)] ----> [OpenAI / Claude API] | | v v [Existing Postgres] <---- [pgvector tables in the same DB, or a separate schema] ``` How it works: 1. The AI service is its own deployable (a NestJS app, or a set of serverless functions). It has its own dependencies and its own release cadence. 2. It authenticates requests with the same JWT your existing API issues, so authorization is inherited rather than reimplemented. 3. It reads data through your existing API or through read-only database access scoped by tenant, never through a second copy of your business logic. 4. It writes results back through your existing API, so validation and audit logging happen exactly once. 5. Embeddings and retrieval state live in pgvector tables in your existing PostgreSQL instance. No new database vendor for most products under a few million documents. 6. Every AI endpoint is behind a feature flag and a per-tenant rate limit. The existing product changes in exactly two places: a small UI surface (a button, a panel, a chat drawer) and a proxy route that forwards to the AI service. If the AI service goes down, the button disappears and everything else keeps working. ## Three integration patterns that cover most products ### Pattern 1: In-context actions "Summarize this ticket", "draft a reply", "extract the action items", "classify this lead". A single LLM call with the current record as context. No memory, no retrieval, no tools. This is the fastest win. It ships in one to two weeks, costs under a cent per call on a budget model, and users understand it instantly. Start here unless you have a specific reason not to. ### Pattern 2: Ask-your-data (RAG) A chat or search box that answers questions over the customer's own documents, tickets, or records. This needs an ingestion pipeline, embeddings, a vector store, and a retrieval step that respects tenant boundaries and permissions. It is the pattern with the highest customer value and the highest risk of hallucination, so it needs citations and an eval set. I wrote a full breakdown in [RAG over your company data: what it costs and how I build it](/blog/rag-over-company-data-cost-and-architecture). ### Pattern 3: Agents that take actions The AI does things in the product: creates records, sends messages, moves items through a workflow. This adds tool calling, confirmation flows, and guardrails on top of pattern 1 or 2. Cost and timeline jump; see my numbers on [AI agent development cost in 2026](/blog/ai-agent-development-cost-2026) before you scope this. Most products should ship pattern 1, then 2, then 3, in that order, with a few weeks of real usage between each. ## The pieces that make it production-grade Any developer can call the OpenAI API. What separates a demo from a feature your customers pay for: - **Streaming.** Responses stream token by token to the UI. Users will not wait eight seconds for a spinner. In Next.js this is a route handler returning a `ReadableStream`; in NestJS it is a server-sent events endpoint. - **Background jobs.** Anything over a few seconds (batch summarization, document ingestion) runs in a BullMQ queue on Redis, not in the request cycle. - **Prompt versioning.** Prompts are code. They live in the repository, have a version, and every change runs the eval set. - **Cost accounting.** Every call logs tokens in and out, the model, the tenant, and the feature. You will want this the first time a customer asks why their bill went up, and the first time you want to charge for AI usage. - **Rate limits per tenant.** A single abusive user must not spend your monthly budget. - **Fallbacks.** Provider outages happen. My integrations route to a second provider (Groq or a second OpenAI-compatible endpoint) when the primary returns errors. - **Data policy.** Both OpenAI and Anthropic offer zero-retention API terms; enable them and say so in your privacy policy. Here is the shape of the guard I use so AI endpoints inherit auth and enforce a per-tenant budget in NestJS: ```typescript @Injectable() export class AiBudgetGuard implements CanActivate { constructor(private readonly usage: AiUsageService) {} async canActivate(ctx: ExecutionContext): Promise { const req = ctx.switchToHttp().getRequest(); const tenantId = req.user?.tenantId; if (!tenantId) throw new UnauthorizedException(); const remaining = await this.usage.remainingTokens(tenantId); if (remaining <= 0) throw new ForbiddenException('AI quota exhausted'); return true; } } ``` Boring code, and it is the reason the feature does not blow up the P&L in month two. ## What it costs to build Priced for the sidecar architecture, with a senior engineer working directly with your team. US agencies quote $5,000-$20,000 for a basic ChatGPT-style integration and $20,000-$50,000+ for anything agentic; my rates for the same scope are below. | Scope | My fixed price | Timeline | Typical US agency | |---|---|---|---| | Pattern 1: one or two in-context AI actions, streaming, flagged rollout | $799-$2,499 | 1-3 weeks | $5,000-$15,000 | | Pattern 2: RAG over customer data with citations, ingestion pipeline, evals | $2,499-$6,999 | 3-6 weeks | $15,000-$40,000 | | Pattern 3: agent with tool calling, confirmations, admin dashboard, usage billing | $6,999-$25,000 | 6-12 weeks | $40,000-$120,000 | These map to my [AI Integration Starter](/services/ai-integration-starter), [Professional](/services/ai-integration-professional), and [Enterprise](/services/ai-integration-enterprise) tiers; full scope and exclusions are on the [pricing page](/pricing#ai-integration). If your existing codebase needs an assessment first, a short [AI readiness audit](/services/ai-consulting-starter) tells you what will and will not integrate cleanly. ## What it costs to run The build is a one-time cost; the API bill is forever, so estimate it before you commit. As of September 2026: - OpenAI's budget tier is roughly **$0.20 / $1.20** per million input / output tokens; its mid tier is about $2 / $12. - Claude Haiku 4.5 is **$1 / $5**; Claude Sonnet 4.6 is **$3 / $15**. - Embeddings (text-embedding-3-small) are **$0.02 per million tokens**. - Prompt caching cuts repeated input cost by up to 90%. A worked example for pattern 1: summarizing a 2,000-token ticket into 150 tokens on a mid-tier model costs roughly $0.006 per call. At 50,000 summaries a month, that is about **$300**, or under $50 on a budget model. For pattern 2, a RAG answer with 6,000 tokens of retrieved context and a 300-token reply is about $0.016 per question on the mid tier. Agency surveys put typical SaaS AI API fees at $50-$3,000 per month by user count. In my experience, products that route simple tasks to cheap models and reserve expensive models for hard ones sit at the low end of that range. Charge for AI usage (a per-seat add-on or metered credits through Stripe Billing) from the first month, and the feature pays for itself. ## Pre-integration checklist Before you hire anyone, confirm these about your existing product: - You have a single auth system that issues a token the AI service can verify - Your data is tenant-scoped in the database (a `tenantId` or `organizationId` on every table that matters) - You have an API or service layer, not just direct database access from the frontend - You can deploy a second service alongside the current one - You have a staging environment with realistic data - You know which data must never be sent to a third-party model - You have feature flags, or are willing to add a simple one - You have five to ten real examples of the task you want the AI to do, with the answer a human would give The last item is the one teams skip and the one that matters most. Those examples become the first eval set. ## A note on working with me I integrate AI into products for teams in the US, UK, and EU from Rajshahi, Bangladesh (UTC+6), which gives UK and EU teams a full afternoon of overlap and US teams three to four hours across their morning and evening. Every engagement runs under a contract with IP assignment, payment by Payoneer or bank transfer in milestones, and all code in your GitHub organization from the first commit. [MedScribe](/projects/medscribe), an AI-assisted medical documentation product, and [Virtual Client](/projects/virtual-client) are examples of AI built into products with existing workflows and strict data boundaries. ## FAQ ### How do I add AI to my existing SaaS product? Put the AI work in a separate service beside your current app, authenticate it with the token you already issue, read and write through your existing API, store embeddings in pgvector inside your existing PostgreSQL, and ship the first feature behind a flag to a small group of users. Start with in-context actions like summarize or draft, then add retrieval, then agents. ### How much does it cost to integrate ChatGPT into an app? A basic integration (one or two AI actions with streaming and a flagged rollout) costs $799-$2,499 from a senior offshore engineer and $5,000-$15,000 from a US agency in 2026. RAG over customer data runs $2,499-$6,999 offshore. Agents with tool calling start around $6,999. Add a monthly API bill of $50-$3,000 depending on usage. ### How much does AI integration cost per month in API fees? For most SaaS products, $50-$3,000 per month. A summarize action on a mid-tier model costs about half a cent per call; a RAG answer about 1.5 cents. Route simple tasks to budget models, enable prompt caching, and log token usage per tenant so you can charge for it. Embeddings are nearly free at $0.02 per million tokens. ### What is RAG and when should I use it instead of fine-tuning? RAG (retrieval-augmented generation) fetches relevant documents at query time and gives them to the model as context. Use it whenever the answer depends on your data, because it updates instantly, cites sources, and respects per-user permissions. Fine-tuning changes the model's style or format, not its knowledge, and is rarely the right first step for a SaaS. ### Should I use n8n, Zapier or a custom build for AI automation? Use n8n or Zapier for internal workflows where a few seconds of latency and a per-execution fee are fine. Build custom when the AI lives inside your product UI, must respect your auth and tenant boundaries, needs evals and prompt versioning, or will be sold to customers. Prototyping in n8n and then rebuilding the reliable parts is a sensible path. ## Work with me If you want to add AI to existing SaaS product code without a rewrite, send me a link to the product and the one feature you want first, and I will reply within two business days with an architecture sketch and a fixed price. [Book a free discovery call](/appointments), see the [AI developer for hire in Dhaka](/hire/ai-developer-dhaka) page, or [start the Professional AI integration brief](/contact?service=ai-integration&tier=professional).
Building something like this?
I'm a freelance AI product developer in Rajshahi, Bangladesh, working remotely with clients worldwide. A free 30-minute call is enough to scope it.
Book a free 30-min callRelated Articles

Running LLMs On-Device in React Native (Expo): What Actually Works in 2026
On-device AI in React Native is production-ready in 2026 for 1-4B models. Here is which libraries work in Expo, what phones can run, and when to stay in the cloud.

Do You Need a CTO for Your AI Startup? A Decision Checklist for Non-Technical Founders
Most pre-seed AI startups do not need a full-time CTO. They need someone senior to make five decisions correctly. Here is how to tell which one you are.

How I Build Multi-Tenant AI Agent SaaS With Next.js, NestJS and Stripe
The exact architecture I use for multi-tenant AI agent SaaS: tenant isolation in NestJS and Prisma, per-tenant token budgets, and Stripe usage billing. With code.