import requestsendpoint = "https://api-prod.usefini.com/v2/bots/ask-question"question = "How do I upgrade to premium?"instruction = "Answer as if you are replying to an email."# The instruction part (role: 'system') in messageHistory is optional.# If you skip it (set to []) the instruction from Fini's UI setup page will be picked up instead.messageHistory = [{"content": instruction, "role": "system"}] # This is optionaldata = {"question": question, "messageHistory": messageHistory} // optional parameters: stream, temperature, stop, categoriestoken = "your_api_key_here" # Best stored in secrets managementheaders = {"Authorization": "Bearer " + token}# Make sure your 'content-type' header is set to 'application/json'answer = requests.post(endpoint, json=data, headers=headers)# This response will contain an updated messageHistory# Re-use this messageHistory in a new request to enable chat modeprint(answer.json());
Copy
{ "answer": "Hello there! Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes. Let me know if you need more details. Have a fantastic day!", "answer_uuid": "f4ead1e0-576b-489f-bc59-7b1c6c43ee27", "based_on": [ { "answer": "Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes", "score": 0.726, "source_id": "https://usefini.com", "source_type": "url", } ], "categories": [ "Fini intro" ], "messages": [ { "content": "Answer in friendly tone", "role": "system" }, { "content": "What is Fini?", "role": "user" }, { "content": "Hello there! Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes. Let me know if you need more details. Have a fantastic day!", "role": "assistant" } ]}
Endpoint Examples
Retrieve Answers
This endpoint retrievers answers from your bot
POST
/
v2
/
bots
/
ask-question
Copy
import requestsendpoint = "https://api-prod.usefini.com/v2/bots/ask-question"question = "How do I upgrade to premium?"instruction = "Answer as if you are replying to an email."# The instruction part (role: 'system') in messageHistory is optional.# If you skip it (set to []) the instruction from Fini's UI setup page will be picked up instead.messageHistory = [{"content": instruction, "role": "system"}] # This is optionaldata = {"question": question, "messageHistory": messageHistory} // optional parameters: stream, temperature, stop, categoriestoken = "your_api_key_here" # Best stored in secrets managementheaders = {"Authorization": "Bearer " + token}# Make sure your 'content-type' header is set to 'application/json'answer = requests.post(endpoint, json=data, headers=headers)# This response will contain an updated messageHistory# Re-use this messageHistory in a new request to enable chat modeprint(answer.json());
Copy
{ "answer": "Hello there! Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes. Let me know if you need more details. Have a fantastic day!", "answer_uuid": "f4ead1e0-576b-489f-bc59-7b1c6c43ee27", "based_on": [ { "answer": "Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes", "score": 0.726, "source_id": "https://usefini.com", "source_type": "url", } ], "categories": [ "Fini intro" ], "messages": [ { "content": "Answer in friendly tone", "role": "system" }, { "content": "What is Fini?", "role": "user" }, { "content": "Hello there! Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes. Let me know if you need more details. Have a fantastic day!", "role": "assistant" } ]}
Prompt to generate completions. If you remove this parameter from your request, the instruction from Fini’s UI setup page will be picked up instead. We recommend always filling this for faster responses (skips DB lookup of instruction)
The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.To describe a function which accepts no parameters, provide the value {"type": "object", "properties": {}}.
Controls how the model responds to function calls. “none” means the model does not call a function, and responds to the end-user. “auto” means the model can pick between an end-user or calling a function. Specifying a particular function via {"name":\ "my_function"} forces the model to call that function. “none” is the default when no functions are present. “auto” is the default if functions are present.
The user_attributes object contains key-value pairs representing user specific information and attributes within the system. Each attribute is defined by a key-value pair where the key is a string and the value can be a string, boolean, or numeric type. These attributes capture user details, enabling personalized responses and workflow handling.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We recommend using 0.4 as the default.
A list of messages comprising the conversation so far.
Copy
import requestsendpoint = "https://api-prod.usefini.com/v2/bots/ask-question"question = "How do I upgrade to premium?"instruction = "Answer as if you are replying to an email."# The instruction part (role: 'system') in messageHistory is optional.# If you skip it (set to []) the instruction from Fini's UI setup page will be picked up instead.messageHistory = [{"content": instruction, "role": "system"}] # This is optionaldata = {"question": question, "messageHistory": messageHistory} // optional parameters: stream, temperature, stop, categoriestoken = "your_api_key_here" # Best stored in secrets managementheaders = {"Authorization": "Bearer " + token}# Make sure your 'content-type' header is set to 'application/json'answer = requests.post(endpoint, json=data, headers=headers)# This response will contain an updated messageHistory# Re-use this messageHistory in a new request to enable chat modeprint(answer.json());
Copy
{ "answer": "Hello there! Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes. Let me know if you need more details. Have a fantastic day!", "answer_uuid": "f4ead1e0-576b-489f-bc59-7b1c6c43ee27", "based_on": [ { "answer": "Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes", "score": 0.726, "source_id": "https://usefini.com", "source_type": "url", } ], "categories": [ "Fini intro" ], "messages": [ { "content": "Answer in friendly tone", "role": "system" }, { "content": "What is Fini?", "role": "user" }, { "content": "Hello there! Fini is an AI tool that helps companies turn their knowledgebase into AI chat in 2 minutes. Let me know if you need more details. Have a fantastic day!", "role": "assistant" } ]}