The input variables type for the canvas
The output result type for individual executions
InternalCreates a new batch builder.
HTTP client for making API requests.
Canvas identification (ID + version or application ID).
Optional batch execution parameters.
Adds one or more items to the batch.
Items without a reference ID will have UUIDs generated automatically. This method can be called multiple times to build up the batch incrementally.
Single item or array of items to add to the batch.
Executes the batch by uploading the input file and creating a batch execution on the server.
Returns a promise-like object that allows flexible usage patterns:
const exec = await batch.execute()const result = await batch.execute().resultThe batch items are serialized to JSONL format, uploaded to vault storage, and submitted to the batch API for processing.
A promise-like object with a result property for direct result access.
// Direct result access (recommended for simple cases)
const result = await batch.execute().result
const outputs = await result.getResults()
// Get execution object for event monitoring
const execution = await batch.execute()
execution.on('statusChange', ([status, response]) => {
console.log(`Status: ${status}`)
if (response.state) {
console.log(`Progress: ${response.state.completed}/${response.state.total}`)
}
})
execution.on('success', (result) => {
console.log('Batch completed!', result.requestId)
})
const result = await execution.result
// Iterate through results
for await (const output of result.iterateResults()) {
console.log(output)
}
Builder class for creating and executing batch operations on a canvas.
The Batch class provides a fluent API for building up a collection of executions to be processed in parallel. Items can be added incrementally, and the batch is executed only when
execute()is called.Usage Pattern
canvas.createBatch()add()method (can be called multiple times)execute()methodReference IDs
Each batch item can have an optional reference ID for later retrieval. If not provided, UUIDs are generated automatically. Reference IDs are useful for correlating results with input data.
Example