Chat API
Send messages to agents and receive responses via the Chat API.
POST
/agents/:id/chatSend a message to an agent and receive a response.
Request Body
JSON
{
"message": "What's the weather like today?"
}Response
200 OK
{
"response": "I can help you find weather information. What city are you interested in?",
"agent_id": "abc123",
"agent_name": "My Assistant"
}POST
/agents/:id/chat/streamSend a message and receive a streaming response using Server-Sent Events (SSE).
Example
JavaScript
const response = await fetch('/api/agents/abc123/chat/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'Hello!' }),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') break;
console.log(data); // Print each token
}
}
}GET
/agents/:id/historyRetrieve conversation history with an agent.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 20 | Number of messages to return |
Response
200 OK
{
"messages": [
{
"role": "user",
"content": "Hello!",
"created_at": "2026-02-14T10:00:00Z"
},
{
"role": "assistant",
"content": "Hi there! How can I help you today?",
"created_at": "2026-02-14T10:00:01Z"
}
]
}SSE Chunk Format
Each SSE event contains a JSON object with a type field:
SSE Events
data: {"type":"text","content":"Hello"}
data: {"type":"text","content":" there!"}
data: {"type":"done","content":""}
data: [DONE]POST
/teams/:id/chatSend a message to a team of agents. All agents respond based on the selected chat mode.
Request Body
JSON
{
"message": "Brainstorm startup ideas",
"mode": "brainstorm"
}Response
200 OK
{
"responses": [
{"agent_id": "a1", "agent_name": "Researcher", "content": "..."},
{"agent_id": "a2", "agent_name": "Analyst", "content": "..."}
],
"summary": "The team identified several promising ideas...",
"mode": "brainstorm"
}Conversation Management
Organize chats into separate conversations per agent.
GET
/agents/:id/conversationsList conversationsPOST
/agents/:id/conversationsCreate new conversationPUT
/agents/:id/conversations/:conv_idUpdate conversation (rename)DELETE
/agents/:id/conversations/:conv_idDelete conversation and messagesGET
/agents/:id/inboxGet unread inbox messagesPOST
/agents/:id/mark-readMark messages as read