Chat
Send a message to your agent and get a response. Your agent will use its configured personality, knowledge base, and available commands to generate contextual responses.
POST /v1/agents/:agentId/chat Try it
Authorizations
x-api-key string header required
API key authentication. Provide your API key as the header value.
Path Parameters
agentId string required
The unique identifier of your agent. You can find this in your agent dashboard.
Body application/json
message string required
The message to send to the agent.
Maximum length: 10000
conversationHistory array optional
Array of previous messages to provide context for the conversation. Each message should have a role ("user" or "assistant") and content field.
Example:
[
{
"role": "user",
"content": "What's the weather like?"
},
{
"role": "assistant",
"content": "I can check the weather for you. What location?"
}
]
toolsEnabled boolean optional default: false
Whether to allow the agent to use tools (execute commands) during the conversation. Defaults to false for safety.
⚠️ Warning: If your webhook calls this API with
toolsEnabled: true, you can create a recursive loop that rapidly drains your AI credits. Only enable if you specifically need the agent to execute commands, and ensure your webhooks usetoolsEnabled: false.
maxToolCalls number optional default: 5
Maximum number of tool calls allowed when toolsEnabled is true. Must be between 0 and 10. This is a hard limit to prevent runaway loops.
Response
200 application/json
Successfully sent message and received response
{
"success": true,
"data": {
"response": "The agent's response text",
"agentId": "0e92bfc9-0114-4de3-8ba9-035d44928809",
"timestamp": "2024-01-01T00:00:00.000Z"
}
}
400 application/json
Invalid request parameters
{
"error": {
"message": "Message is required",
"code": "validation_error"
}
}
401 application/json
Invalid or missing API key
{
"error": {
"message": "Invalid API key",
"code": "unauthorized"
}
}
404 application/json
Agent not found
{
"error": {
"message": "Agent not found",
"code": "not_found"
}
}
Code Examples
cURL
curl --request POST \
--url https://public-developers.memeputer.com/v1/agents/YOUR_AGENT_ID/chat \
--header 'x-api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"message": "Hello! How are you?",
"conversationHistory": []
}'
JavaScript/TypeScript
const response = await fetch(
"https://public-developers.memeputer.com/v1/agents/YOUR_AGENT_ID/chat",
{
method: "POST",
headers: {
"x-api-key": "<api-key>",
"Content-Type": "application/json",
},
body: JSON.stringify({
message: "Hello! How are you?",
conversationHistory: [],
}),
},
);
const data = await response.json();
console.log(data.data.response);
Python
import requests
response = requests.post(
'https://public-developers.memeputer.com/v1/agents/YOUR_AGENT_ID/chat',
headers={
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
json={
'message': 'Hello! How are you?',
'conversationHistory': []
}
)
data = response.json()
print(data['data']['response'])