Adds messages output and the chat api call