Skip to content

Streaming Endpoint API Reference

How does Clair streaming endpoints work?

Unlike a traditional REST API, streaming in the Clair is event-driven and uses SSE under the hood to send tokens to your frontend as soon as they generate. The process is at follow:

  1. You make a request to our server with your query
  2. Our server responds with a query id and a unique streaming channel name
  3. Your frontend using the Clair SDK listens to the events sent to your unique channel for that specific query
  4. As events get generated and sent by our server, your frontend gets notified and receive their content
  5. You don't have to manage websockets or any complicated setup. The Clair SDK manages this for your under the hood
  6. You simply need to
    1. Get a streaming channel id and a query id from our servers via a traditional REST API
    2. Render the contents of the events as they come to your frontend

The integration is possible using any frontend framework or technology. It also works, by simply including the Clair SDK script tag in your html.

We are available to help!

In addition to this documentation Swagger and ReDoc style documentations are available.



Get Clinical Query Streaming Channel

POST https://prod.askclair.ai/api/v1/get-clinical-query-streaming-channel/

The "Get Clinical Query Streaming Channel" endpoint allows you to create a streaming channel for a clinical query. By making a POST request to the endpoint https://prod.askclair.ai/api/v1/get-clinical-query-streaming-channel/, you can initiate the creation of a channel.

In addition to your query, you can supply the following optional flags for additional functionalities.

  • Clinical summary: When set to true, the model will summarize the literature about the topic (drug or disease). Rather than answer a quesstion.
  • override: By default, our model will not answer out of scope questions. When set to true, this will expand the search even if its out of scope.
  • limit: This flag when set to true will limit the response back to 25 words. Helpful when testing or for demos.

Once the request is successful, the API will respond with the channel name and query ID, both of which will be returned with a status code of 200. The channel name and query ID are crucial for listening to the answer, context, and references using our Clair SDK in your frontend application.

To enable streaming in your frontend, you can utilize the Clair SDK library, which can be accessed at the following URL: https://prod.askclair.ai/static/js/galenSDK.min.js.

For a demonstration of how to implement the streaming functionality, you can refer to the example application available on GitHub at https://github.com/Jonathan-Adly/clair_streaming_demo. This example application provides a practical illustration of how to integrate and use the Clair SDK for streaming clinical query results.

Events that will be received and should be handled by your frontend:

  1. start
    • Event data = {"text": "question asked"}
  2. answer
    • Event data = {"text" : "generated tokens"}
  3. answer_done (optional to handle - conveinence event with the full answer in html)
    • Event data = {"text" : "Full answer in HTML"}
  4. context
    • Event data = {"text": "generated tokens"}
  5. references
    • Event data = {"title": "reference title", "doi": "reference doi", "abstract": "reference abstract", "url": "reference url"}
  6. end
    • Event data = {"text": "query_id"}
import requests
token = f"token {your_token}"
url = "https://prod.askclair.ai/api/v1/get-clinical-query-streaming-channel/"
headers = {'Authorization': token, 'Content-Type': 'application/json'}

payload = {
  "query": "string",
  "clinical_summary_mode": false, #optional
  "override": false, #optional
  "limit": false #optional
}

response = requests.post(url, json=payload, headers=headers)
return response.json()
const fetch = require('node-fetch');
const token = `token ${your_token}`;
const url = "https://prod.askclair.ai/api/v1/get-clinical-query-streaming-channel/";

const headers = {
  'Authorization': token,
  'Content-Type': 'application/json'
};

const payload = {
  "query": "string",
  "clinical_summary_mode": false, //optional
  "override": false, //optional
  "limit": false //optional
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl 
-X POST 
-H "Authorization: token YOUR_TOKEN" 
-H "Content-Type: application/json" 
-d '{"query": "string"}' 
https://prod.askclair.ai/api/v1/get-clinical-query-streaming-channel/

This returns two string values. channel_name is the name of the channel and query_id is the query ID.

Response
  {
    "channel_name": "string",
    "query_id": "string"
  }

Here is an example of how to handle the events on your frontend:

<p id="answer"> Answer: </p>
<script src="https://prod.askclair.ai/static/js/galenSDK.min.js"> </script>
<script>
  //call start to start the streaming process
  function start() {
    // channelName and queryID comes from our server after a post request
    clairConnect(channelName, queryID).then(function(channel) {
        channel.bind('start', function(data) {
            console.log("started stream..");
        });
        channel.bind("answer", function (data) {
              let text = data.text;
              document.getElementById("answer").innerHTML += text;
            });
      // handle rest of events
    }).catch(function(error) {
        console.log("Error: " + error);
    });

      // Call the ready to listen function when your are ready to reveive event.
      // note - this function, must be called after the channel is connected.
      clairReadyToListen(channelName, queryID);
}
</script>


Get Query Details

GET https://prod.askclair.ai/api/v1/get-query-details/{query_id}/

The "Get Query Details" endpoint allows you to retrieve the answer, context, and references for a clinical query after the streaming process is completed. To obtain the results, you need to make a GET request to the endpoint https://prod.askclair.ai/api/v1/get-query-details/{query_id}/, where {query_id} represents the unique identifier of the specific query for which you want to retrieve the details.

This endpoint is particularly useful when you have completed the streaming process and need to obtain the final results for a specific query. By using the query ID, you can retrieve the answer, context, and references associated with the clinical query you have previously streamed.

By sending the GET request, the API will respond with the relevant details associated with the specified query. This includes the generated answer, the context or evidence summary, and the references that support the answer.

import requests
url = "https://prod.askclair.ai/api/v1/get-query-details/{query_id}/"
headers = {
"Authorization": "token YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
const fetch = require('node-fetch');
const url = "https://prod.askclair.ai/api/v1/get-query-details/{query_id}/";
const token = "YOUR_TOKEN";

fetch(url,{
headers: {
    "Authorization": `token ${token}`,
    "Content-Type": "application/json"
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl -X GET \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://prod.askclair.ai/api/v1/get-query-details/{query_id}/

Ensure that you replace {query_id} in the URL with the actual query identifier you want to retrieve details for. Once you receive the response, you can process it based on your application's requirements.

Response
  {
  "question": "string",
  "answer": "string",
  "context_summary": "string",
  "references": [
    {
      "abstract": "string",
      "title": "string",
      "link": "http://example.com",
      "doi": "string"
    }
  ],
    "helpful_links": [
      {
      "title": "string",
      "link": "http://example.com",
      }
    ],
    "FDA_monographs": [
      "title": "string",
      "link": "http://example.com",
    ],
    "guidelines": [
      "title": "string",
      "link": "http://example.com",
    ] 
  }

Create Bulk ICD10 Streaming Channel

POST https://prod.askclair.ai/api/v1/create-bulk-icd10-streaming-channel/

The "Create Bulk ICD10 Streaming Channel" endpoint allows you to create a streaming channel for a bulk ICD10 query (up to 5 codes at a time). By making a POST request to the endpoint https://prod.askclair.ai/api/v1/create-bulk-icd10-streaming-channel/, you can initiate the creation of a channel.

Once the request is successful, the API will respond with the channel name and query ID, both of which will be returned with a status code of 200. The channel name and query ID are crucial for listening to the answer using our Clair SDK in your frontend application.

To enable streaming in your frontend, you can utilize the Clair SDK library, which can be accessed at the following URL: https://prod.askclair.ai/static/js/galenSDK.min.js.

For a demonstration of how to implement the streaming functionality, you can refer to the example application available on GitHub at https://github.com/Jonathan-Adly/clair_streaming_demo. This example application provides a practical illustration of how to integrate and use the Clair SDK for streaming clinical query results.

Events that will be received and should be handled by your frontend:

  1. start
    • Event data = {"text": "codes submitted"}
  2. answer
    • Event data = {"text": "generated tokens}
  3. end
    • Event data = {"text: "query id"}
import requests
token = f"token {your_token}"
url = "https://prod.askclair.ai/api/v1/create-bulk-icd10-streaming-channel/"
headers = {'Authorization': token, 'Content-Type': 'application/json'}

payload = {
  "codes": ["string"],  
}

response = requests.post(url, json=payload, headers=headers)
return response.json()
const fetch = require('node-fetch');
const token = `token ${your_token}`;
const url = "https://prod.askclair.ai/api/v1/create-bulk-icd10-streaming-channel/";

const headers = {
  'Authorization': token,
  'Content-Type': 'application/json'
};

const payload = {
  "codes": ["string"],
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl 
-X POST 
-H "Authorization: token YOUR_TOKEN" 
-H "Content-Type: application/json" 
-d '{"codes": ["string"]}' 
https://prod.askclair.ai/api/v1/create-bulk-icd10-streaming-channel/

This returns two string values. channel_name is the name of the channel and query_id is the query ID.

Response
  {
    "channel_name": "string",
    "query_id": "string"
  }


Get Bulk ICD10 Query Details

GET https://prod.askclair.ai/api/v1/get-bulk-icd10-query-details/{query_id}/

The "Get Bulkd ICD10 Query Details" endpoint allows you to retrieve the answer for an ICD10 query after the streaming process is completed. To obtain the results, you need to make a GET request to the endpoint https://prod.askclair.ai/api/v1//get-bulk-icd10-query-details/{query_id}/, where {query_id} represents the unique identifier of the specific query for which you want to retrieve the details.

By sending the GET request, the API will respond with the relevant details associated with the specified query.

import requests
url = "https://prod.askclair.ai/api/v1/get-bulk-icd10-query-details/{query_id}/"
headers = {
"Authorization": "token YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
const fetch = require('node-fetch');
const url = "https://prod.askclair.ai/api/v1/get-bulk-icd10-query-details/{query_id}/";
const token = "YOUR_TOKEN";

fetch(url,{
headers: {
    "Authorization": `token ${token}`,
    "Content-Type": "application/json"
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl -X GET \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://prod.askclair.ai/api/v1/get-bulk-icd10-query-details/{query_id}/

Ensure that you replace {query_id} in the URL with the actual query identifier you want to retrieve details for. Once you receive the response, you can process it based on your application's requirements.

This endpoint is particularly useful when you have completed the streaming process and need to obtain the final results for a specific query. By using the query ID, you can retrieve the clinical summary, and the icd10 codes associated with the query you have previously streamed.

Response
  {
    "codes": "string",
    "clinical_summary": "string"
  }

Create Stewardship Streaming Channel

POST https://prod.askclair.ai/api/v1/create-stewardship-streaming-channel/

The "Create Stewardship Streaming Channel" endpoint allows you to create a streaming channel for a stewardship query. By making a POST request to the endpoint https://prod.askclair.ai/api/v1/create-stewardship-streaming-channel/, you can initiate the creation of a channel.

Once the request is successful, the API will respond with the channel name and query ID, both of which will be returned with a status code of 200. The channel name and query ID are crucial for listening to the answer using our Clair SDK in your frontend application.

To enable streaming in your frontend, you can utilize the Clair SDK library, which can be accessed at the following URL: https://prod.askclair.ai/static/js/galenSDK.min.js.

For a demonstration of how to implement the streaming functionality, you can refer to the example application available on GitHub at https://github.com/Jonathan-Adly/clair_streaming_demo. This example application provides a practical illustration of how to integrate and use the Clair SDK for streaming stewardship query results.

Events that will be received and should be handled by your frontend:

  1. start
    • Event data = {"text": "question asked"}
  2. answer
    • Event data = {"text" : "generated tokens"}
  3. answer_done (optional to handle - conveinence event with the full answer in html)
    • Event data = {"text" : "Full answer in HTML"}
  4. context
    • Event data = {"text": "generated tokens"}
  5. references
    • Event data = {"title": "reference title", "doi": "reference doi", "abstract": "reference abstract", "url": "reference url"}
  6. end
    • Event data = {"text": "query_id"}
import requests
token = f"token {your_token}"
url = "https://prod.askclair.ai/api/v1/create-stewardship-streaming-channel/"
headers = {'Authorization': token, 'Content-Type': 'application/json'}

payload = {
  "infection": "string",
  "age": 120, #optional
  "weight": 300, #optional
  "crcl": 200, #optional
  "liver_disease": true #optional
}

response = requests.post(url, json=payload, headers=headers)
return response.json()
const fetch = require('node-fetch');
const token = `token ${your_token}`;
const url = "https://prod.askclair.ai/api/v1/create-stewardship-streaming-channel/";

const headers = {
  'Authorization': token,
  'Content-Type': 'application/json'
};

const payload = {
  "infection": "string",
  "age": 120,
  "weight": 300,
  "crcl": 200,
  "liver_disease": true
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl 
-X POST 
-H "Authorization: token YOUR_TOKEN" 
-H "Content-Type: application/json" 
-d '{"infection": "string", "age": 120, "weight": 300, "crcl": 200, "liver_disease": true}'  
https://prod.askclair.ai/api/v1/create-stewardship-streaming-channel/

This returns two string values. channel_name is the name of the channel and query_id is the query ID.

Response
  {
    "channel_name": "string",
    "query_id": "string"
  }


Get Stewardship Query Details

GET https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/

The "Get Stewardship Query Details" endpoint allows you to retrieve the answer for a stewardship query after the streaming process is completed. To obtain the results, you need to make a GET request to the endpoint https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/, where {query_id} represents the unique identifier of the specific query for which you want to retrieve the details.

By sending the GET request, the API will respond with the relevant details associated with the specified query.

import requests
url = "https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/"
headers = {
"Authorization": "token YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
const fetch = require('node-fetch');
const url = "https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/";
const token = "YOUR_TOKEN";

fetch(url,{
headers: {
    "Authorization": `token ${token}`,
    "Content-Type": "application/json"
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl -X GET \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/

Ensure that you replace {query_id} in the URL with the actual query identifier you want to retrieve details for. Once you receive the response, you can process it based on your application's requirements.

This endpoint is particularly useful when you have completed the streaming process and need to obtain the final results for a specific query. By using the query ID, you can retrieve the answer, and the case associated with the query you have previously streamed.

Response
  {
  "question": "string",
  "answer": "string",
  "context_summary": "string",
  "references": [
    {
      "abstract": "string",
      "title": "string",
      "link": "http://example.com",
      "doi": "string"
    }
  ],
    "helpful_links": [
      {
      "title": "string",
      "link": "http://example.com",
      }
    ],
    "FDA_monographs": [
      "title": "string",
      "link": "http://example.com",
    ],
    "guidelines": [
      "title": "string",
      "link": "http://example.com",
    ] 
  }

Create Interaction Streaming Channel

POST https://prod.askclair.ai/api/v1/create-interactions-streaming-channel/

The "Create Interactions Streaming Channel" endpoint allows you to create a streaming channel for a drug interactions query (up to 25 drugs at a time). By making a POST request to the endpoint https://prod.askclair.ai/api/v1/create-interactions-streaming-channel/, you can initiate the creation of a channel.

Once the request is successful, the API will respond with the channel name and query ID, both of which will be returned with a status code of 200. The channel name and query ID are crucial for listening to the answer using our Clair SDK in your frontend application.

To enable streaming in your frontend, you can utilize the Clair SDK library, which can be accessed at the following URL: https://prod.askclair.ai/static/js/galenSDK.min.js.

For a demonstration of how to implement the streaming functionality, you can refer to the example application available on GitHub at https://github.com/Jonathan-Adly/clair_streaming_demo. This example application provides a practical illustration of how to integrate and use the Clair SDK for streaming drug interactions results.

Events that will be received and should be handled by your frontend:

  1. start
    • Event data = {"text": "Interacting drug pairs"},
  2. new_interaction
    • Event data = {"id": "unique id for each interaction"}
  3. drug_pair
    • Event data = {"text": "drug pair, example: 'simvastatin, atorvastatin' ", "id": "id referenced in new_interaction"}
  4. severity
    • Event data = {"text": "severity of interaction, example: Major", "id": "id referenced in new_interaction"}
  5. recommendation
    • Event data = {"text": "short recommendation, example: Contraindicated", "id": "id referenced in new_interaction"}
  6. description
    • Event data = {"text": "interaction description", "id": "id referenced in new_interaction"}
  7. management
    • Event data = {"text": "management ", "id": "id referenced in new_interaction"}
  8. references
    • Event data = {"title": "title", "doi": "doi", "url": "url", "abstract": "abstract", "id": id}
  9. end
    • Event data = {"query_id": "query_id"}
import requests
token = f"token {your_token}"
url = "https://prod.askclair.ai/api/v1/create-interactions-streaming-channel/"
headers = {'Authorization': token, 'Content-Type': 'application/json'}

payload = {
  "drugs": ["string", "string"] #min 2 drugs, max 25 drugs. 
}

response = requests.post(url, json=payload, headers=headers)
return response.json()
const fetch = require('node-fetch');
const token = `token ${your_token}`;
const url = "https://prod.askclair.ai/api/v1/create-interactions-streaming-channel/";

const headers = {
  'Authorization': token,
  'Content-Type': 'application/json'
};

const payload = {
 drugs": ["string", "string"] //min 2 drugs, max 25 drugs.
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl 
-X POST 
-H "Authorization: token YOUR_TOKEN" 
-H "Content-Type: application/json" 
-d '{"drugs": ["string", "string"]}'  
https://prod.askclair.ai/api/v1/create-interactions-streaming-channel/

This returns two string values. channel_name is the name of the channel and query_id is the query ID.

Response
  {
    "channel_name": "string",
    "query_id": "string"
  }


Get Interaction Query Details

GET https://prod.askclair.ai/api/v1/get-interaction-query-details/{query_id}/

The "Get Interaction Query Details" endpoint allows you to retrieve the answer for a stewardship query after the streaming process is completed. To obtain the results, you need to make a GET request to the endpoint https://prod.askclair.ai/api/v1/get-interactions-query-details/{query_id}/, where {query_id} represents the unique identifier of the specific query for which you want to retrieve the details.

By sending the GET request, the API will respond with the relevant details associated with the specified query.

import requests
url = "https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/"
headers = {
"Authorization": "token YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
const fetch = require('node-fetch');
const url = "https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/";
const token = "YOUR_TOKEN";

fetch(url,{
headers: {
    "Authorization": `token ${token}`,
    "Content-Type": "application/json"
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl -X GET \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://prod.askclair.ai/api/v1/get-stewardship-query-details/{query_id}/

Ensure that you replace {query_id} in the URL with the actual query identifier you want to retrieve details for. Once you receive the response, you can process it based on your application's requirements.

This endpoint is particularly useful when you have completed the streaming process and need to obtain the final results for a specific query. By using the query ID, you can retrieve the answer, and the case associated with the query you have previously streamed.

Response
  {
  "question": "string",
  "answer": "string",
  "context_summary": "string",
  "references": [
    {
      "abstract": "string",
      "title": "string",
      "link": "http://example.com",
      "doi": "string"
    }
  ]
  }

Get BYOD Query Streaming Channel

POST https://prod.askclair.ai/api/v1/create-byod-streaming-channel/

The "Create Bring Your Own Document Streaming Channel" endpoint allows you to create a streaming channel for a BYOD query. By making a POST request to the endpoint https://prod.askclair.ai/api/v1/create-byod-streaming-channel/, you can initiate the creation of a channel.

You can search all your documents, or optionally further filter by specific collection name or a user identifier that you supply at the time of document upload. For example, if you have users or departments within your system. You can filter your documents depending on who is making the query.

Once the request is successful, the API will respond with the channel name and query ID, both of which will be returned with a status code of 200. The channel name and query ID are crucial for listening to the answer, context, and references using our Clair SDK in your frontend application.

To enable streaming in your frontend, you can utilize the Clair SDK library, which can be accessed at the following URL: https://prod.askclair.ai/static/js/galenSDK.min.js.

For a demonstration of how to implement the streaming functionality, you can refer to the example application available on GitHub at https://github.com/Jonathan-Adly/clair_streaming_demo. This example application provides a practical illustration of how to integrate and use the Clair SDK for streaming clinical query results.

Events that will be received and should be handled by your frontend:

  1. start
    • Event data = {"text": "question asked"}
  2. answer
    • Event data = {"text" : "generated tokens"}
  3. answer_done (optional to handle - conveinence event with the full answer in html)
    • Event data = {"text" : "Full answer in HTML"}
  4. context
    • Event data = {"text": "generated tokens"}
  5. references
    • Event data = {"title": "your document title", "confident": "80.25", "text": "relevant text in your document", "chunk_id": "the id of relevant text in our database"}
  6. end
    • Event data = {"text": "query_id"}

Please note, references are your own documents in that case. They are structered as a JSON with title (of your document), confidence (90.23), and text.

import requests
token = f"token {your_token}"
url = "https://prod.askclair.ai/api/v1/create-byod-streaming-channel/"
headers = {'Authorization': token, 'Content-Type': 'application/json'}

payload = {
  "query": "string",
  "collection_name: "string", #optional
  "user_identifier": "string" #optional
}

response = requests.post(url, json=payload, headers=headers)
return response.json()
const fetch = require('node-fetch');
const token = `token ${your_token}`;
const url = "https://prod.askclair.ai/api/v1/create-byod-streaming-channel/";

const headers = {
  'Authorization': token,
  'Content-Type': 'application/json'
};

const payload = {
  "query": "string",
  "collection_name: "string", //optional
  "user_identifier": "string" //optional
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl 
-X POST 
-H "Authorization: token YOUR_TOKEN" 
-H "Content-Type: application/json" 
-d '{"query": "string","collection_name: "string", "user_identifier": "string"}' 
https://prod.askclair.ai/api/v1/create-byod-streaming-channel/

This returns two string values. channel_name is the name of the channel and query_id is the query ID.

Response
  {
    "channel_name": "string",
    "query_id": "string"
  }


Get BYOD Query Details

GET https://prod.askclair.ai/api/v1/get-byod-query-detail/{query_id}/

The "Get BYOD Query Details" endpoint allows you to retrieve the answer, context, and references for a BYOD query after the streaming process is completed. To obtain the results, you need to make a GET request to the endpoint https://prod.askclair.ai/api/v1/get-byod-query-details/{query_id}/, where {query_id} represents the unique identifier of the specific query for which you want to retrieve the details.

This endpoint is particularly useful when you have completed the streaming process and need to obtain the final results for a specific query. By using the query ID, you can retrieve the answer, context, and references associated with the byod query you have previously streamed.

By sending the GET request, the API will respond with the relevant details associated with the specified query. This includes the generated answer, the context or evidence summary, and the references that support the answer.

import requests
url = "https://prod.askclair.ai/api/v1/get-byod-query-details/{query_id}/"
headers = {
"Authorization": "token YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
const fetch = require('node-fetch');
const url = "https://prod.askclair.ai/api/v1/get-byod-query-details/{query_id}/";
const token = "YOUR_TOKEN";

fetch(url,{
headers: {
    "Authorization": `token ${token}`,
    "Content-Type": "application/json"
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl -X GET \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://prod.askclair.ai/api/v1/get-byod-query-details/{query_id}/

Ensure that you replace {query_id} in the URL with the actual query identifier you want to retrieve details for. Once you receive the response, you can process it based on your application's requirements.

Response
  {
  "question": "string",
  "answer": "string",
  "context_summary": "string",
  "references": [
    {
      "title": "string",
      "confidence": "90.23",
      "text": "string"
    }
  ]
  }

Create Medication Review Streaming Channel

POST https://prod.askclair.ai/api/v1/create-med-review-streaming-channel/

The "Create Medication Review Streaming Channel" endpoint allows you to create a streaming channel for a medication review query. You send a list of medical conditions and medications and our models generates helpful recommendations.

You can send up to 10 ICD10 codes or 10 diseases and 15 drugs at a time.. By making a POST request to the endpoint https://prod.askclair.ai/api/v1/create-med-review-streaming-channel/, you can initiate the creation of a channel.

Please note, this end point requires a list ICD10 code or diseases (medical conditions) plus a list of drugs. Submitting both ICD10 codes AND diseases will result in an error.

Once the request is successful, the API will respond with the channel name and query ID, both of which will be returned with a status code of 200. The channel name and query ID are crucial for listening to the answer using our Clair SDKin your frontend application.

To enable streaming in your frontend, you can utilize the Clair SDKlibrary, which can be accessed at the following URL: https://prod.askclair.ai/static/js/galenSDK.min.js.

For a demonstration of how to implement the streaming functionality, you can refer to the example application available on GitHub at https://github.com/Jonathan-Adly/clair_streaming_demo. This example application provides a practical illustration of how to integrate and use the Clair SDKfor streaming clinical query results.

Events that will be received and should be handled by your frontend:

  1. start
    • Event data = {"text": "patient case generated from your query"}
  2. answer
    • Event data = {"text": "generated tokens}
  3. end
    • Event data = {"text: "query id"}
import requests
token = f"token {your_token}"
url = "https://prod.askclair.ai/api/v1/create-med-review-streaming-channel/"
headers = {'Authorization': token, 'Content-Type': 'application/json'}

payload = {
  "codes": ["list of ICD 10 codes"], #or "diseases": ["list of medical conditions"],
  "drugs": ["list of drugs"],
  "notes": "Any relevant patient notes", #optional
  "focus": "Any focus area for interventions" #optional 
}

response = requests.post(url, json=payload, headers=headers)
return response.json()
const fetch = require('node-fetch');
const token = `token ${your_token}`;
const url = "https://prod.askclair.ai/api/v1/create-med-review-streaming-channel/";

const headers = {
  'Authorization': token,
  'Content-Type': 'application/json'
};

const payload = {
  "codes": ["list of ICD 10 codes"], //or "diseases": ["list of medical conditions"],
  "drugs": ["list of drugs"],
  "notes": "Any relevant patient notes", //optional
  "focus": "Any focus area for interventions" //optional 
}
fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl 
-X POST 
-H "Authorization: token YOUR_TOKEN" 
-H "Content-Type: application/json" 
-d '{"codes": ["list of ICD 10 codes"],"drugs": ["list of drugs"], "notes": "notes here", "focus": "focus here"}' 
https://prod.askclair.ai/api/v1/create-med-review-streaming-channel/

This returns two string values. channel_name is the name of the channel and query_id is the query ID.

Response
  {
    "channel_name": "string",
    "query_id": "string"
  }


Get Medication Review Query Details

GET https://prod.askclair.ai/api/v1/get-med-review-query-details/{query_id}/

The "Get Medication Review Query Details" endpoint allows you to retrieve the answer for medication review query after the streaming process is completed. To obtain the results, you need to make a GET request to the endpoint https://prod.askclair.ai/api/v1/get-med-review-query-details/{query_id}/, where {query_id} represents the unique identifier of the specific query for which you want to retrieve the details.

By sending the GET request, the API will respond with the relevant details associated with the specified query.

import requests
url = "https://prod.askclair.ai/api/v1/get-med-review-query-details/{query_id}/"
headers = {
"Authorization": "token YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
const fetch = require('node-fetch');
const url = "https://prod.askclair.ai/api/v1/get-med-review-query-details/{query_id}/";
const token = "YOUR_TOKEN";

fetch(url,{
headers: {
    "Authorization": `token ${token}`,
    "Content-Type": "application/json"
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
curl -X GET \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://prod.askclair.ai/api/v1/get-med-review-query-details/{query_id}/

Ensure that you replace {query_id} in the URL with the actual query identifier you want to retrieve details for. Once you receive the response, you can process it based on your application's requirements.

This endpoint is particularly useful when you have completed the streaming process and need to obtain the final results for a specific query. By using the query ID, you can retrieve the clinical summary, and the icd10 codes associated with the query you have previously streamed.

Response
  {
    "patient_case": "string",
    "recommendation": "string"
  }