curl --request POST \
--url https://api.sully.ai/v1/utils/text-to-json \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'X-Account-Id: <api-key>' \
--data @- <<EOF
{
"text": "Patient is a 45-year-old male presenting with chest pain...",
"schema": {
"type": "object",
"description": "Structured clinical summary extracted from a patient encounter note",
"properties": {
"patientInfo": {
"type": "object",
"description": "Demographic details about the patient mentioned in the note",
"properties": {
"age": {
"type": "number",
"description": "Patient age in years as a number, e.g. 45"
},
"gender": {
"type": "string",
"description": "Patient gender as stated or implied in the note"
},
"allergies": {
"type": [
"array",
"null"
],
"description": "List of documented allergies; null if none mentioned",
"items": {
"type": "string",
"description": "A single allergy (drug, food, or environmental)"
}
}
},
"required": [
"age",
"gender",
"allergies"
]
},
"symptoms": {
"type": "array",
"description": "Active symptoms the patient is currently experiencing or reporting",
"items": {
"type": "string",
"description": "A single symptom in plain language, e.g. 'chest pain'"
}
},
"diagnosis": {
"type": "array",
"description": "Only confirmed diagnoses — do not include suspected or rule-out conditions",
"items": {
"type": "string",
"description": "A single confirmed diagnosis"
}
},
"severityLevel": {
"type": "string",
"description": "Overall clinical severity based on the presenting condition and vitals",
"enum": [
"mild",
"moderate",
"severe",
"critical"
]
},
"notes": {
"type": [
"string",
"null"
],
"description": "Additional clinical notes, provider observations, or contextual information not captured elsewhere"
}
},
"required": [
"patientInfo",
"symptoms",
"diagnosis",
"severityLevel",
"notes"
]
}
}
EOFimport requests
url = "https://api.sully.ai/v1/utils/text-to-json"
payload = {
"text": "Patient is a 45-year-old male presenting with chest pain...",
"schema": {
"type": "object",
"description": "Structured clinical summary extracted from a patient encounter note",
"properties": {
"patientInfo": {
"type": "object",
"description": "Demographic details about the patient mentioned in the note",
"properties": {
"age": {
"type": "number",
"description": "Patient age in years as a number, e.g. 45"
},
"gender": {
"type": "string",
"description": "Patient gender as stated or implied in the note"
},
"allergies": {
"type": ["array", "null"],
"description": "List of documented allergies; null if none mentioned",
"items": {
"type": "string",
"description": "A single allergy (drug, food, or environmental)"
}
}
},
"required": ["age", "gender", "allergies"]
},
"symptoms": {
"type": "array",
"description": "Active symptoms the patient is currently experiencing or reporting",
"items": {
"type": "string",
"description": "A single symptom in plain language, e.g. 'chest pain'"
}
},
"diagnosis": {
"type": "array",
"description": "Only confirmed diagnoses — do not include suspected or rule-out conditions",
"items": {
"type": "string",
"description": "A single confirmed diagnosis"
}
},
"severityLevel": {
"type": "string",
"description": "Overall clinical severity based on the presenting condition and vitals",
"enum": ["mild", "moderate", "severe", "critical"]
},
"notes": {
"type": ["string", "null"],
"description": "Additional clinical notes, provider observations, or contextual information not captured elsewhere"
}
},
"required": ["patientInfo", "symptoms", "diagnosis", "severityLevel", "notes"]
}
}
headers = {
"X-API-Key": "<api-key>",
"X-Account-Id": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-Key': '<api-key>',
'X-Account-Id': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Patient is a 45-year-old male presenting with chest pain...',
schema: {
type: 'object',
description: 'Structured clinical summary extracted from a patient encounter note',
properties: {
patientInfo: {
type: 'object',
description: 'Demographic details about the patient mentioned in the note',
properties: {
age: {type: 'number', description: 'Patient age in years as a number, e.g. 45'},
gender: {type: 'string', description: 'Patient gender as stated or implied in the note'},
allergies: {
type: ['array', 'null'],
description: 'List of documented allergies; null if none mentioned',
items: {type: 'string', description: 'A single allergy (drug, food, or environmental)'}
}
},
required: ['age', 'gender', 'allergies']
},
symptoms: {
type: 'array',
description: 'Active symptoms the patient is currently experiencing or reporting',
items: {
type: 'string',
description: 'A single symptom in plain language, e.g. \'chest pain\''
}
},
diagnosis: {
type: 'array',
description: 'Only confirmed diagnoses — do not include suspected or rule-out conditions',
items: {type: 'string', description: 'A single confirmed diagnosis'}
},
severityLevel: {
type: 'string',
description: 'Overall clinical severity based on the presenting condition and vitals',
enum: ['mild', 'moderate', 'severe', 'critical']
},
notes: {
type: ['string', 'null'],
description: 'Additional clinical notes, provider observations, or contextual information not captured elsewhere'
}
},
required: ['patientInfo', 'symptoms', 'diagnosis', 'severityLevel', 'notes']
}
})
};
fetch('https://api.sully.ai/v1/utils/text-to-json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sully.ai/v1/utils/text-to-json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Patient is a 45-year-old male presenting with chest pain...',
'schema' => [
'type' => 'object',
'description' => 'Structured clinical summary extracted from a patient encounter note',
'properties' => [
'patientInfo' => [
'type' => 'object',
'description' => 'Demographic details about the patient mentioned in the note',
'properties' => [
'age' => [
'type' => 'number',
'description' => 'Patient age in years as a number, e.g. 45'
],
'gender' => [
'type' => 'string',
'description' => 'Patient gender as stated or implied in the note'
],
'allergies' => [
'type' => [
'array',
'null'
],
'description' => 'List of documented allergies; null if none mentioned',
'items' => [
'type' => 'string',
'description' => 'A single allergy (drug, food, or environmental)'
]
]
],
'required' => [
'age',
'gender',
'allergies'
]
],
'symptoms' => [
'type' => 'array',
'description' => 'Active symptoms the patient is currently experiencing or reporting',
'items' => [
'type' => 'string',
'description' => 'A single symptom in plain language, e.g. \'chest pain\''
]
],
'diagnosis' => [
'type' => 'array',
'description' => 'Only confirmed diagnoses — do not include suspected or rule-out conditions',
'items' => [
'type' => 'string',
'description' => 'A single confirmed diagnosis'
]
],
'severityLevel' => [
'type' => 'string',
'description' => 'Overall clinical severity based on the presenting condition and vitals',
'enum' => [
'mild',
'moderate',
'severe',
'critical'
]
],
'notes' => [
'type' => [
'string',
'null'
],
'description' => 'Additional clinical notes, provider observations, or contextual information not captured elsewhere'
]
],
'required' => [
'patientInfo',
'symptoms',
'diagnosis',
'severityLevel',
'notes'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"X-Account-Id: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sully.ai/v1/utils/text-to-json"
payload := strings.NewReader("{\n \"text\": \"Patient is a 45-year-old male presenting with chest pain...\",\n \"schema\": {\n \"type\": \"object\",\n \"description\": \"Structured clinical summary extracted from a patient encounter note\",\n \"properties\": {\n \"patientInfo\": {\n \"type\": \"object\",\n \"description\": \"Demographic details about the patient mentioned in the note\",\n \"properties\": {\n \"age\": {\n \"type\": \"number\",\n \"description\": \"Patient age in years as a number, e.g. 45\"\n },\n \"gender\": {\n \"type\": \"string\",\n \"description\": \"Patient gender as stated or implied in the note\"\n },\n \"allergies\": {\n \"type\": [\n \"array\",\n \"null\"\n ],\n \"description\": \"List of documented allergies; null if none mentioned\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single allergy (drug, food, or environmental)\"\n }\n }\n },\n \"required\": [\n \"age\",\n \"gender\",\n \"allergies\"\n ]\n },\n \"symptoms\": {\n \"type\": \"array\",\n \"description\": \"Active symptoms the patient is currently experiencing or reporting\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single symptom in plain language, e.g. 'chest pain'\"\n }\n },\n \"diagnosis\": {\n \"type\": \"array\",\n \"description\": \"Only confirmed diagnoses — do not include suspected or rule-out conditions\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single confirmed diagnosis\"\n }\n },\n \"severityLevel\": {\n \"type\": \"string\",\n \"description\": \"Overall clinical severity based on the presenting condition and vitals\",\n \"enum\": [\n \"mild\",\n \"moderate\",\n \"severe\",\n \"critical\"\n ]\n },\n \"notes\": {\n \"type\": [\n \"string\",\n \"null\"\n ],\n \"description\": \"Additional clinical notes, provider observations, or contextual information not captured elsewhere\"\n }\n },\n \"required\": [\n \"patientInfo\",\n \"symptoms\",\n \"diagnosis\",\n \"severityLevel\",\n \"notes\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("X-Account-Id", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sully.ai/v1/utils/text-to-json")
.header("X-API-Key", "<api-key>")
.header("X-Account-Id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Patient is a 45-year-old male presenting with chest pain...\",\n \"schema\": {\n \"type\": \"object\",\n \"description\": \"Structured clinical summary extracted from a patient encounter note\",\n \"properties\": {\n \"patientInfo\": {\n \"type\": \"object\",\n \"description\": \"Demographic details about the patient mentioned in the note\",\n \"properties\": {\n \"age\": {\n \"type\": \"number\",\n \"description\": \"Patient age in years as a number, e.g. 45\"\n },\n \"gender\": {\n \"type\": \"string\",\n \"description\": \"Patient gender as stated or implied in the note\"\n },\n \"allergies\": {\n \"type\": [\n \"array\",\n \"null\"\n ],\n \"description\": \"List of documented allergies; null if none mentioned\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single allergy (drug, food, or environmental)\"\n }\n }\n },\n \"required\": [\n \"age\",\n \"gender\",\n \"allergies\"\n ]\n },\n \"symptoms\": {\n \"type\": \"array\",\n \"description\": \"Active symptoms the patient is currently experiencing or reporting\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single symptom in plain language, e.g. 'chest pain'\"\n }\n },\n \"diagnosis\": {\n \"type\": \"array\",\n \"description\": \"Only confirmed diagnoses — do not include suspected or rule-out conditions\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single confirmed diagnosis\"\n }\n },\n \"severityLevel\": {\n \"type\": \"string\",\n \"description\": \"Overall clinical severity based on the presenting condition and vitals\",\n \"enum\": [\n \"mild\",\n \"moderate\",\n \"severe\",\n \"critical\"\n ]\n },\n \"notes\": {\n \"type\": [\n \"string\",\n \"null\"\n ],\n \"description\": \"Additional clinical notes, provider observations, or contextual information not captured elsewhere\"\n }\n },\n \"required\": [\n \"patientInfo\",\n \"symptoms\",\n \"diagnosis\",\n \"severityLevel\",\n \"notes\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sully.ai/v1/utils/text-to-json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["X-Account-Id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Patient is a 45-year-old male presenting with chest pain...\",\n \"schema\": {\n \"type\": \"object\",\n \"description\": \"Structured clinical summary extracted from a patient encounter note\",\n \"properties\": {\n \"patientInfo\": {\n \"type\": \"object\",\n \"description\": \"Demographic details about the patient mentioned in the note\",\n \"properties\": {\n \"age\": {\n \"type\": \"number\",\n \"description\": \"Patient age in years as a number, e.g. 45\"\n },\n \"gender\": {\n \"type\": \"string\",\n \"description\": \"Patient gender as stated or implied in the note\"\n },\n \"allergies\": {\n \"type\": [\n \"array\",\n \"null\"\n ],\n \"description\": \"List of documented allergies; null if none mentioned\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single allergy (drug, food, or environmental)\"\n }\n }\n },\n \"required\": [\n \"age\",\n \"gender\",\n \"allergies\"\n ]\n },\n \"symptoms\": {\n \"type\": \"array\",\n \"description\": \"Active symptoms the patient is currently experiencing or reporting\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single symptom in plain language, e.g. 'chest pain'\"\n }\n },\n \"diagnosis\": {\n \"type\": \"array\",\n \"description\": \"Only confirmed diagnoses — do not include suspected or rule-out conditions\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single confirmed diagnosis\"\n }\n },\n \"severityLevel\": {\n \"type\": \"string\",\n \"description\": \"Overall clinical severity based on the presenting condition and vitals\",\n \"enum\": [\n \"mild\",\n \"moderate\",\n \"severe\",\n \"critical\"\n ]\n },\n \"notes\": {\n \"type\": [\n \"string\",\n \"null\"\n ],\n \"description\": \"Additional clinical notes, provider observations, or contextual information not captured elsewhere\"\n }\n },\n \"required\": [\n \"patientInfo\",\n \"symptoms\",\n \"diagnosis\",\n \"severityLevel\",\n \"notes\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"patientInfo": {
"age": 45,
"gender": "male",
"allergies": null
},
"symptoms": [
"chest pain"
],
"diagnosis": [],
"severityLevel": "moderate",
"notes": null
}
}{
"status": "error",
"data": {
"message": "<string>",
"code": "<string>",
"validationErrors": {}
},
"date": "2023-11-07T05:31:56Z",
"errorType": "<string>"
}{
"message": "<string>"
}{
"status": "error",
"data": {
"message": "<string>",
"code": "<string>",
"validationErrors": {}
},
"date": "2023-11-07T05:31:56Z",
"errorType": "<string>"
}{
"status": "error",
"data": {
"message": "<string>",
"code": "<string>",
"validationErrors": {}
},
"date": "2023-11-07T05:31:56Z",
"errorType": "<string>"
}Transform Text to JSON
Transforms unstructured text into structured JSON according to a provided schema. This utility endpoint extracts specific data patterns from free-form content.
curl --request POST \
--url https://api.sully.ai/v1/utils/text-to-json \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'X-Account-Id: <api-key>' \
--data @- <<EOF
{
"text": "Patient is a 45-year-old male presenting with chest pain...",
"schema": {
"type": "object",
"description": "Structured clinical summary extracted from a patient encounter note",
"properties": {
"patientInfo": {
"type": "object",
"description": "Demographic details about the patient mentioned in the note",
"properties": {
"age": {
"type": "number",
"description": "Patient age in years as a number, e.g. 45"
},
"gender": {
"type": "string",
"description": "Patient gender as stated or implied in the note"
},
"allergies": {
"type": [
"array",
"null"
],
"description": "List of documented allergies; null if none mentioned",
"items": {
"type": "string",
"description": "A single allergy (drug, food, or environmental)"
}
}
},
"required": [
"age",
"gender",
"allergies"
]
},
"symptoms": {
"type": "array",
"description": "Active symptoms the patient is currently experiencing or reporting",
"items": {
"type": "string",
"description": "A single symptom in plain language, e.g. 'chest pain'"
}
},
"diagnosis": {
"type": "array",
"description": "Only confirmed diagnoses — do not include suspected or rule-out conditions",
"items": {
"type": "string",
"description": "A single confirmed diagnosis"
}
},
"severityLevel": {
"type": "string",
"description": "Overall clinical severity based on the presenting condition and vitals",
"enum": [
"mild",
"moderate",
"severe",
"critical"
]
},
"notes": {
"type": [
"string",
"null"
],
"description": "Additional clinical notes, provider observations, or contextual information not captured elsewhere"
}
},
"required": [
"patientInfo",
"symptoms",
"diagnosis",
"severityLevel",
"notes"
]
}
}
EOFimport requests
url = "https://api.sully.ai/v1/utils/text-to-json"
payload = {
"text": "Patient is a 45-year-old male presenting with chest pain...",
"schema": {
"type": "object",
"description": "Structured clinical summary extracted from a patient encounter note",
"properties": {
"patientInfo": {
"type": "object",
"description": "Demographic details about the patient mentioned in the note",
"properties": {
"age": {
"type": "number",
"description": "Patient age in years as a number, e.g. 45"
},
"gender": {
"type": "string",
"description": "Patient gender as stated or implied in the note"
},
"allergies": {
"type": ["array", "null"],
"description": "List of documented allergies; null if none mentioned",
"items": {
"type": "string",
"description": "A single allergy (drug, food, or environmental)"
}
}
},
"required": ["age", "gender", "allergies"]
},
"symptoms": {
"type": "array",
"description": "Active symptoms the patient is currently experiencing or reporting",
"items": {
"type": "string",
"description": "A single symptom in plain language, e.g. 'chest pain'"
}
},
"diagnosis": {
"type": "array",
"description": "Only confirmed diagnoses — do not include suspected or rule-out conditions",
"items": {
"type": "string",
"description": "A single confirmed diagnosis"
}
},
"severityLevel": {
"type": "string",
"description": "Overall clinical severity based on the presenting condition and vitals",
"enum": ["mild", "moderate", "severe", "critical"]
},
"notes": {
"type": ["string", "null"],
"description": "Additional clinical notes, provider observations, or contextual information not captured elsewhere"
}
},
"required": ["patientInfo", "symptoms", "diagnosis", "severityLevel", "notes"]
}
}
headers = {
"X-API-Key": "<api-key>",
"X-Account-Id": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-Key': '<api-key>',
'X-Account-Id': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Patient is a 45-year-old male presenting with chest pain...',
schema: {
type: 'object',
description: 'Structured clinical summary extracted from a patient encounter note',
properties: {
patientInfo: {
type: 'object',
description: 'Demographic details about the patient mentioned in the note',
properties: {
age: {type: 'number', description: 'Patient age in years as a number, e.g. 45'},
gender: {type: 'string', description: 'Patient gender as stated or implied in the note'},
allergies: {
type: ['array', 'null'],
description: 'List of documented allergies; null if none mentioned',
items: {type: 'string', description: 'A single allergy (drug, food, or environmental)'}
}
},
required: ['age', 'gender', 'allergies']
},
symptoms: {
type: 'array',
description: 'Active symptoms the patient is currently experiencing or reporting',
items: {
type: 'string',
description: 'A single symptom in plain language, e.g. \'chest pain\''
}
},
diagnosis: {
type: 'array',
description: 'Only confirmed diagnoses — do not include suspected or rule-out conditions',
items: {type: 'string', description: 'A single confirmed diagnosis'}
},
severityLevel: {
type: 'string',
description: 'Overall clinical severity based on the presenting condition and vitals',
enum: ['mild', 'moderate', 'severe', 'critical']
},
notes: {
type: ['string', 'null'],
description: 'Additional clinical notes, provider observations, or contextual information not captured elsewhere'
}
},
required: ['patientInfo', 'symptoms', 'diagnosis', 'severityLevel', 'notes']
}
})
};
fetch('https://api.sully.ai/v1/utils/text-to-json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sully.ai/v1/utils/text-to-json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Patient is a 45-year-old male presenting with chest pain...',
'schema' => [
'type' => 'object',
'description' => 'Structured clinical summary extracted from a patient encounter note',
'properties' => [
'patientInfo' => [
'type' => 'object',
'description' => 'Demographic details about the patient mentioned in the note',
'properties' => [
'age' => [
'type' => 'number',
'description' => 'Patient age in years as a number, e.g. 45'
],
'gender' => [
'type' => 'string',
'description' => 'Patient gender as stated or implied in the note'
],
'allergies' => [
'type' => [
'array',
'null'
],
'description' => 'List of documented allergies; null if none mentioned',
'items' => [
'type' => 'string',
'description' => 'A single allergy (drug, food, or environmental)'
]
]
],
'required' => [
'age',
'gender',
'allergies'
]
],
'symptoms' => [
'type' => 'array',
'description' => 'Active symptoms the patient is currently experiencing or reporting',
'items' => [
'type' => 'string',
'description' => 'A single symptom in plain language, e.g. \'chest pain\''
]
],
'diagnosis' => [
'type' => 'array',
'description' => 'Only confirmed diagnoses — do not include suspected or rule-out conditions',
'items' => [
'type' => 'string',
'description' => 'A single confirmed diagnosis'
]
],
'severityLevel' => [
'type' => 'string',
'description' => 'Overall clinical severity based on the presenting condition and vitals',
'enum' => [
'mild',
'moderate',
'severe',
'critical'
]
],
'notes' => [
'type' => [
'string',
'null'
],
'description' => 'Additional clinical notes, provider observations, or contextual information not captured elsewhere'
]
],
'required' => [
'patientInfo',
'symptoms',
'diagnosis',
'severityLevel',
'notes'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"X-Account-Id: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sully.ai/v1/utils/text-to-json"
payload := strings.NewReader("{\n \"text\": \"Patient is a 45-year-old male presenting with chest pain...\",\n \"schema\": {\n \"type\": \"object\",\n \"description\": \"Structured clinical summary extracted from a patient encounter note\",\n \"properties\": {\n \"patientInfo\": {\n \"type\": \"object\",\n \"description\": \"Demographic details about the patient mentioned in the note\",\n \"properties\": {\n \"age\": {\n \"type\": \"number\",\n \"description\": \"Patient age in years as a number, e.g. 45\"\n },\n \"gender\": {\n \"type\": \"string\",\n \"description\": \"Patient gender as stated or implied in the note\"\n },\n \"allergies\": {\n \"type\": [\n \"array\",\n \"null\"\n ],\n \"description\": \"List of documented allergies; null if none mentioned\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single allergy (drug, food, or environmental)\"\n }\n }\n },\n \"required\": [\n \"age\",\n \"gender\",\n \"allergies\"\n ]\n },\n \"symptoms\": {\n \"type\": \"array\",\n \"description\": \"Active symptoms the patient is currently experiencing or reporting\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single symptom in plain language, e.g. 'chest pain'\"\n }\n },\n \"diagnosis\": {\n \"type\": \"array\",\n \"description\": \"Only confirmed diagnoses — do not include suspected or rule-out conditions\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single confirmed diagnosis\"\n }\n },\n \"severityLevel\": {\n \"type\": \"string\",\n \"description\": \"Overall clinical severity based on the presenting condition and vitals\",\n \"enum\": [\n \"mild\",\n \"moderate\",\n \"severe\",\n \"critical\"\n ]\n },\n \"notes\": {\n \"type\": [\n \"string\",\n \"null\"\n ],\n \"description\": \"Additional clinical notes, provider observations, or contextual information not captured elsewhere\"\n }\n },\n \"required\": [\n \"patientInfo\",\n \"symptoms\",\n \"diagnosis\",\n \"severityLevel\",\n \"notes\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("X-Account-Id", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sully.ai/v1/utils/text-to-json")
.header("X-API-Key", "<api-key>")
.header("X-Account-Id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Patient is a 45-year-old male presenting with chest pain...\",\n \"schema\": {\n \"type\": \"object\",\n \"description\": \"Structured clinical summary extracted from a patient encounter note\",\n \"properties\": {\n \"patientInfo\": {\n \"type\": \"object\",\n \"description\": \"Demographic details about the patient mentioned in the note\",\n \"properties\": {\n \"age\": {\n \"type\": \"number\",\n \"description\": \"Patient age in years as a number, e.g. 45\"\n },\n \"gender\": {\n \"type\": \"string\",\n \"description\": \"Patient gender as stated or implied in the note\"\n },\n \"allergies\": {\n \"type\": [\n \"array\",\n \"null\"\n ],\n \"description\": \"List of documented allergies; null if none mentioned\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single allergy (drug, food, or environmental)\"\n }\n }\n },\n \"required\": [\n \"age\",\n \"gender\",\n \"allergies\"\n ]\n },\n \"symptoms\": {\n \"type\": \"array\",\n \"description\": \"Active symptoms the patient is currently experiencing or reporting\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single symptom in plain language, e.g. 'chest pain'\"\n }\n },\n \"diagnosis\": {\n \"type\": \"array\",\n \"description\": \"Only confirmed diagnoses — do not include suspected or rule-out conditions\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single confirmed diagnosis\"\n }\n },\n \"severityLevel\": {\n \"type\": \"string\",\n \"description\": \"Overall clinical severity based on the presenting condition and vitals\",\n \"enum\": [\n \"mild\",\n \"moderate\",\n \"severe\",\n \"critical\"\n ]\n },\n \"notes\": {\n \"type\": [\n \"string\",\n \"null\"\n ],\n \"description\": \"Additional clinical notes, provider observations, or contextual information not captured elsewhere\"\n }\n },\n \"required\": [\n \"patientInfo\",\n \"symptoms\",\n \"diagnosis\",\n \"severityLevel\",\n \"notes\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sully.ai/v1/utils/text-to-json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["X-Account-Id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Patient is a 45-year-old male presenting with chest pain...\",\n \"schema\": {\n \"type\": \"object\",\n \"description\": \"Structured clinical summary extracted from a patient encounter note\",\n \"properties\": {\n \"patientInfo\": {\n \"type\": \"object\",\n \"description\": \"Demographic details about the patient mentioned in the note\",\n \"properties\": {\n \"age\": {\n \"type\": \"number\",\n \"description\": \"Patient age in years as a number, e.g. 45\"\n },\n \"gender\": {\n \"type\": \"string\",\n \"description\": \"Patient gender as stated or implied in the note\"\n },\n \"allergies\": {\n \"type\": [\n \"array\",\n \"null\"\n ],\n \"description\": \"List of documented allergies; null if none mentioned\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single allergy (drug, food, or environmental)\"\n }\n }\n },\n \"required\": [\n \"age\",\n \"gender\",\n \"allergies\"\n ]\n },\n \"symptoms\": {\n \"type\": \"array\",\n \"description\": \"Active symptoms the patient is currently experiencing or reporting\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single symptom in plain language, e.g. 'chest pain'\"\n }\n },\n \"diagnosis\": {\n \"type\": \"array\",\n \"description\": \"Only confirmed diagnoses — do not include suspected or rule-out conditions\",\n \"items\": {\n \"type\": \"string\",\n \"description\": \"A single confirmed diagnosis\"\n }\n },\n \"severityLevel\": {\n \"type\": \"string\",\n \"description\": \"Overall clinical severity based on the presenting condition and vitals\",\n \"enum\": [\n \"mild\",\n \"moderate\",\n \"severe\",\n \"critical\"\n ]\n },\n \"notes\": {\n \"type\": [\n \"string\",\n \"null\"\n ],\n \"description\": \"Additional clinical notes, provider observations, or contextual information not captured elsewhere\"\n }\n },\n \"required\": [\n \"patientInfo\",\n \"symptoms\",\n \"diagnosis\",\n \"severityLevel\",\n \"notes\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"patientInfo": {
"age": 45,
"gender": "male",
"allergies": null
},
"symptoms": [
"chest pain"
],
"diagnosis": [],
"severityLevel": "moderate",
"notes": null
}
}{
"status": "error",
"data": {
"message": "<string>",
"code": "<string>",
"validationErrors": {}
},
"date": "2023-11-07T05:31:56Z",
"errorType": "<string>"
}{
"message": "<string>"
}{
"status": "error",
"data": {
"message": "<string>",
"code": "<string>",
"validationErrors": {}
},
"date": "2023-11-07T05:31:56Z",
"errorType": "<string>"
}{
"status": "error",
"data": {
"message": "<string>",
"code": "<string>",
"validationErrors": {}
},
"date": "2023-11-07T05:31:56Z",
"errorType": "<string>"
}Authorizations
Required together with the other Sully authentication header.
Required together with the other Sully authentication header.
Body
Text and schema for transformation
Request payload for transforming unstructured text into structured JSON
Unstructured text to transform
"Patient is a 45-year-old male presenting with chest pain..."
JSON Schema defining the structure to extract from the text. Use description fields on properties to guide the model — they act as extraction instructions (e.g. "only include confirmed diagnoses, not suspected ones").
{
"type": "object",
"description": "Structured clinical summary extracted from a patient encounter note",
"properties": {
"patientInfo": {
"type": "object",
"description": "Demographic details about the patient mentioned in the note",
"properties": {
"age": {
"type": "number",
"description": "Patient age in years as a number, e.g. 45"
},
"gender": {
"type": "string",
"description": "Patient gender as stated or implied in the note"
},
"allergies": {
"type": ["array", "null"],
"description": "List of documented allergies; null if none mentioned",
"items": {
"type": "string",
"description": "A single allergy (drug, food, or environmental)"
}
}
},
"required": ["age", "gender", "allergies"]
},
"symptoms": {
"type": "array",
"description": "Active symptoms the patient is currently experiencing or reporting",
"items": {
"type": "string",
"description": "A single symptom in plain language, e.g. 'chest pain'"
}
},
"diagnosis": {
"type": "array",
"description": "Only confirmed diagnoses — do not include suspected or rule-out conditions",
"items": {
"type": "string",
"description": "A single confirmed diagnosis"
}
},
"severityLevel": {
"type": "string",
"description": "Overall clinical severity based on the presenting condition and vitals",
"enum": ["mild", "moderate", "severe", "critical"]
},
"notes": {
"type": ["string", "null"],
"description": "Additional clinical notes, provider observations, or contextual information not captured elsewhere"
}
},
"required": [
"patientInfo",
"symptoms",
"diagnosis",
"severityLevel",
"notes"
]
}
Response
JSON data extracted from text
Response containing the structured JSON data extracted from text
Extracted structured data that conforms to the provided schema
{
"patientInfo": {
"age": 45,
"gender": "male",
"allergies": null
},
"symptoms": ["chest pain"],
"diagnosis": [],
"severityLevel": "moderate",
"notes": null
}