cURL
curl -X POST https://reygrid.com/api/v1/agents/{AgentId}/chat \
-H "Authorization: Bearer $REYGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Where is my order #1042?", "userId": "user_42"}'from reygrid import ReyGrid
client = ReyGrid(api_key="YOUR_API_KEY")
res = client.chat("{AgentId}", "Where is my order #1042?", user_id="user_42")
print(res.output.reply.content)
# Streaming
for event in client.stream_chat("{AgentId}", "Where is my order #1042?", user_id="user_42"):
print(event.delta.reply.content or "", end="")import { ReyGrid } from "reygrid";
const client = new ReyGrid({ apiKey: "YOUR_API_KEY" });
const res = await client.chat("{AgentId}", "Where is my order #1042?", { userId: "user_42" });
console.log(res.output.reply.content);
// Streaming
for await (const event of client.streamChat("{AgentId}", "Where is my order #1042?", { userId: "user_42" })) {
process.stdout.write(event.delta?.reply?.content ?? "");
}{
"success": true,
"userId": "user_42",
"messageId": "msg_mgGdMG8f9PUjc",
"output": {
"reply": {
"id": "msg_x6tWaZ3H9oOKd",
"content": "Your order #1042 shipped yesterday and should arrive within 2 business days."
},
"finish_reason": "stop"
},
"usage": {
"credits": 0.5
}
}{
"success": false,
"error": {
"code": "INVALID_BODY",
"message": "Invalid body",
"list": {
"message": [
"Message is required"
]
}
}
}{
"error": "Unauthorized",
"code": "AUTH_REQUIRED"
}{
"success": false,
"error": {
"code": "UNKNOWN_ERROR",
"message": "An error occurred"
},
"output": {},
"usage": {
"credits": 0
}
}{
"success": false,
"error": {
"code": "MODERATION_UNAVAILABLE",
"message": "The message couldn't be checked. Try again in a moment."
},
"output": {},
"usage": {
"credits": 0
}
}Chat
Chat with an agent
Sends a message to an agent.
When stream is false, the API returns a normal JSON response.
When stream is true, the API returns a Server-Sent Events (SSE) stream using delta events.
If userId is provided, it is used as the persistent conversation identifier and conversationId is ignored.
POST
/
agents
/
{AgentId}
/
chat
cURL
curl -X POST https://reygrid.com/api/v1/agents/{AgentId}/chat \
-H "Authorization: Bearer $REYGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Where is my order #1042?", "userId": "user_42"}'from reygrid import ReyGrid
client = ReyGrid(api_key="YOUR_API_KEY")
res = client.chat("{AgentId}", "Where is my order #1042?", user_id="user_42")
print(res.output.reply.content)
# Streaming
for event in client.stream_chat("{AgentId}", "Where is my order #1042?", user_id="user_42"):
print(event.delta.reply.content or "", end="")import { ReyGrid } from "reygrid";
const client = new ReyGrid({ apiKey: "YOUR_API_KEY" });
const res = await client.chat("{AgentId}", "Where is my order #1042?", { userId: "user_42" });
console.log(res.output.reply.content);
// Streaming
for await (const event of client.streamChat("{AgentId}", "Where is my order #1042?", { userId: "user_42" })) {
process.stdout.write(event.delta?.reply?.content ?? "");
}{
"success": true,
"userId": "user_42",
"messageId": "msg_mgGdMG8f9PUjc",
"output": {
"reply": {
"id": "msg_x6tWaZ3H9oOKd",
"content": "Your order #1042 shipped yesterday and should arrive within 2 business days."
},
"finish_reason": "stop"
},
"usage": {
"credits": 0.5
}
}{
"success": false,
"error": {
"code": "INVALID_BODY",
"message": "Invalid body",
"list": {
"message": [
"Message is required"
]
}
}
}{
"error": "Unauthorized",
"code": "AUTH_REQUIRED"
}{
"success": false,
"error": {
"code": "UNKNOWN_ERROR",
"message": "An error occurred"
},
"output": {},
"usage": {
"credits": 0
}
}{
"success": false,
"error": {
"code": "MODERATION_UNAVAILABLE",
"message": "The message couldn't be checked. Try again in a moment."
},
"output": {},
"usage": {
"credits": 0
}
}Authorizations
ReyGrid API key sent as a Bearer token.
Path Parameters
The ID of the agent.
Body
application/json
Example:
"Check my current subscription"
Existing conversation ID. Ignored when userId is provided.
Example:
"conv_abc123"
Stable user identifier used to maintain a persistent conversation across platforms such as WhatsApp, Discord, and Telegram.
When provided, conversationId is ignored.
Example:
"user_42"
When true, the response is delivered using Server-Sent Events (SSE) with delta events.
Show child attributes
Show child attributes
Minimum array length:
1Show child attributes
Show child attributes