Chatmu Agent Streaming API

Implement the AI Agent in your own apps via Server-Sent Events (SSE).

  • Chema Rodriguez
    Author
    by Chema Rodriguez
    17 days ago
  • POST /api/chatmu-streaming

    This endpoint allows you to send a prompt to the Chatmu Agent and receive a real-time streamed response. This is the exact same engine that powers Chatmu.io.


    Request Context

    POST https://chatmu.io/api/chatmu-streaming
    Content-Type: application/json
    Authorization: Bearer YOUR_API_KEY
    
    

    { "message": "What is the demographic profile of Billie Eilish?", "chatId": "uuid-for-memory-optional", "tenantId": "your-workspace-id" }


    Understanding the Stream (Parsing Widgets)

    The response is a standard SSE (Server-Sent Events) stream. You will receive markdown text chunks representing the AI's answer.


    However, the Chatmu Agent does more than text. When it executes analytical tasks, it returns internal JSON blocks so your frontend can render UI Widgets (like bar charts, usage reports, or the planner's tasks). These blocks look like this in the stream:


    [CHATMU_AGENT]{"agent": "usage", "type": "usage_report", "payload": {"cost": x}}[/CHATMU_AGENT]

    How to handle it: Regex match [CHATMU_AGENT](.*?)[/CHATMU_AGENT] to extract the JSON. Depending on the type (e.g., usage_report), you can hide that raw string from the user and instead build a native UI component with the payload data!




    Related Articles