Not publicly available.This describes the Loupestack API before launch. Endpoints, limits and fields can still change.
Embedding generated UIs
A generated UI is a self-contained HTML document written by the language model, plus the saved queries it may run. This page is for whoever shows those documents to people: the rules below are what keeps a document from reading your users’ cookies or sending their data anywhere.
Getting a UI
Section titled “Getting a UI”- Create one with
POST /v1/uisand aprompt, or throughPOST /v1/chat. Both stream; theuievent givesuiIdandversion. - Change it with
POST /v1/uis/{id}/versions: each change is a new version, and older versions keep working. - Fetch a version with
GET /v1/uis/{id}/versions/{version}. It returnshtmlandqueries: the names and parameters of the queries this version may run. No SQL.
Showing it
Section titled “Showing it”Put the version’s html into a sandboxed iframe:
<iframe sandbox="allow-scripts" srcdoc="..."></iframe>- Use exactly
sandbox="allow-scripts". Never addallow-same-origin,allow-top-navigation,allow-popupsorallow-forms. Withoutallow-same-originthe document has an opaque origin: it cannot read your page’s cookies or storage, or reach its DOM. - The
htmlstarts with a Content-Security-Policy that forbids all network access, so the document cannot load or send anything by itself. Do not strip or rewrite it. - If the iframe fires a second
loadevent, the document navigated itself: remove the iframe.
The bridge: how its queries run
Section titled “The bridge: how its queries run”The document cannot call the API. It asks your page, by postMessage, through a function the API puts in the
document: platform.run(name, params). Your page:
- listens for
messageevents whosesourceis that iframe’scontentWindowand whosedata.typeisplatform:run, and ignores everything else; - checks that
data.nameis one of the version’squeries(the API checks again); - calls
POST /v1/uis/{id}/versions/{version}/runwith{ "name": data.name, "params": data.params }, with the user’s session; - posts the outcome back to
iframe.contentWindow, with target origin'*'(the frame’s origin is opaque):{ type: 'platform:result', id: data.id, result }on success, or{ type: 'platform:result', id: data.id, error: { code, message } }on failure.
window.addEventListener('message', async (event) => { if (event.source !== frame.contentWindow || event.data?.type !== 'platform:run') return; const { id, name, params } = event.data; if (!queryNames.has(name)) return reply(id, { error: { code: 'not_found', message: 'No such query.' } }); const res = await fetch(`https://api.dev.loupestack.com/v1/uis/${uiId}/versions/${version}/run`, { method: 'POST', credentials: 'include', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ name, params }), }); const body = await res.json(); reply(id, res.ok ? { result: body } : { error: body.error });});const reply = (id, outcome) => frame.contentWindow.postMessage({ type: 'platform:result', id, ...outcome }, '*');A version can only run its own queries: the API refuses any other name, whatever the document sends.
Deleting
Section titled “Deleting”DELETE /v1/uis/{id} removes a UI, all its versions and their saved
queries. The member who created it can delete it, and so can owners and admins.