Ask a question to a PDF
curl --request GET \
--url https://api.scholarai.io/api/question \
--header 'x-scholarai-api-key: <api-key>'import requests
url = "https://api.scholarai.io/api/question"
headers = {"x-scholarai-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-scholarai-api-key': '<api-key>'}};
fetch('https://api.scholarai.io/api/question', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.scholarai.io/api/question",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-scholarai-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"
"net/http"
"io"
)
func main() {
url := "https://api.scholarai.io/api/question"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-scholarai-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.scholarai.io/api/question")
.header("x-scholarai-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scholarai.io/api/question")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-scholarai-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"chunks": [
{
"chunk_num": 123,
"chunk": "<string>",
"img_mds": [
"<string>"
],
"pdf_url": "<string>"
}
],
"total_chunk_num": 123,
"hint": "<string>"
}Endpoints
Ask a question to a PDF
Uses embedding model to find section of PDF most relevant for answering a question :param pdf_url: the url :param question: the question :return: the chunk most relevant to answering that question and its source
GET
/
api
/
question
Ask a question to a PDF
curl --request GET \
--url https://api.scholarai.io/api/question \
--header 'x-scholarai-api-key: <api-key>'import requests
url = "https://api.scholarai.io/api/question"
headers = {"x-scholarai-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-scholarai-api-key': '<api-key>'}};
fetch('https://api.scholarai.io/api/question', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.scholarai.io/api/question",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-scholarai-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"
"net/http"
"io"
)
func main() {
url := "https://api.scholarai.io/api/question"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-scholarai-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.scholarai.io/api/question")
.header("x-scholarai-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scholarai.io/api/question")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-scholarai-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"chunks": [
{
"chunk_num": 123,
"chunk": "<string>",
"img_mds": [
"<string>"
],
"pdf_url": "<string>"
}
],
"total_chunk_num": 123,
"hint": "<string>"
}Authorizations
Query Parameters
The user question. Must be in English.
id for PDF. Must begin with be one of PDF_URL:some.url.com or PROJ:some_path
⌘I