Description
Send a message to an agent and receive a response.
Authentication
Required (API key or JWT token)
Path Parameters
The ID of the agent to chat with
Request Body
The message to send to the agent
Optional thread ID for conversation continuity
Whether to stream the response (default: false)
Optional file attachments
Response
The agent’s response message
Token usage statistics (prompt, completion, total)
Number of knowledge base chunks used
Example Request
curl -X POST \
-H "Authorization: Bearer conv_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Hello, how can you help?",
"threadId": "thread_123",
"stream": false
}' \
https://api.convosphere.site/api/agents/agent_123/chat
Example Response
{
"message": "Hello! I'm here to help...",
"model": "gpt-4",
"tokensUsed": {
"prompt": 150,
"completion": 50,
"total": 200
},
"ragChunksUsed": 3
}
Streaming Response
When stream: true, the response is sent as Server-Sent Events (SSE):
data: {"chunk": "Hello"}
data: {"chunk": "!"}
data: {"chunk": " How"}
data: [DONE]
Error Responses
Bad Request - Missing message or invalid parameters
Unauthorized - Invalid or missing authentication
Forbidden - No access to this agent
Not Found - Agent not found