AI integration patterns
The handful of architectures that cover most real LLM work, when each applies, and the failure modes to design for.
Pick the smallest pattern that works
Most business problems with language models are solved by one of five shapes. Starting from the smallest keeps cost, risk and surprise down.
1. Classify and route
Input text, fixed set of outputs. Triage support tickets, tag documents, detect intent. Cheap, fast, easy to evaluate against a labelled set. Often a small model is enough.
2. Extract structure
Messy input, structured output with a schema: invoices to line items, emails to orders, CVs to fields. The model returns typed JSON validated against the schema; anything invalid or low-confidence goes to a review queue. The review queue is part of the product, not a fallback.
3. Retrieve and answer
Questions over your documents. The quality lives in retrieval: how documents are split, how search is done (keyword plus vector, then rerank), and how permissions are enforced at query time. The model's job is to answer from what was retrieved, with citations, and to say "not in the sources" when it is not.
4. Draft for a human
The model writes, a person sends. Support replies, proposals, summaries, translations. The human review step is what makes this safe to ship early. Measure acceptance rate and edit distance, not just "does it sound good".
5. Act with tools
The model calls your APIs: look up an order, create a ticket, schedule a job. Each tool is typed, scoped to what the user could do themselves, logged, and reversible where possible. Multi-step agents are built from these tools with explicit limits on steps, cost and time, and with approval gates on anything consequential.
Failure modes to design for
- Prompt injection. Anything the model reads (documents, emails, web pages) can contain instructions. Treat retrieved content as data, keep tools scoped, and never let retrieved text grant permissions.
- Confident nonsense. Require citations, check them, and show confidence to the user. Evaluate on the awkward cases, not the easy ones.
- Silent drift. Models change under you. Pin versions, run the eval set on every change including provider updates, and alert on score drops.
- Cost surprises. Per-request and per-user budgets, caching for repeated questions, smaller models for the easy steps.
- Latency. Stream outputs, do retrieval in parallel, and show progress. A six-second blank screen loses users; six seconds of visible thinking does not.
Provider independence
We build against a thin interface: a call takes a prompt, tools and a schema, and returns a typed result. Behind it sits Claude, OpenAI, Gemini or an open model you host. Switching is configuration. This matters for price, for data residency, and for not being stuck when a provider changes terms.