Skip to main content
POST
/
ai
/
v1
/
summaries
Create a clinical summary for a given patient
curl --request POST \
  --url https://api.{workspaceId}.clinia.cloud/ai/v1/summaries \
  --header 'Content-Type: application/json' \
  --data '
{
  "patientId": "<string>",
  "summaryTemplateId": "<string>"
}
'
{
  "data": {
    "type": "text-delta",
    "payload": {
      "sectionTitle": "<string>",
      "sectionIndex": 1,
      "text": "<string>"
    }
  },
  "id": "<string>",
  "event": "<string>"
}
Streaming results are forwarded as Server-Sent Events (SSE) with each event containing a JSON payload.
{
  "event": undefined, // events are never used in this implementation. Prefer differentiating based on data.type instead.
  "data": <json payload>, // This is what you should be parsing, it will often be handled by your SSE client library for you.
  "id": <incremental id>, // This is an incremental id that can be used to ensure correct ordering of events.
}

Possible Payload shapes

There can be multiple text-start events, one per section of the summary template. Each text-start event will be followed by one or more text-delta events with the same sectionTitle and sectionIndex, and eventually a text-end event.
{
  "type": "text-start",
  "payload": {
    "sectionTitle": string,
    "sectionIndex": number,
  }
}
{
  "type": "text-delta",
  "payload": {
    "sectionTitle": string,
    "sectionIndex": number,
    "text": string, // this is a delta, so you should append it to the previous text for this section
  }
}
{
  "type": "text-end",
  "payload": {
    "sectionTitle": string,
    "sectionIndex": number,
  }
}
After all sections have been streamed, there will be a summary-end event indicating that the summary generation workflow has completed. If the status field in the payload is success, the summary has been persisted and can be retrieved with the provided summaryId. If the status is error, the summary generation has failed and the error message will be included in the payload.
{
  "type": "summary-end",
  "payload": {
    "status": "success",
    "summaryId": string,
  }
}

OR

{
  "type": "summary-end",
  "payload": {
    "status": "error",
    "error": string,
  }
}

Example SSE Stream

id: 1
data: {"type":"text-start","payload":{"sectionTitle":"History of Present Illness","sectionIndex":0}}

id: 2
data: {"type":"text-delta","payload":{"text":"Patient reports progressive shortness of breath over 3 days.","sectionTitle":"History of Present Illness","sectionIndex":0}}

id: 3
data: {"type":"text-start","payload":{"sectionTitle":"Medications","sectionIndex":1}}

id: 4
data: {"type":"text-delta","payload":{"text":"Lisinopril 10 mg once daily.","sectionTitle":"Medications","sectionIndex":1}}

id: 5
data: {"type":"text-delta","payload":{"text":"No chest pain, fever, or recent travel were reported.","sectionTitle":"History of Present Illness","sectionIndex":0}}

id: 6
data: {"type":"text-delta","payload":{"text":"Metformin 500 mg twice daily with meals.","sectionTitle":"Medications","sectionIndex":1}}

id: 7
data: {"type":"text-end","payload":{"sectionTitle":"History of Present Illness","sectionIndex":0}}

id: 8
data: {"type":"text-end","payload":{"sectionTitle":"Medications","sectionIndex":1}}

id: 9
data: {"type":"summary-end","payload":{"status":"success","summaryId":"sum_01JABZX3V4Q2P2M41ME6E3FQ7R"}}


Headers

X-User-Id
string

The ID of the user making the request. Used to associate the request with a specific user.

Body

application/json
patientId
string
required

The patient id that we want to create a clinical summary for. This should be the same patient id used during ingestion.

summaryTemplateId
string
required

ID of a summary template. This can be retrieved via GET /summary-templates.

Response

Summary workflow event stream

data
object
required
id
string
event
string