AI in your website
Text and structured answers, web-grounded answers, reading uploaded files, extracting fields and generating images, billed to you, or run through your own key.
On this page
Your website can call AI directly, with no keys to manage and no accounts to set up: categorise a support message, summarise a document, draft a reply, read a receipt, generate a poster. These are runtime features your website's users trigger, distinct from the builder that writes the website.
What it can do
import { ai, files } from "@praxivara/sdk";
const text = await ai.invokeLLM({ prompt }); // plain text
const data = await ai.invokeLLM({ prompt, response_json_schema: { ... } }); // JSON matching the schema
const web = await ai.invokeLLM({ prompt, add_context_from_internet: true }); // grounded on live web results
const read = await ai.invokeLLM({ prompt, file_urls: [up.file_url] }); // reads an uploaded PDF or image
const { url } = await ai.generateImage({ prompt, size: "1024x1024" }); // an image for the app
const { output } = await ai.extractDataFromUploadedFile({ file_url: up.file_url, json_schema });- Structured answers: pass a JSON schema and get back an object your website can rely on, a category, a priority, parsed fields, instead of free text to parse.
- Web grounding: lets the answer draw on live web results when the question is about the world rather than your data.
- Reading files: only files your website stored through its own upload, never an arbitrary outside address.
- Extraction: pull named fields out of a receipt, an invoice or a form scan.
- Images: a generated image is stored with the website and referenced like any other asset.
Who can call it
AI calls need a signed-in user by default, so put them behind a login or on an admin screen. They should be deliberate, labelled features with a loading state, never something that runs every time a page renders.
Billing
AI features are billed to you, the owner, in credits, never to your website's users. Each website has its own line on the Usage page so you can see what a feature costs. If a call cannot run, for example because your balance is spent, the website receives a clear error to show instead of retrying.
Using your own key
If you would rather pay your AI provider directly, ask the builder about using your own AI key. It tells you the name to store the key under in Secrets. Text answers from ai.invokeLLM then run on your own account and no credits are charged for them. Generated images and extraction are still billed in credits.
Long outputs
For a long document, a full article or a report, ask the builder to generate it section by section, so each part arrives complete.
Asking for it
When a support message arrives, categorise it and set a priority. Let admins generate a poster for a class from its description. Read the uploaded receipt and fill in the amount and date. The builder writes the call, the loading state and the error state.
What went wrong? Pick any that apply.
That didn't send. Try again in a moment.