Orange Book
Guides

Add AI capabilities to a normal application only when needed

Treat inference, model gateways, and natural-language search as replaceable modules, not prerequisites for a useful application.

Edited and verified by Orange Book Editorial Team ·

OPTIONAL AIINTERMEDIATE25 minutesOutcome: a written decision on whether AI belongs

Make the application useful without a model, then add AI only where it improves a real task. SaaS tenant management, CMS publishing, image resizing, and PDF generation do not require an LLM. AI is a better fit for classification, summarization, generation, and semantic retrieval that deterministic rules cannot solve economically.

This is not an agent tutorial

Agents and chat are only two possible product shapes. This page shows how a normal application can call a replaceable model module safely and keep its core service available when that module fails.

Decide whether the capability is justified

User taskDefaultConsider AI whenNon-AI fallback
Form validationSchema and deterministic rulesDo not replace with a modelDisplay field errors
Content classificationRules, tags, or a human choiceCategories are fuzzy and volume is highSave as unclassified
Text summaryExtract and human summaryDocuments are long, numerous, and approximation is acceptableShow original and outline
Content searchKeywords and filtersUsers express intent in natural languageKeep keyword search
Copy draftTemplatesUsers benefit from varied first draftsUse a fixed template

If output can charge money, delete data, change authorization, or publish publicly, the model can propose an action but deterministic checks or a human must approve it.

Three Cloudflare entry points

Workers AI

Call Cloudflare-hosted models from a controlled service layer in a Worker.

AI Gateway

Observe, control, and switch model providers when an application already uses external model APIs or needs provider fallback.

AI Search

Build managed retrieval from a website, R2 bucket, or uploaded documents for natural-language search with sources.

The products can work together, but do not enable them all by default. Define input, output, latency target, data sensitivity, and budget, then select the smallest entry point.

Integration sequence

Define a stable application interface

Business code calls your own classify(), summarize(), or search() interface instead of scattering model requests across page components. Return structured output, sources, model state, and recognizable errors.

Bound input and output

Limit text length, file type, and allowed fields on the server. Treat retrieved documents and user input as untrusted data. They cannot override system rules or request secrets.

Add timeout and fallback

Return an understandable state when a model times out or a quota is exhausted. Search falls back to keywords, summaries to the original preview, and classification to a review queue. Saving, login, and payment cannot depend on model success.

Observe cost and quality

Record calls, the applicable usage unit, latency, errors, and human corrections per feature. Do not log complete sensitive prompts and private user content by default.

Release gate

Correctness

Fixtures cover normal, empty, oversized, adversarial, and downstream-failure inputs.

Security

Secrets stay server-side, output passes schema validation, and high-risk actions are never automatic.

Cost

A per-request bound, daily budget signal, and over-budget fallback replace assumptions about free allowance.

Replaceability

Disabling the AI binding still leaves the core save, read, and completion flow available.

Next: choose a search and knowledge approach.

Primary sources

Did this page help you complete your goal?

Beta feedback is generated in this browser and is never uploaded automatically.

On this page