Chat V1 Response
Example response for Chat V1 API
Brutus AI api response documentation, the api is reference is available at Chat API.
API Request Precap
When sending a request to the /v1/chat/completions endpoint, you need to include the following information in the request body:
- 
/v1/chat/completions: This endpoint allows you to query the BrutusAI search engine and retrieve relevant search results based on the user's query.It accepts a
historyparameter, which is a list of of previous messages in the conversation, and other parameters such assearch_mode,image_result, andsearch_resultare also available.Parameters such as
search_mode,image_result, andsearch_resultare optional and can be used to customize the search results.By default, the
search_modeis set toauto,image_resultandsearch_resultare set to4. That means the API would automatically determine based on conversation if it's required to generate search results or not, and it would return 4 search results and 4 image results. Many times, if conversation includes general meesages like "Hi there", "How are you?", "I am good", etc, then it's not required to generate search results. - 
So the example request to the
/v1/chat/completionsendpoint would look like this: 
import http.client
import json
 
conn = http.client.HTTPSConnection("brutusai.com")
payload = json.dumps({
    "history": [
    {
        "content": "When is America's next general election?",
        "role": "user"
    }
    ],
})
headers = {
    'x-api-key': 'your_api_key',
    'Content-Type': 'application/json'
}
conn.request("POST", "/api/v1/chat/completions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))Example request without the optional fields
- 
So the example request to the
/v1/chat/completionswithout the optional parameters would look like:import http.client import json conn = http.client.HTTPSConnection("brutusai.com") payload = json.dumps({ "history": [ { "content": "When is America's next general election?", "role": "user" } ] }) headers = { 'x-api-key': 'your_api_key', 'Content-Type': 'application/json' } conn.request("POST", "/api/v1/chat/completions", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) 
Example Response
- 
Example response from the
/v1/chat/completionsendpoint be something like this:{ "data": { "history": [ { "content": "When is America's next general election?", "role": "user" }, { "content": "The next general election in America is the 2024 United States presidential election, where incumbent President Joe Biden, a member of the Democratic Party, is running for re-election. His predecessor Donald Trump, a member of the Republican Party, is also expected to participate in the election. The election is scheduled for a date in 2024, and more information can be found on the Wikipedia page dedicated to the 2024 United States presidential election. Additionally, a PDF document highlighting key dates related to the 2024 elections, including the presidential qualifying date, is available for further reference.", "image_result": "[{\"title\": \"General Election\", \"imageUrl\": \"https://www.votecalhounfl.gov/portals/calhoun/Images/2024revElectionDates.jpg?ver=xwPVS3zdnC5VFXsU9QoTgw%3D%3D\", \"link\": \"https://www.votecalhounfl.gov/portals/calhoun/Images/2024revElectionDates.jpg?ver=xwPVS3zdnC5VFXsU9QoTgw%3D%3D\", \"snippet\": \"General Election\"}, {\"title\": \"Chart: 2024: The Super Election Year | Statista\", \"imageUrl\": \"http://cdn.statcdn.com/Infographic/images/normal/31604.jpeg\", \"link\": \"http://cdn.statcdn.com/Infographic/images/normal/31604.jpeg\", \"snippet\": \"Chart: 2024: The Super Election Year | Statista\"}, {\"title\": \"US 2024 presidential election: Dates, candidates and latest issues ...\", \"imageUrl\": \"https://cloudfront-us-east-2.images.arcpublishing.com/reuters/5ARS5ZBCEVK5DP6JSVWL6XGPR4.jpg\", \"link\": \"https://cloudfront-us-east-2.images.arcpublishing.com/reuters/5ARS5ZBCEVK5DP6JSVWL6XGPR4.jpg\", \"snippet\": \"US 2024 presidential election: Dates, candidates and latest issues ...\"}, {\"title\": \"US Presidential Elections 2024: Key dates and events, what lies ...\", \"imageUrl\": \"https://img.etimg.com/thumb/width-1200,height-900,imgsize-41570,resizemode-75,msid-106923480/news/international/world-news/us-presidential-elections-2024-key-dates-and-events-what-lies-ahead.jpg\", \"link\": \"https://img.etimg.com/thumb/width-1200,height-900,imgsize-41570,resizemode-75,msid-106923480/news/international/world-news/us-presidential-elections-2024-key-dates-and-events-what-lies-ahead.jpg\", \"snippet\": \"US Presidential Elections 2024: Key dates and events, what lies ...\"}]", "peopleAlsoAsk": "[]", "role": "assistant", "search_result": "[{\"title\": \"2024 United States presidential election - Wikipedia\", \"link\": \"https://en.wikipedia.org/wiki/2024_United_States_presidential_election\", \"snippet\": \"Incumbent President Joe Biden, a member of the Democratic Party, is running for re-election. His predecessor Donald Trump, a member of the Republican Party, is ...\"}, {\"title\": \"[PDF] 2024 ELECTIONS\", \"link\": \"https://www.sos.la.gov/ElectionsAndVoting/PublishedDocuments/ElectionsCalendar2024.pdf\", \"snippet\": \"***Early voting advanced one day due to the state observed holiday for Thanksgiving and Acadian Day. PRESIDENTIAL QUALIFYING. 3/23/2024 Presidential Preference ...\"}]" } ] }, "message": "Success" } 
Understanding Response
- 
Understanding the response:
The
historyfield contains the response to the user's query, it's the part of history. So it will include conversation history.- The 
historyis list of objects, each object contains thecontentfield which contains the response to the user's query, therolefield which contains the role of the message, it can be eitheruserorassistant. - The other fields such as 
image_result,search_result, andpeopleAlsoAskare optional and contain the search results and related questions. - The 
image_resultfield contains a list of image results related to the user's query. - The 
search_resultfield contains a list of search results related to the user's query. - The 
peopleAlsoAskfield contains a list of related questions that the user might be interested in. This is only generated when ai detects that user might be interested in related questions. 
 - The 
 
