AI
Ask question
Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context.
You can ask a question about a single file, several files, or the entire contents of a Box Hub. To search across and ask questions about everything in a Box Hub, send a single item with type set to hubs and the Hub's ID as the id. Box AI answers the question using the indexed content of all files in that Hub.
Asking questions about a Box Hub requires Box AI for Hubs to be enabled in the Admin Console before the Hub is created, so that its content is indexed.
post/ai/ask
Request body
Example request
{
"mode": "multiple_item_qa",
"prompt": "What is the value provided by public APIs based on this document?",
"items": [
{
"id": "123",
"type": "file",
"content": "This is file content."
}
],
"dialogue_history": [
{
"prompt": "Make my email about public APIs sound more professional.",
"answer": "Here is the first draft of your professional email about public APIs.",
"created_at": "2012-12-12T10:53:43-08:00"
}
],
"include_citations": true,
"ai_agent": {
"type": "ai_agent_id",
"id": "14031"
}
}Response
A successful response including the answer from the LLM.
Example response
{
"answer": "Public APIs are important because of key and important reasons.",
"created_at": "2012-12-12T10:53:43-08:00",
"completion_reason": "done",
"ai_agent_info": {
"models": [
{
"name": "azure__openai__text_embedding_ada_002",
"provider": "azure",
"supported_purpose": "embedding"
}
],
"processor": "basic_text"
},
"citations": [
{
"content": "Public APIs are key drivers of innovation and growth.",
"id": "123",
"type": "file",
"name": "The importance of public APIs.pdf"
}
]
}