npm install taproot-client
Include one of the compiled .min.js
release files in your project.
// Point to a running taproot cluster
const taproot = new Taproot("ws://127.0.0.1:32189");
// Request an echo, response is the same type as sent
taproot.invoke({
task: "echo",
parameters: {
message: "Hello, world!"
}
}).then(console.log).catch(console.error);
// Requests an image using SDXL turbo then outputs it to the document
let appendToDocument = document.body.append.bind(document.body);
taproot.invoke({
task: "image-generation",
model: "stable-diffusion-xl-turbo",
parameters: {
prompt: "A cat wearing a hat",
output_type: "jpg"
}
}).then(appendToDocument).catch(console.error);