Tools
A template id looks like
tpl_xxxxx.
Find a template
Ask for the templates and their layers:modifications, for example:
headline, price, qr, photo.
Pass layer values
modifications is an object keyed by layer name. A string sets the text of a layer. An object sets that layer’s own fields.
A full example for
create_image:
Read the result
create_image returns the image itself, so the assistant can show it or save it to a file. create_pdf stores the file and returns a link:
Compose an image without a template
Usecreate_image_from_shapes when no template fits. Give the tool a canvas and a list of shapes. It draws the shapes in order and returns the image, so the assistant can design a one-off banner, label, or invoice.
Every shape has type, x, y, width, and height, in pixels from the top left of the canvas. The first shape is at the back and the last is on top.
A few rules:
icontakes an Iconoir name, for examplecheck-circleorarrow-right.srcandcanvas.backgroundImagetake an HTTPS URL or a data URL.canvas.backgroundImagealso takes a CSS gradient, for examplelinear-gradient(to right, #4f46e5, #9333ea).styletakes CSS property names for the rest:padding,boxShadow,borderStyle,lineHeight, and similar. Set the size withwidthandheight, not withstyle.- Table
columnsare the headers androwshold one value per column in the same order. - Limits: 1 to 100 shapes, 16 to 4096 pixels on each side of the canvas, 4000 characters of text, 200 table rows, 12 table columns.
canvas.background is set. canvas.backgroundImage wins over canvas.background.
A full example: an invoice.
Handle errors
A failed tool call returns a message with the error code, using the same codes as the REST API:
See Errors for the full list.