const axios = require("axios");
const config = {
headers: {
"x-api-key": "sec_xxxxxx",
"Content-Type": "application/json",
},
};
const data = {
sourceId: "src_xxxxxx",
messages: [
{
role: "user",
content: "Who wrote the constitution?",
},
],
};
axios
.post("https://api.chatpdf.com/v1/chats/message", data, config)
.then((response) => {
console.log("Result:", response.data.content);
})
.catch((error) => {
console.error("Error:", error.message);
console.log("Response:", error.response.data);
});
Insights
curl -X POST ‘https://api.chatpdf.com/v1/chats/message’ \
-H ‘x-api-key: sec_7wUyfnbCsQftkQDN3MJqG53SekBaiCqt’ \
-H ‘Content-Type: application/json’ \
-d ‘{“sourceId”: “src_xxxxxx”, “messages”: [{“role”: “user”, “content”: “Who wrote the consitution?”}]}’
Recent Comments