i don’t know about image generation but you can use this to stop on a word
// Check if the stop word is in the output if (output.includes(stopWord)) { output = “The conversation has ended.”; }