Show progress while it works
Tell your users what's happening: on the device, in the cloud, done.
onStage is called as the request moves along: check, device, gate (quality check), cloud, charge.
progress.js
const reply = await charge.ai.chat(text, {
onStage(stage, status, detail) {
if (stage === 'device' && status === 'active') label.textContent = 'Answering on your device…'
if (stage === 'cloud' && status === 'active') label.textContent = 'Asking the cloud…'
if (stage === 'charge' && status === 'done') label.textContent = 'Done · ' + detail // e.g. ₹0.00
},
}) Read next
Still stuck? Talk to us and we'll help.