Build
Generate an app
Drive the multi-agent build pipeline from your code. Stream the same events the workbench shows: plan, file writes, ready, errors. Every app lives under a chat — start a chat, generate, iterate.
#The end-to-end flow
- Create a chat (or pick an existing one).
- POST a prompt to start the build pipeline.
- Stream events as the planner, files agent, code agents, and reviewer run.
- Receive a
readyevent with the preview URL. - (Optional) Run augmenters, deploy, fork, or iterate.
#One-shot generate (recommended)
The SDK's apps.generateStream wraps the full lifecycle — it creates the chat, kicks off the build, and yields events until ready or error.
const stream = client.apps.generateStream({
prompt: 'Modern landing page for an AI scheduling assistant',
template: 'saas-ai-landing', // optional starter
augmenters: ['seo', 'a11y'], // queue for after build
workspaceContextOverride: { // override brand voice for this run
voice: 'confident, plainspoken',
},
});
for await (const event of stream) {
switch (event.type) {
case 'plan': console.log('plan:', event.summary); break;
case 'file': console.log('file:', event.path); break;
case 'review': console.log('review:', event.notes); break;
case 'ready':
console.log('preview:', event.previewUrl);
console.log('app id:', event.appId);
break;
case 'error': throw new Error(event.message);
}
}#Request fields
| Field | Type | Description |
|---|---|---|
| promptrequired | string | Natural-language description of what to build. |
| template | string | Optional starter ID — see Templates docs for the full list. |
| chatId | string | Continue an existing chat. Omit to create a new one. |
| augmenters | string[] | Augmenter aliases to run sequentially after the build. Examples: ["seo","a11y","pwa"]. |
| workspaceContextOverride | object | Per-run override of any field in your workspace context (voice, audience, etc.). |
| modelOverride | string | Force a specific model. See Models reference. Falls back to your tier default. |
#Event shapes
Every event has a type discriminator. Common types:
| Field | Type | Description |
|---|---|---|
| plan | { summary, files } | Planner agent finished. summary is prose; files is the manifest. |
| file | { path, contents } | A code agent committed a file to the workspace. |
| review | { notes, fixes } | Reviewer ran. notes is a markdown summary; fixes lists files patched. |
| augmenter | { alias, status } | Lifecycle event for a queued augmenter (started, applied, failed). |
| ready | { previewUrl, appId } | Preview is up. Capture appId for follow-ups. |
| error | { code, message } | Terminal error — pipeline stopped. Inspect code for retry guidance. |
See Streaming events for the wire format.
#Iterating on an existing app
To send a follow-up prompt to an existing app, post to the chat that owns it:
const stream = client.chats.sendStream({
chatId: app.chatId,
prompt: 'Add a FAQ section above the footer',
});
for await (const event of stream) {
if (event.type === 'file') console.log('rewrote', event.path);
if (event.type === 'ready') console.log('preview', event.previewUrl);
}#Cancelling a run
Pass an AbortController (or context.Context in Go) and call abort to stop the stream. The server-side build is cancelled and quota is partially refunded if cancellation happens before the code-agent stage.
const ac = new AbortController();
setTimeout(() => ac.abort(), 30_000); // 30s timeout
const stream = client.apps.generateStream(
{ prompt: '...' },
{ signal: ac.signal },
);#Where to go next
PromptFloe developer docs