LIVE QA API Contract - PhotonInsights/photon-public-api GitHub Wiki

API endpoint for the LIVE QA functionality

Authentication

Require x-pi-bearer key in the headers, whose value should be set to the long term access token that you have generated

URL

POST /chatbot/api/v2/live/answer

Request JSON Data

Parameter Type Description Required Default Example
query str Query to search for   "Tesla"
stream bool Whether to get the answer as a stream false true
settings obj Custom settings for the api {"dateRange":"ANYTIME","onlineSearchSource":"CUSTOM_DOMAINS","customDomains":["rhinohealth.com"]}
settings.dateRange str Custom date range for request, possible values: PAST_DAY, PAST_WEEK ,PAST_MONTH, PAST_QUARTER, PAST_YEAR, ANYTIME PAST_WEEK
settings.onlineSearchSource str Parameter to specify source of search, if not set internal documents will be used, possible values: NEWS, INTERNET, CUSTOM_DOMAINS CUSTOM_DOMAINS
settings.customDomains list[str] List of custom domains, to be set when onlineSearchSource is CUSTOM_DOMAINS ["cnn.com"]
settings.fileSystemIds list[str] List of fileIds to be used as source, If null internal documents are not used as source, if empty list is passed, all documents are used as source ["9c9c6f92-a0bb-452b-9080-c75e37f28a62"]
settings.entitiesFromAnswer bool Whether to extract entities from answer false true


Example Request

Search For Tesla

    
{"query":"rhinohealth","stream":true,"settings":{"dateRange":"ANYTIME","onlineSearchSource":"CUSTOM_DOMAINS","customDomains":["rhinohealth.com"]}}
    
  

Response JSON Data when stream is set to False

Response JSON

Parameter Type Description Required Example
data obj Contains all the sources, summary and the final answer {...}
data.SOURCES obj Contains all the sources {...}
data.SOURCES.sources list[obj] Contains all the source related information [{...}]
data.SOURCES.sources[].answerSource str Source type "Article"
data.SOURCES.sources[].url str source url "https://www.businessinsider.com/elon-musk-problems-twitter-x-tesla-gamble-luck-run-out-2023-12"
data.SOURCES.sources[].source str source name "Business Insider"
data.SOURCES.sources[].title str article title "Elon Musk's Problems at Twitter"
data.SOURCES.sources[].datetime str article date "2023-12-10T11:58:12.399182"
data.SOURCES.sources[].icon str source icon "https://encrypted-tbn3.gstatic.com/faviconV2?url=https://www.businessinsider.com&client=STREAM&size=128&type=FAVICON&fallback_opts=TYPE,SIZE,URL"
data.SOURCES.relatedSearches List[str] Related Searches for Query ["tesla price","tesla 2023"]
data.SOURCES.relatedQuestions List[str] Related Questions for Query ["Is the Tesla Cybertruck out yet?","How much is the 2024 Tesla Model 3?"]
data.SUMMARY obj Contains summary for all the sources {...}
data.SUMMARY.server str default value SUMMARY 'SUMMARY'
data.SUMMARY.data List[str] Summaries for all articles ["Elon Musk has been in a wild ride since 2018....", "A 2019 crash involving Tesla Autopilot occurred on a rural road....",...]
data.ANSWER_ENTITIES list[obj] Contains all entities extracted from answer [{...}]
data.ANSWER_ENTITIES[].entityGroup str type of entity, i.e a person or org or location etc "PER"
data.ANSWER_ENTITIES[].score Double score of entity extraction 0.9763529896736145
data.ANSWER_ENTITIES[].word str entity "Tesla"
data.ANSWER_ENTITIES[].start int start index 64
data.ANSWER_ENTITIES[].end int end index 69
data.LLM obj object containing final answer {...}
data.LLM.answer str chatbot answer Recently, there have been several notable happenings related to Tesla. Here is a high-level overview:\n\n1. Elon Musk's Challenges:......"

Example Curl Request

In the below curl replace LongTermAccessToken with the actual token obtained from long term token generation workflow

Search For Tesla

    
curl --location 'https://prod-gateway.photoninsights.com/chatbot/api/v2/live/answer' \
--header 'Content-Type: application/json' \
--header 'x-pi-bearer: LongTermAccessToken' \
--data '{"query":"rhinohealth","stream":false,"settings":{"dateRange":"ANYTIME","onlineSearchSource":"CUSTOM_DOMAINS","customDomains":["rhinohealth.com"], "fileSystemIds":[]}}'
    
  
⚠️ **GitHub.com Fallback** ⚠️