Send Message
curl --request POST \
--url https://api.example.com/api/agents/{agentId}/chat \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>",
"threadId": "<string>",
"stream": true,
"attachments": [
{}
]
}
'import requests
url = "https://api.example.com/api/agents/{agentId}/chat"
payload = {
"message": "<string>",
"threadId": "<string>",
"stream": True,
"attachments": [{}]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', threadId: '<string>', stream: true, attachments: [{}]})
};
fetch('https://api.example.com/api/agents/{agentId}/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/agents/{agentId}/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'threadId' => '<string>',
'stream' => true,
'attachments' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/agents/{agentId}/chat"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"threadId\": \"<string>\",\n \"stream\": true,\n \"attachments\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/agents/{agentId}/chat")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"threadId\": \"<string>\",\n \"stream\": true,\n \"attachments\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/agents/{agentId}/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"threadId\": \"<string>\",\n \"stream\": true,\n \"attachments\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"400": {},
"401": {},
"403": {},
"404": {},
"message": "<string>",
"model": "<string>",
"tokensUsed": {},
"ragChunksUsed": 123
}Chat
Send Message
POST
/
api
/
agents
/
{agentId}
/
chat
Send Message
curl --request POST \
--url https://api.example.com/api/agents/{agentId}/chat \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>",
"threadId": "<string>",
"stream": true,
"attachments": [
{}
]
}
'import requests
url = "https://api.example.com/api/agents/{agentId}/chat"
payload = {
"message": "<string>",
"threadId": "<string>",
"stream": True,
"attachments": [{}]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', threadId: '<string>', stream: true, attachments: [{}]})
};
fetch('https://api.example.com/api/agents/{agentId}/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/agents/{agentId}/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'threadId' => '<string>',
'stream' => true,
'attachments' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/agents/{agentId}/chat"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"threadId\": \"<string>\",\n \"stream\": true,\n \"attachments\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/agents/{agentId}/chat")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"threadId\": \"<string>\",\n \"stream\": true,\n \"attachments\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/agents/{agentId}/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"threadId\": \"<string>\",\n \"stream\": true,\n \"attachments\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"400": {},
"401": {},
"403": {},
"404": {},
"message": "<string>",
"model": "<string>",
"tokensUsed": {},
"ragChunksUsed": 123
}Description
Send a message to an agent and receive a response.Authentication
Required (API key or JWT token)Path Parameters
string
required
The ID of the agent to chat with
Request Body
string
required
The message to send to the agent
string
Optional thread ID for conversation continuity
boolean
Whether to stream the response (default: false)
array
Optional file attachments
Response
string
The agent’s response message
string
The AI model used
object
Token usage statistics (prompt, completion, total)
number
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
Whenstream: true, the response is sent as Server-Sent Events (SSE):
data: {"chunk": "Hello"}
data: {"chunk": "!"}
data: {"chunk": " How"}
data: [DONE]
Error Responses
object
Bad Request - Missing message or invalid parameters
object
Unauthorized - Invalid or missing authentication
object
Forbidden - No access to this agent
object
Not Found - Agent not found
Was this page helpful?
⌘I