PromptFloe Developer Docs
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

  1. Create a chat (or pick an existing one).
  2. POST a prompt to start the build pipeline.
  3. Stream events as the planner, files agent, code agents, and reviewer run.
  4. Receive a ready event with the preview URL.
  5. (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

FieldTypeDescription
promptrequiredstringNatural-language description of what to build.
templatestringOptional starter ID — see Templates docs for the full list.
chatIdstringContinue an existing chat. Omit to create a new one.
augmentersstring[]Augmenter aliases to run sequentially after the build. Examples: ["seo","a11y","pwa"].
workspaceContextOverrideobjectPer-run override of any field in your workspace context (voice, audience, etc.).
modelOverridestringForce a specific model. See Models reference. Falls back to your tier default.

#Event shapes

Every event has a type discriminator. Common types:

FieldTypeDescription
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