The Sully.ai API allows you to turn audio conversations into clinical notes, saving you time and improving your documentation quality. Notes are generated using the API in 3 steps:
Transcribe the conversation audio by uploading a file or streaming audio in real-time.
If you are looking to stream audio for transcription during visits, you will first need to request a token from the API, then open a WebSocket so that you can pass audio and receive transcriptions in real-time.
// Get streaming tokenconst tokenResponse =awaitfetch('https://api.sully.ai/v1/audio/transcriptions/stream/token',{method:'POST',headers:{'X-Api-Key':'your-api-key','X-Account-Id':'your-account-id'}});const{data:{ token }}=await tokenResponse.json();// Connect to WebSocketconst ws =newWebSocket(`wss://api.sully.ai/audio/transcriptions/stream?sample_rate=16000&account_id=${accountId}&api_token=${token}`);// Handle connection eventsws.onopen=()=>console.log("Connected");ws.onerror=(error)=>console.error("WebSocket error:", error);// Send audio dataws.send(JSON.stringify({audio: base64AudioData }));// Receive transcriptionconst transcriptionSegments =[];let segmentIndex =0;ws.onmessage=(event)=>{const data =JSON.parse(event.data);if(data.text){ transcriptionSegments[segmentIndex]= data.text;// isFinal indicates transcription for the current segment is completeif(data.isFinal){ segmentIndex++;}}};
You can generate SOAP notes immediately using Sully’s pre-configured note type.
// Create a SOAP note from a transcriptionconst response =awaitfetch('https://api.sully.ai/v1/notes',{method:'POST',headers:{'X-Api-Key':'your-api-key','X-Account-Id':'your-account-id','Content-Type':'application/json'},body:JSON.stringify({transcript:"I've been feeling really tired lately. How long has this been going on? About two weeks. Let's run some blood tests to check your iron and thyroid levels.",noteType:{type:'soap'}})});const{data:{ noteId }}=await response.json();
If you need a precise note structure that Note Styles aren’t providing, you can instead specify a Note Template. This will allow you to control the fine details of your note formatting such as lists, headers, and section lengths.
// Create a note using a templateconst response =awaitfetch('https://api.sully.ai/v1/notes',{method:'POST',headers:{'X-Api-Key':'your-api-key','X-Account-Id':'your-account-id','Content-Type':'application/json'},body:JSON.stringify({transcript:"I've been feeling really tired lately. How long has this been going on? About two weeks. Let's run some blood tests to check your iron and thyroid levels.",noteType:{type:'note_template'template:{"id":"my-template","title":"My Template","globalPrompt":"Be concise","sections":[// see the Note Template schema for more details]}}})});const{data:{ noteId }}=await response.json();
Notes typically only take a few seconds to generate. You can retrieve your completed note either by polling the notes API or setting up a webhook so that your application may be notified whenever a note or transcription has been completed.
For full webhook setup instructions, follow the Webhooks guide. Once set up, your webhook handler will receive events related to audio transcription and note generation.
You can specify one of our supported BCP47 language tags both when uploading and streaming audio for transcription. Audio which is not in the specified language will be ignored. Or, you can also specify the multi tag as the language for multilingual conversations.
// Transcribe an audio fileconst body =newFormData();body.append('audio', audioBuffer,{filename:'audio.mp3',contentType:'audio/mpeg',});// Transcribe a conversation in US Spanishconst response =awaitfetch('https://api.sully.ai/v1/audio/transcriptions?language=es-US',{method:'POST',headers:{'X-Api-Key':'your-api-key','X-Account-Id':'your-account-id'}, body});const{data:{ transcriptionId }}=await response.json();
If you have additional context programmatically available, you can provide it to Sully’s note creation API so that it can be incorporated into your notes.
date: The date of the patient visit.
patientInfo: High-level patient descriptors including name, date of birth, and gender.
medicationList: A list of known patient medications.
previousNote: A previous note needed as context for this note (e.g. if it is a follow-up).
instructions: Additional instructions for how you’d like the note to be generated.
context: Any additional context you’d like to provide.