Box AI API is a beta feature, which means the
available capabilities may change.
Box AI API is available to all Enterprise Plus customers.
Box AI API allows you to
ask a question about a supplied file or
a set of files, and get a response based on
the content.
For example, while viewing a document in Box,
you can ask Box AI to summarize the content.
curl -i -X POST "https://api.box.com/2.0/ai/ask" \
-H "content-type: application/json" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-d '{
"mode": "single_item_qa",
"prompt": "What is the value provided by public APIs based on this document?",
"items": [
{
"type": "file",
"id": "9842787262"
}
],
}'
BoxAIResponse response = BoxAI.sendAIRequest(
api,
"What is the content of the file?",
Collections.singletonList("123456", BoxAIItem.Type.FILE)),
BoxAI.Mode.SINGLE_ITEM_QA
);
await client.ai.createAiAsk({
mode: 'multiple_item_qa' as AiAskModeField,
prompt: 'Which direction sun rises?',
items: [
new AiAskItemsField({
id: fileToAsk1.id,
type: 'file' as AiAskItemsTypeField,
content: 'Earth goes around the sun',
}),
new AiAskItemsField({
id: fileToAsk2.id,
type: 'file' as AiAskItemsTypeField,
content: 'Sun rises in the East in the morning',
}),
],
} satisfies AiAsk);
client.ai.create_ai_ask(CreateAiAskMode.MULTIPLE_ITEM_QA.value, 'Which direction sun rises?', [CreateAiAskItems(id=file_to_ask_1.id, type=CreateAiAskItemsTypeField.FILE.value, content='Earth goes around the sun'), CreateAiAskItems(id=file_to_ask_2.id, type=CreateAiAskItemsTypeField.FILE.value, content='Sun rises in the East in the morning')])
await client.Ai.CreateAiAskAsync(requestBody: new AiAsk(mode: AiAskModeField.MultipleItemQa, prompt: "Which direction sun rises?", items: Array.AsReadOnly(new [] {new AiAskItemsField(id: fileToAsk1.Id, type: AiAskItemsTypeField.File, content: "Earth goes around the sun"),new AiAskItemsField(id: fileToAsk2.Id, type: AiAskItemsTypeField.File, content: "Sun rises in the East in the morning")})));
To make a call, you need to pass the following parameters.
Mandatory parameters are in bold.
Parameter
Description
Available values
Example
mode
The type of request. It can be a question about a single file or a set of files. For multiple files, Box AI API supports up to 1MB of text representation and up to 25 files.
single_item_qa, multiple_item_qa
single_item_qa
prompt
The question about your document or content.
"What is this document about?"
items.id
The Box file ID you want to provide as input.
112233445566
items.type
The type of the provided input. Currently, it can be a single file or multiple files.
file
file
items.content
The content of the item, often the text representation.
“An application programming interface (API) is a way for two or more computer programs or components to communicate with each other. It is a type of software interface……”