Embed Decision Playground
Place the complete playground on any HTTPS website with one iframe. Visitors can edit questions, run decisions, inspect results, and use presets inside the frame. The frame scrolls independently when its contents exceed the chosen height.
To start the iframe in dark mode, append ?theme=dark to its URL. A visitor's saved Light or Dark choice takes precedence.
Quick start
- Deploy Decision Playground with a server-side Baseten key.
- Copy the HTML below and paste it into your website. This page fills in your deployment URL automatically.
- Publish your page and run a decision in the iframe to check the integration.
HTML iframe
<iframe
src="https://YOUR-DOMAIN/embed"
title="Decision Playground"
width="100%"
height="900"
loading="lazy"
referrerpolicy="strict-origin-when-cross-origin"
allow="clipboard-write"
allowfullscreen
style="border: 0; max-width: 100%;"
></iframe>Framework examples
React
export function DecisionPlaygroundEmbed() {
return (
<iframe
src="https://YOUR-DOMAIN/embed"
title="Decision Playground"
width="100%"
height="900"
loading="lazy"
referrerPolicy="strict-origin-when-cross-origin"
allow="clipboard-write"
allowFullScreen
style={{ border: 0, maxWidth: '100%' }}
/>
);
}Render the component wherever the playground should appear. No package or client-side API key is needed.
Next.js App Router
// app/decisions/page.tsx
export default function DecisionsPage() {
return (
<main>
<h1>Decision Playground</h1>
<iframe
src="https://YOUR-DOMAIN/embed"
title="Decision Playground"
width="100%"
height="900"
loading="lazy"
referrerPolicy="strict-origin-when-cross-origin"
allow="clipboard-write"
allowFullScreen
style={{ border: 0, maxWidth: '100%' }}
/>
</main>
);
}This page is a Server Component; the iframe needs no client directive.
WordPress Custom HTML
<iframe
src="https://YOUR-DOMAIN/embed"
title="Decision Playground"
width="100%"
height="900"
loading="lazy"
referrerpolicy="strict-origin-when-cross-origin"
allow="clipboard-write"
allowfullscreen
style="border: 0; max-width: 100%;"
></iframe>In the WordPress block editor, add a Custom HTML block, paste the snippet, and preview the page.
Iframe attributes
| Attribute | Purpose |
|---|---|
src | Public /embed URL on your Decision Playground deployment. |
title | Accessible description for assistive technology. |
width | 100% fits the containing element. |
height | Visible frame height in pixels; adjust for your page. Overflow scrolls inside the iframe. |
loading | lazy defers loading until near the viewport. |
referrerpolicy | Limits referrer data sent to the deployment. |
allow | Delegates clipboard writing for the Inspector Copy button in cross-origin frames, where the host permits it. |
allowfullscreen | Allows fullscreen if a browser or host page requests it. |
style | Removes the border and prevents overflow beyond the container. |
Customization options
Set width and height to fit your page. The playground adapts to the iframe width and scrolls within its own frame when needed. Visitors can choose Light or Dark in the playground header. The choice is saved when browser storage is available; the current iframe session still works when third-party storage is blocked. Style the iframe's border, spacing, and container on the host page; host CSS cannot change the contents of a cross-origin iframe.
Security and allowed domains
The iframe calls /api/decide on its own deployment origin. Browser code and the host website never receive BASETEN_API_KEY. The API uses only that server environment variable. A public deployment consumes your Baseten quota and has no built-in rate limiting; use Baseten account limits or Vercel Firewall if you need request caps.
By default, any HTTPS website may frame /embed. To restrict hosts, set EMBED_ALLOWED_ORIGINS to comma-separated HTTPS origins, for example https://example.com,https://app.example.org, then redeploy. Entries must be exact origins without paths or trailing slashes. Invalid configuration blocks all framing. The setting controls framing, not direct API access. Other routes keep their existing headers.
Requests are limited to 4 MB. Compare mode makes two calls. Baseten may return 429 when its own capacity or account limits are reached; the playground retries those responses automatically up to three times.
Troubleshooting
- Blank or blocked frame: check the browser console for a
frame-ancestorserror. Add the host's exact HTTPS origin toEMBED_ALLOWED_ORIGINS, and check for an extraX-Frame-Optionsheader added by your proxy. - Authentication error: set
BASETEN_API_KEYon the deployment server. Refresh the iframe after redeploying. - 429 rate limit: Baseten rate-limited the request. The playground retries automatically up to three times; wait and try again if it persists.
- 502 network error: the deployment could not reach Baseten. Check the function logs and try again.
- History does not persist: some browsers restrict storage in third-party frames. The current session remains usable; export runs you need to keep.
- Layout feels cramped: widen the parent container or increase iframe height. The playground stacks its columns on narrow screens.
Frequently asked questions
Does the host website need a JavaScript SDK?
No. The same public iframe URL works in HTML, React, Next.js, WordPress, and other sites.
Do visitors need an API key?
No. The deployment holds the Baseten key server-side. The API does not enforce its own usage limits, so set Baseten account limits or platform-level protection if the deployment is public.
Can the host page read playground data?
No. Browser same-origin rules isolate a cross-origin iframe from its parent page.
Can I embed on HTTP while developing?
The default policy permits the deployment's own origin for local testing. To test another host, use HTTPS.