v1

latestOpenAPI 3.0.2Apache-2.02026-07-142963051.0 MB
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

mode'multiple_item_qa' | 'single_item_qa' required

Box AI handles text documents with text representations up to 2MB in size, or a maximum of 25 files, whichever comes first. If the text file size exceeds 2MB, the first 2MB of text representation will be processed. Box AI handles image documents with a resolution of 1024 x 1024 pixels, with a maximum of 5 images or 5 pages for multi-page images. If the number of image or image pages exceeds 5, the first 5 images or pages will be processed. If you set mode parameter to single_item_qa, the items array can have one element only. Currently Box AI does not support multi-modal requests. If both images and text are sent Box AI will only process the text.

promptstring required

The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters.

include_citationsboolean

A flag to indicate whether citations should be returned.

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.

answerstring required

The answer provided by the LLM.

created_atstring date-time required

The ISO date formatted timestamp of when the answer to the prompt was created.

completion_reasonstring

The reason the response finishes.

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"
    }
  ]
}