Skip to main content
Use AI streaming when a website or support surface should show the AI answer as it is generated.
POST /api/v1/connect/ai-stream
The response uses server-sent events.

Request

curl "https://api.plato.ae/api/v1/connect/ai-stream" \
  -X POST \
  -H "Authorization: Bearer $PLATO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "ai_agent_id",
    "conversationId": "conversation_id",
    "lastMessageId": "message_id"
  }'

Body

{
  agentId: string;
  conversationId: string;
  channelId?: string | null;
  lastMessageId?: string | null;
  senderId?: string | null;
}
senderId is required unless Plato can read it from lastMessageId. channelId is optional when the conversation already has a channel or the last message has a channel.

Events

The stream sends data: events. Delta event:
{
  "type": "delta",
  "delta": "Hello",
  "text": "Hello"
}
Done event:
{
  "type": "done",
  "messageId": "message_id",
  "text": "Hello, how can I help?"
}
Error event:
{
  "type": "error",
  "error": "Conversation not found."
}

Browser Example

const response = await fetch("https://api.plato.ae/api/v1/connect/ai-stream", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    agentId: "ai_agent_id",
    conversationId: "conversation_id",
    lastMessageId: "message_id",
  }),
});

const reader = response.body?.getReader();
For public websites, call this endpoint from your backend when possible. Do not expose long-lived API keys in browser code.

Permission

AI streaming requires:
connect360:conversation:engage