Skip to main content
Follow these steps to get access and start building:
1

Starting from a clean slate

To install the Corti SDK you can use Node Package Manager (npm) in a terminal of your choosing:
  1. Install Node.js and npm (detailed instructions available here)
  2. Open a terminal and run npm install @corti/sdk
  3. Start using the JavaScript SDK!
View the package details and latest version on npm.
To check if you have npm installed, run npm -v and a version number should be returned. If it fails, then reinstall npm from the link above or try restarting your computer.
Before making requests, you’ll need to set up a CortiClient. This handles authentication with the Corti API.If you already have client credentials for your API project, you can initialize the client like this:
import { CortiEnvironment, CortiClient } from "@corti/sdk";

new CortiClient({
    environment: CortiEnvironment.Eu,
    auth: {
        clientId: CLIENT_ID,
        clientSecret: CLIENT_SECRET
    },
    tenantName: TENANT
}); 
Still need to create an API project and client credentials? Learn more here!

2

Authentication

Authentication is governed by OAuth 2.0 using client credentials grant type. This authentication protocol offers enhanced security measures, ensuring that access to patient data and medical documentation is securely managed and compliant with healthcare regulations.
The client credentials flow shown below is intended for backend/server-side applications only. For frontend applications, you should use access tokens instead of exposing client secrets. See the Authentication Guide for frontend authentication patterns.
  1. Obtain your API client credentials from the Corti API Console.
  2. Add the client_id and client_secret to your project.
    import { CortiEnvironment, CortiClient } from "@corti/sdk";
    
    new CortiClient({
        environment: CortiEnvironment.Eu,
        auth: {
            clientId: CLIENT_ID,
            clientSecret: CLIENT_SECRET
        },
        tenantName: TENANT
    });
    
  3. Start making API calls and requests from this client!
For best performance, create a single CortiClient instance and reuse it throughout your application. Avoid re-initializing a new client for every request.
Click here to read more about how to appropriately use OAuth for your workflow needs and proper handling of client_secret.
For comprehensive authentication examples and advanced configuration options, see the Authentication Guide in the SDK repository.
3

Testing your client

JavaScript code example of using the client to authenticate and create an interaction:
Creating an interaction
import { CortiEnvironment, CortiClient } from "@corti/sdk";

const client = new CortiClient({
    environment: CortiEnvironment.Eu,
    auth: {
        clientId: CLIENT_ID,
        clientSecret: CLIENT_SECRET
    },
    tenantName: TENANT
});
  
const { interactionId } = await client.interactions.create({
    encounter: {
        identifier: "YOUR_IDENTIFIER",
        status: "planned",
        type: "first_consultation"
    }
});
Find the full specification for create interaction request in the API Reference

4

Building a complete workflow

Goal: Integrate with Corti SDK to enable an ambient documentation, AI scribe applicationWorkflow:
  1. Upload recording
  2. Transcribe recording
  3. Generate documentation
  4. Fetch the documentation
The first step will be to create an interaction, as shown above. Once you’ve created your interaction, the interaction ID can be used for the steps that follow below.
See more details about this workflow here and the full API specifications here.
1

Upload a recording

Here is where you use the interaction ID.
upload recording
await client.recordings.upload(file, "INTERACTION ID");
Create a helper function to upload a recording:
full function
import { createReadStream } from "fs";

async function uploadRecording(client, interactionId, filePath){
    const file = createReadStream(filePath, {autoClose: true});
    return client.recordings.upload(file, interactionId);
}
The createReadStream import is used to create a readable stream from a file path.Find the full specification for uploading a recording in the API reference.
2

Generate a transcript

Here you’ll need the interactionId as well as the recordingId returned from the upload response.
Generate a transcript
const { recordingId } = await uploadRecording(client, interactionId, "sample.mp3") 
const transcript = await client.transcripts.create(interactionId, {
    recordingId: recordingId,
    primaryLanguage: "en"
});
Find the full specification for generating a transcript in the API reference
3

Generating a document

Here you need the interactionId and transcript text (transcript) from the previous step.
Generate a Document
const document = await client.documents.create(interactionId, {
    context: [{
        type: "string",
        data: transcript.transcripts.map(t => t.text).join(" "),
    }],
    templateKey: "soap",
    outputLanguage: "en",
});
Find the full specification for generating a document in the API reference
4

Retrieving the document

If you need to retrieve a generated document again or at a later time (since the create call already returns the document), you can do so using the interactionId and documentId from the previous step.
Get a Document
await client.documents.get("INTERACTION ID", "DOCUMENT ID");
Find the full specification for retrieving a document in the API reference
import { CortiEnvironment, CortiClient } from "@corti/sdk";
import dotenv from "dotenv";
import fs from "fs";

dotenv.config();

const { CLIENT_ID, CLIENT_SECRET, TENANT_NAME: TENANT } = process.env;

const client = new CortiClient({
    environment: CortiEnvironment.Eu,
    auth: { clientId: CLIENT_ID, clientSecret: CLIENT_SECRET },
    tenantName: TENANT,
});

const { interactionId } = await client.interactions.create({
    encounter: {
        identifier: "GUID OF YOUR CHOOSING",
        status: "planned",
        type: "first_consultation",
    },
});

const { recordingId } = await client.recordings.upload(
    fs.createReadStream("sample.mp3", { autoClose: true }),
    interactionId
);

const transcript = await client.transcripts.create(interactionId, {
    recordingId,
    primaryLanguage: "en"
});

const document = await client.documents.create(interactionId, {
    context: [{ 
        type: "string",
        data: transcript.transcripts.map(t => t.text).join(" "),
    }],
    templateKey: "soap",
    outputLanguage: "en",
});

console.log(document.name);
The dotenv import loads environment variables from a .env file. This keeps sensitive values like your client ID and client secret out of your source code, which is considered best practice.

Additional Resources

For support or questions, please reach out via help.corti.ai.
To get access to Corti API click here to sign up
I