cURL
curl -X POST https://www.verahealth.ai/api/chat/v1 \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "What is the first-line treatment for hypertension?"
}'const response = await fetch('https://www.verahealth.ai/api/chat/v1', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'What is the first-line treatment for hypertension?',
traceId: '550e8400-e29b-41d4-a716-446655440000' // Optional: for internal tracking
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\\n\\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') break;
const event = JSON.parse(data);
console.log('Event:', event);
}
}
}import requests
import json
url = 'https://www.verahealth.ai/api/chat/v1'
headers = {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
data = {
'prompt': 'What is the first-line treatment for hypertension?',
'traceId': '550e8400-e29b-41d4-a716-446655440000' # Optional: for internal tracking
}
with requests.post(url, headers=headers, json=data, stream=True) as response:
for line in response.iter_lines():
if line:
line = line.decode('utf-8')
if line.startswith('data: '):
data = line[6:]
if data == '[DONE]':
break
event = json.loads(data)
print('Event:', event)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.verahealth.ai/api/chat/v1",
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([
'prompt' => 'What is the first-line treatment for hypertension?'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://www.verahealth.ai/api/chat/v1"
payload := strings.NewReader("{\n \"prompt\": \"What is the first-line treatment for hypertension?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://www.verahealth.ai/api/chat/v1")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What is the first-line treatment for hypertension?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.verahealth.ai/api/chat/v1")
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["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"What is the first-line treatment for hypertension?\"\n}"
response = http.request(request)
puts response.read_bodydata: {"type":"NodeChunk","content":{"nodeName":"STREAM","content":"The first-line treatment for hypertension typically includes..."}}
v1
Chat
deprecated
Send a medical question and receive an answer as a Server-Sent Events (SSE) stream. The stream contains answer text, DOI/PMID citation mappings, reference metadata, and suggested follow-up questions.
New integrations should use POST /api/chat/v2.
POST
/
api
/
chat
/
v1
cURL
curl -X POST https://www.verahealth.ai/api/chat/v1 \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "What is the first-line treatment for hypertension?"
}'const response = await fetch('https://www.verahealth.ai/api/chat/v1', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'What is the first-line treatment for hypertension?',
traceId: '550e8400-e29b-41d4-a716-446655440000' // Optional: for internal tracking
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\\n\\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') break;
const event = JSON.parse(data);
console.log('Event:', event);
}
}
}import requests
import json
url = 'https://www.verahealth.ai/api/chat/v1'
headers = {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
data = {
'prompt': 'What is the first-line treatment for hypertension?',
'traceId': '550e8400-e29b-41d4-a716-446655440000' # Optional: for internal tracking
}
with requests.post(url, headers=headers, json=data, stream=True) as response:
for line in response.iter_lines():
if line:
line = line.decode('utf-8')
if line.startswith('data: '):
data = line[6:]
if data == '[DONE]':
break
event = json.loads(data)
print('Event:', event)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.verahealth.ai/api/chat/v1",
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([
'prompt' => 'What is the first-line treatment for hypertension?'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://www.verahealth.ai/api/chat/v1"
payload := strings.NewReader("{\n \"prompt\": \"What is the first-line treatment for hypertension?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://www.verahealth.ai/api/chat/v1")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What is the first-line treatment for hypertension?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.verahealth.ai/api/chat/v1")
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["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"What is the first-line treatment for hypertension?\"\n}"
response = http.request(request)
puts response.read_bodydata: {"type":"NodeChunk","content":{"nodeName":"STREAM","content":"The first-line treatment for hypertension typically includes..."}}
Authorizations
API key for authentication. Contact support@verahealth.ai to obtain your API key.
Body
application/json
Response
Server-Sent Events stream (Content-Type: text/event-stream). Each frame is data: {JSON_OBJECT} and every event has type and content fields. The stream terminates with data: [DONE].
Event types
content.nodeName | Description |
|---|---|
STREAM | Chunks of answer text. |
DOI_REFERENCE_MAP | Maps inline reference numbers to DOI/PMID links. |
REFERENCES | Reference metadata (title, journal, authors, DOI, PMID, year). |
SUGGEST | Up to 3 suggested follow-up questions (emitted in a NodeEnd wrapper at the end of the stream). |
Example events
{"type": "NodeChunk", "content": {"nodeName": "STREAM", "content": "The first-line treatment..."}}
{"type": "NodeChunk", "content": {"nodeName": "DOI_REFERENCE_MAP", "content": {"referenceMap": {"1": "https://doi.org/10.1056/NEJMoa2035389"}, "totalReferences": 1}}}
{"type": "NodeChunk", "content": {"nodeName": "REFERENCES", "content": [{"title": "Hypertension Guidelines 2023", "metadata": {"title": "2023 ACC/AHA Guidelines", "journal": "JACC", "pmid": "12345678", "doi": "10.1056/NEJMoa2035389", "year": 2023}}]}}
{"type": "NodeEnd", "content": {"message": {"nodeName": "SUGGEST", "value": {"question_1": "...", "question_2": "...", "question_3": "..."}}}}
Server-Sent Events stream containing JSON objects. Each event has a type and content field. See the endpoint description for detailed event type documentation.
Was this page helpful?