MediFlow — API Documentation

Quick reference for integrating with the Clinical Agent API.
Base URL
When deployed, the base URL is: https://mediflow-ai-medical-assistant-785629432566.us-central1.run.app

Available endpoints

Path Method Purpose
/ or /index.html GET Serves the main chat UI (HTML).
/data/patients.json GET Returns bundled dummy patient data (JSON).
/api/patients GET API-style endpoint returning the same patient JSON.
/api/health GET Health check; returns a small JSON status object.
/api/chat POST Send a chat message to the clinical agent (returns JSON).
/api/chat/stream POST Streamed responses (SSE-like) from the agent. Clients should parse Server-Sent Events prefixed by data: and handle {"type":"chunk"} and final {"type":"complete"} events.
/api/threads GET Returns available conversation threads (list).
/api/documentation GET Serves this API documentation HTML page.

Examples

/api/health

curl https://mediflow-ai-medical-assistant-785629432566.us-central1.run.app/api/health

Response: { "status": "ok", "message": "Clinical Agent API is running" }

Get patients (JSON)

curl https://mediflow-ai-medical-assistant-785629432566.us-central1.run.app/data/patients.json

      # or API-style
      curl https://mediflow-ai-medical-assistant-785629432566.us-central1.run.app/api/patients

Send chat message (simple request)

POST JSON body: { "message": "Patient has chest pain", "thread_id": null }

curl -X POST https://mediflow-ai-medical-assistant-785629432566.us-central1.run.app/api/chat \
          -H "Content-Type: application/json" \
          -d '{"message":"Patient has chest pain"}'

        # Python (requests)
        import requests
        r = requests.post("https://mediflow-ai-medical-assistant-785629432566.us-central1.run.app/api/chat", json={"message":"Patient has chest pain"})
        print(r.json())

Streamed assistant response

The app exposes a streaming endpoint at /api/chat/stream. The server sends incremental data chunks encoded as newline-delimited JSON prefixed with data: . The client in the UI reads response.body.getReader() and decodes pieces.

// Minimal browser example using fetch and a reader
async function streamChat(message){
  const res = await fetch('/api/chat/stream', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ message })
  });
  const reader = res.body.getReader();
  const decoder = new TextDecoder();
  let full = '';
  while(true){
    const { done, value } = await reader.read();
    if(done) break;
    const chunk = decoder.decode(value, { stream: true });
    // server sends lines like: data: { ... }\n\n
    // parse and handle chunk (UI may show incremental content)
    // see the project's front-end code for a more complete example
  }
}

Notes about streaming

Integration tips

Support

If you need further help integrating the API, email: wsmaisys@gmail.com