The Hidden Complexity of Building AI Assistants
The Production Edition · 2026 · 12 chapters
What every developer should know before going to production — a practical field guide to secure, observable, production-ready AI assistants, for the developer who shipped the demo and now has to run it.
A working demo is only the visible part
A developer can wire an LLM to a few endpoints and ship a chat box in an afternoon. The part that takes months is everything the demo never shows — and it is all below the surface.
Building an AI chatbot is easy. Building one you can trust in production is a different story. This guide walks the whole iceberg, one chapter at a time.

The twelve chapters
Each one stands on its own — read it as a chapter, a post, or a checklist item.
It demos beautifully. That is the problem.
A prototype proves the idea works once, for you, on a happy path. Production means it works every time, for everyone — including the user who asks the question you never imagined.
The first version always feels like magic. You connect a model, expose a couple of endpoints, drop in a chat window, and it answers. The demo lands. Everyone wants it shipped.
Then the real questions arrive. What happens when a user asks for data that is not theirs? When the model calls the wrong tool five times in a loop? When one enthusiastic account quietly runs up a four-figure monthly bill? When someone pastes instructions into a field hoping the assistant will follow them instead of you?
The gap between “it answered” and “I can run this” is most of the work — and none of it is visible in the demo.
- A model that answers on the happy path
- A few endpoints wired straight through
- A chat window that looks the part
- One person testing — you
- Authorization the model can never overrule
- Sensitive fields masked before they reach the model
- Every call, token and dollar traced per user
- Caps, confirmations and alerts when things drift
The moment you add a bot, you add a new way in.
A chat box is an open prompt into your data. The question is whether the assistant can do more than the person typing — and who gets to decide that.
Scenario — unauthorized access. A sales rep opens the assistant and asks for something they could never pull up on screen. In a naïve build, the model is helpful to a fault: it has an endpoint, so it calls it, and reads the answer aloud.
J. Okafor $128,500
M. Chen $96,750 …
GET /api/salaries → 200 OK · no one checked who was asking
Never let the model decide who is allowed. The call runs with the user’s own credentials; your API answers 403 exactly as it would on screen.
Authorization stays where it already lives — in your application. The assistant never holds your users’ credentials and never calls your API directly.
Your API returns more than the model should ever see.
Just because an endpoint returns a field does not mean the assistant needs it. Every field you hand the model is a field that can surface in an answer, a log, or a screenshot.
One “get customer” endpoint returns the whole record — and buried in it: a tax ID, an internal risk score, an API key your frontend never renders. The model has no idea which fields are sensitive. Hand it the whole object and it can repeat any part of it.
The fix is not to trust the model to be discreet. It is to decide, field by field, what reaches the model at all — and to mask the rest before a single character enters its context.
"id": 4182, "name": "Acme Logistics", "email": "[email protected]", "taxId": "30-71234567-9", "notes": "Call Ana on +54 11 5555 0142", "internalScore": 87, "apiKey": "sk_live_9f2c…"
"id": 4182, "name": "Acme Logistics", "email": "•••@acme.com", "taxId": "••••567-9", "notes": "Call Ana on [PHONE]" // internalScore — not sent // apiKey — never sent
Ten mask types, applied on the server before the response enters the model’s context.
| Mask | Your API returns | The model reads |
|---|---|---|
| Label | [email protected] | [EMAIL] |
| Email domain | [email protected] | •••@acme.com |
| Last 4 | A12345678 | ••••5678 |
| First 3 | A12345678 | A12••••• |
| Card BIN | 4242 4242 4242 4242 | 424242••••••4242 |
| Year | 1987-03-14 | 1987 |
| Month | 1987-03-14 | 1987-03 |
| Range | 48200 | 10k–100k |
| Age band | 34 | 30–39 |
| Text scan | Call +1 415 555 0142 | Call [PHONE] |
Paste one real response into the console and it learns the fields. Tick the ones the assistant needs, choose a mask for the sensitive ones, and the service enforces it before any text reaches the model.
The model is one caller. Make sure it is the right one.
An assistant that calls your API is only safe if every call carries the identity of the person chatting — not a shared service account, not a god-mode token.
The tempting shortcut is to give the assistant its own powerful credential so it can “just get the data.” Now every user shares one identity, tenant boundaries blur, and a single bug becomes a cross-customer breach.
The correct answer is boring: the assistant acts as the user, through the login you already have. No new directory, no new passwords, no second system to keep in sync.
Three tokens, one rule: nothing is held by a party that does not need it
Identity is delegated, never invented. The user is named from the authenticated request — not from the message body — so a prompt cannot claim to be someone else.
Three tokens, four parties, one rule. Your backend swaps its API token for a per-user session token, and every call into your data runs under that user.
Your bot is answering. Do you know what happens behind each answer?
You instrument your application without thinking about it. The AI layer ships as a black box — and a black box is exactly where cost, latency and quiet failure hide.
Illustrative — hypothetical cost growth with no monitoring or intervention.
The pitfall: you monitor your app, but not your AI.
- A single user quietly generates a flood of API calls
- The model keeps reaching for the wrong tool, round after round
- Response times creep up and nobody notices
- Users get a wrong answer, lose trust, and stop asking
- Track tokens and cost per user and per tenant
- Trace every model call and every tool call
- Watch latency and failure rates
- Alert on abnormal behaviour before the bill does
- Collect and read the feedback users leave
The observability you would have to build and maintain yourself comes built in, per tenant — a console that turns the black box into something you can read.
One question is rarely one model call.
Agentic assistants loop — read, think, read again. Each loop is tokens, and tokens are money. Without a ceiling, one curious user or one confused model can run the meter.
The cost of an answer is not fixed. A simple lookup might be one call; a “why did this fail?” might chain five. Multiply by active users and days, and the bill stops being a rounding error. The numbers below are illustrative — but the shape is real.
The single biggest lever is calls per question.
| Assumption | Illustrative value |
|---|---|
| Daily active AI users | 1,000 |
| Questions per user per day | 10 |
| Average model calls per question | 3 |
| Average cost per model call | $0.005 |
| Days per month | 30 |
Formula: users × questions × calls × cost × days. Constant average model cost; excludes infrastructure and external API charges. Not product pricing.
Cost becomes a number you set and watch, not one you discover at the end of the month. Choose the model per job, cap the loops, and see spend per user and tenant.
Reading is reversible. Acting is not.
The jump from answering to doing is the biggest one in this guide. A wrong sentence is an annoyance; a wrong write is a ticket raised, a refund issued, a record deleted.
“Excessive agency” is the failure mode: a model that is a little too eager, a tool that is a little too powerful, and nothing standing between the intent and the effect. The guardrail is not to forbid action — it is to make every action explicit, scoped to what you declared, and confirmed by a human.
Let it act — but never without the user’s yes.
I’ll create this task. Please confirm:
title “Follow up on vendor order”
assignee Maria Chen
Endpoints are read-only by default. An endpoint only becomes a write when you declare it one — and every write passes through a confirmation step the backend cannot skip.
“It seems to work” is not a metric.
A model that is confident and wrong is worse than one that says “I don’t know.” You cannot improve what you cannot see — and you cannot see quality without feedback and review.
Grounding answers in live data makes the assistant far less likely to invent a number — it is quoting what your API returned, not recalling from training. But “far less likely” is not “never.” There is no rule that mechanically proves every figure in an answer traces back to a tool result.
So the honest posture is two-sided: instruct the model to quote only what the tools returned, then keep the receipts and actually read them. Collect ratings. Review conversations. Fix the endpoint descriptions that keep confusing it.
Grounding reduces hallucination. Review is how you catch the rest.
User asked for this quarter’s at-risk accounts. The assistant answered, but left a follow-up about one account unresolved and reached for a reporting endpoint that returned an error.
A question was left unanswered — the user asked twice and did not get the number.
An endpoint description is ambiguous; the model picked the wrong tool on the first try.
Quality is not a one-time test; it is a loop. You decide what the assistant reads, AI helps you tune it, and every conversation can be checked.
Nothing is held by a party that does not need it.
Good AI architecture is mostly about who holds what. Keep credentials on your side, keep the model on its side, and route everything through a backend you control.
Four parties. The browser holds only a short-lived session token. Your backend holds your API token and relays every message. The AI service runs the model and plans tool calls but never touches your users’ credentials. Your API answers as the signed-in user. Each boundary is a thing that cannot leak across it.
The browser never sees your API token. Your API never sees an AI Enable Kit token. The service never holds your users’ credentials. Three boundaries, three breaches that cannot happen.
This separation is not a configuration you can get wrong — it is how the integration is shaped. All traffic flows through your own backend, so you can log it, filter it and apply your own rules before and after.
The model is the easy part. The platform is the project.
You can build all of this. The real question is whether the AI platform is your product — or the thing that has to sit underneath it before your product can ship.
Everything in the last nine chapters — the tool-calling loop, session and identity handling, field filtering and masking, logging, cost tracking, alerts — has to exist per application and per tenant. Then it has to be maintained as models, providers and prices change underneath you.
Months of specialised work, then ongoing maintenance — or live in days.
- Model integration and a tool-calling loop
- Sessions, identity and permission handling
- Field filtering and masking of sensitive data
- Logs, usage, cost tracking and alerts — per tenant
- And all of it, maintained as the models change
- All of it built in, per application and tenant
- Your login, your permissions, your APIs
- Allowlisted fields and masks, enforced by the service
- A console for usage, conversations and alerts
- Three routes and a script tag — live in days
Connect, define, embed.
Everything in this guide, assembled into three moves: point it at your API, choose what it can reach, drop in the widget.
The front end is a single script tag on your signed-in pages. The back end is three small routes — a session route, a message relay and a delete route — and the console hands you each one, with your URLs filled in, in Node, Python, PHP, Ruby, Go or Java.
<script src="https://aienablekit.com/widget.js" data-session-url="/api/chat/session" data-message-url="/api/chat/send-message" data-delete-url="/api/chat/delete-session" defer></script>
// POST /api/chat/session
const user = currentUser(event) // your auth
return fetch(`${KIT}/auth`, {
method: "POST",
headers: { authorization: `Bearer ${API_TOKEN}` },
body: JSON.stringify({ user_id: user.id })
})Three ways to enable your endpoints
Change what the assistant reads without a redeploy — edit the inventory and the next question uses it.
The production-readiness checklist.
If you can tick these, your assistant is ready for real users. If you cannot, you know exactly what is left.
Attack surface
Identity & access
Data exposure
Action safety
Cost & limits
Observability & quality
The demo got you here. Production is the rest of the iceberg.
You don’t have to build the platform underneath your AI to ship it. Point AI Enable Kit at your API, choose what it can reach, and your own data answers back — secure, observable and live in days.
Become a Design Partner →Security and data-protection claims in this guide reflect the product as implemented.