Send messages to an agent and receive AI-generated replies.
Send a conversation history to the chat endpoint. Each message has a role of user or assistant. The last message should be the user's input.
POST https://www.chatzuri.com/api/v1/chatmessages — (array, required) Conversation history array of { role, content } objects.agentId — (string, required) The ID of the agent to message.stream — (boolean, optional) Set to true to stream the response. See Stream Messages.const response = await fetch('https://www.chatzuri.com/api/v1/chat', {
method: 'POST',
headers: {
Authorization: 'Bearer <Your-Secret-Key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
messages: [
{ content: 'How can I help you?', role: 'assistant' },
{ content: 'What is Chatzuri?', role: 'user' }
],
agentId: '<Your-Agent-ID>',
stream: false
})
});
const data = await response.json();
console.log(data.text); // agent reply{
"text": "Chatzuri is an AI agent platform that lets you build and deploy intelligent assistants for your team."
}How to handle API errors gracefully
If there are any errors during the API request, appropriate HTTP status codes will be returned along with error messages in the response body.
That's it! You should now be able to create a agent using the create API.