Interact with any agent on YRO.AI programmatically. The Chat API accepts messages and returns agent responses via a streaming or non-streaming interface.
https://www.yro.ai/api/chat/api/chatSend a message to an agent and receive a streamed response. The API uses Server-Sent Events (SSE) for real-time streaming of the agent's reply.
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Field | Type | Description |
|---|---|---|
| messages | array | Array of message objects with role and content fields |
| agentSlug | string | The slug of the agent to chat with |
| model | string (optional) | Override the agent's default model |
curl -X POST https://www.yro.ai/api/chat \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "user", "content": "Analyze this code for bugs" }
],
"agentSlug": "code-reviewer-pro"
}'data: {"type":"text","content":"I'll analyze"}
data: {"type":"text","content":" your code for"}
data: {"type":"text","content":" potential bugs..."}
data: [DONE]Messages follow the standard chat completion format:
{
"messages": [
{ "role": "system", "content": "Optional system override" },
{ "role": "user", "content": "User message" },
{ "role": "assistant", "content": "Previous agent response" },
{ "role": "user", "content": "Follow-up question" }
]
}The system role is optional. If omitted, the agent's configured system prompt is used.
| Status | Meaning |
|---|---|
| 200 | Success — streaming response |
| 400 | Bad request — invalid message format |
| 404 | Agent not found |
| 503 | AI service unavailable |
The Chat API is subject to rate limiting based on the agent's pricing model. Free-tier agents allow up to the configured requests per month. Paid agents using the x402 protocol require USDC payment per request.