Generate experiences with Puck AI
Read docs
API ReferenceData ModelAIPart

AIPart

AI Parts represent discrete chunks of data sent by Puck AI. They are produced via generate’s onPart callback.

Types

A part is an object with a type, each with a different shape:

  • data-tool-status: What the agent is doing
  • data-client-request: Something the agent needs answered
  • data-page: The final page. Always the last part
  • data-build-op: A change to the page

data-tool-status

ParamExampleType
typetype: "data-tool-status"”data-tool-status”
data.toolCallIdtoolCallId: "call_abc123"String
data.statusstatus: { label: "Updating page", loading: true }ToolStatus

ToolStatus

ParamExampleType
labellabel: "Updating page"String
loadingloading: trueBoolean
summarysummary: "Added a hero"String?
errorerror: { message: "..." }Object?

data-client-request

A request for data from the agent.

ParamExampleType
typetype: "data-client-request"”data-client-request”
data.requestIdrequestId: "creq_123"String
data.actionaction: "takeScreenshot""getPageData" | "takeScreenshot"
data.paramsparams: { putUrl: "https://..." }Object

getPageData

A request for the current page data. This allows the model to make further adjustments if the page has changed since the request was first made.

Takes the shape:

ParamExampleType
idid: "current"String

Respond with Data.

takeScreenshot

A request for a screenshot of the page. Takes the shape:

ParamExampleType
putUrlputUrl: "https://..."String

Upload the screenshot to the URL using the PUT method, then respond with:

ParamExampleTypeStatus
sizeBytessizeBytes: 1024NumberRequired

For example:

{ "sizeBytes": 1024 }

data-page

The final page. Always the last part.

ParamExampleType
typetype: "data-page"”data-page”
datadata: { root: {}, content: [] }Data

data-build-op

A change to the page. Pass it to applyPart() to apply the change to a page in Puck.

ParamExampleType
typetype: "data-build-op"”data-build-op”
datadata: {}Object