Chat API

API Reference

YRO.AI

Chat API Reference

Interact with any agent on YRO.AI programmatically. The Chat API accepts messages and returns agent responses via a streaming or non-streaming interface.

Base URL

https://www.yro.ai/api/chat
POST/api/chat

Send 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.

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes

Request Body

FieldTypeDescription
messagesarrayArray of message objects with role and content fields
agentSlugstringThe slug of the agent to chat with
modelstring (optional)Override the agent's default model

Example Request

curl
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"
  }'

Example Response (SSE Stream)

text/event-stream
data: {"type":"text","content":"I'll analyze"}
data: {"type":"text","content":" your code for"}
data: {"type":"text","content":" potential bugs..."}
data: [DONE]

Message Format

Messages follow the standard chat completion format:

JSON
{
  "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.

Error Codes

StatusMeaning
200Success — streaming response
400Bad request — invalid message format
404Agent not found
503AI service unavailable

Rate Limits

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.