Generative AI

Generated reference for the iPrintessApi methods tagged #ai-api:generative-ai in printess-editor.d.ts. Custom types referenced below (parameter and return shapes) are documented on the Types reference.

canUseClaudeDesign

canUseClaudeDesign(): boolean

Whether the AI design agent is offered on this template: the designer enabled it, and the account has AI credits. Gate the button that calls runDesignAgent on this.

Returns: boolean

generateImage

generateImage(model: iExternalGenImageModel, targetFrameName: string | null, action: Array<iExternalGenImageFollowUpAction>): Promise<{ resultImage: iExternalImage }>

generates AI image with various models

Parameter Type Description
model iExternalGenImageModel
targetFrameName string | null
action Array<iExternalGenImageFollowUpAction>

Returns: Promise<{ resultImage: iExternalImage }>

generateText

generateText(model: iExternalGenTextModel): Promise<{ text: string }>

Generates AI text with an Anthropic or OpenAI model and returns it as { text }. A prompt and optionally images go in, one text comes out: the model has no tools, no skills and no memory of earlier calls, so it can only answer - it can never read or change the template beyond the images you hand it via imageUrls. Consumes AI credits based on the tokens used - images are billed as input tokens.

Parameter Type Description
model iExternalGenTextModel

Returns: Promise<{ text: string }>

getClaudeDesignSettings

getClaudeDesignSettings(): iClaudeDesignSettings | undefined

Returns last persisted Claude design dialog inputs from template properties - what a customizer reopens its own design form with.

Returns: iClaudeDesignSettings | undefined

getImageAiByFrameName

getImageAiByFrameName(frameNameOrTitle: string): iExternalImageAi | null

Returns all AI settings of the image in the given frame: text-to-image and image-edit prompts, models and quality settings, the assign action and the segmentation, background removal and upscale tasks. Prompts are returned as stored, so ${…} placeholders are not evaluated - use getImagePromptByFrameName for the evaluated prompt. Null if the frame is not found or is not an image frame.

Parameter Type Description
frameNameOrTitle string js-name or title of the frame

Returns: iExternalImageAi | null

getImagePromptByFrameName

getImagePromptByFrameName(frameNameOrTitle: string): { prompt: string } | null

Returns the AI prompt of the image currently placed in the given frame, wrapped as { prompt } — the text-to-image prompt, or the image-edit prompt if that is what created it, with any ${…} placeholders evaluated. Null if the frame holds no AI-generated image or the frame is not found.

Parameter Type Description
frameNameOrTitle string js-name or title of the frame

Returns: { prompt: string } | null

runDesignAgent

runDesignAgent(options: iExternalDesignAgentOptions): Promise<void>

Generates a design with the authoring agent and applies it to the loaded template.

Replaces the former runClaudeDesign, which was one non-streaming call that had to produce a correct layout first time. It could not: whether text fits a frame is only knowable by laying it out with print metrics, so every version of it overflowed. The agent writes the design, checks it with its validate query and corrects what that reports.

Resolves when the run has finished and everything it produced has been applied. Progress arrives through onOutput / onStatus; persist the inputs by passing settings.

Parameter Type Description
options iExternalDesignAgentOptions

Returns: Promise<void>