How do I add AI to my own app?
Call an AI model's API from your server with a secret key, send instructions plus the user's message, and treat the reply as untrusted data.
The basic loop is simple. Your app's back end, the server part rather than the browser, sends a request to a model provider with your API key, your instructions and the user's input, and gets text back. Keeping the key on the server is essential: anyone can read code that runs in a browser.
Making it ready for real users is the bigger job:
- A system prompt that sets the role, scope, tone and format.
- Structured output: ask for JSON and validate it before using it.
- Streaming, so long replies appear word by word.
- Limits on input size, per-user rate limits and a spending cap, so one user can't run up your bill.
- Retries with growing waits, and a fallback when the provider is busy.
- Defenses against prompt injection, where text from a user or a document tries to override your instructions.
- Tool use, letting the model call functions you define, with approval for risky actions.
Start with one narrow feature, measure whether its answers are good, then grow it.
Vumbli covers this in Agents & Automation, from "Calling an AI model from your code" to shipping your own AI-powered app, and in Building AI Product Features, which adds streaming, tool loops, caching, rate limits and guardrails, ending with a production chat endpoint.
Start with these missions
- Calling an AI model from your code (AI Agents & Tool Use)
- System prompts that ship (AI Agents & Tool Use)
- Streaming: parse server-sent events (Building AI Product Features)
- UX patterns for AI features (Building AI Product Features)
Tracks that teach it
More questions, answered by building