メインコンテンツへスキップ
POST
/
ai
/
ask
cURL
curl -i -L 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"
            }
         ],
         "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": "2013-12-12T10:53:43-08:00"
              }
          ],
          "include_citations": true,
          "ai_agent": {
            "type": "ai_agent_ask",
            "long_text": {
              "model": "azure__openai__gpt_4o_mini",
              "prompt_template": "It is `{current_date}`, and I have $8000 and want to spend a week in the Azores. What should I see?",
            },
            "basic_text": {
              "model": "azure__openai__gpt_4o_mini",
           }
         }
      }'
{
  "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"
    }
  ]
}
このリソースは、バージョン2024.0のエンドポイントで使用されています。 詳細については、 Box APIのバージョン管理を参照してください。Box SDKのバージョニング戦略について詳しく学ぶ。」

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Body

application/json

AIへの質問リクエストオブジェクト。

mode
enum<string>
required

Box AIは、最大1 MBのテキストレプリゼンテーションを含むテキストドキュメント、または最大25ファイルを処理します (いずれか先に到達した方)。ファイルサイズが1 MBを超える場合は、テキストレプリゼンテーションの最初の1 MBが処理されます。Box AIは、解像度が1024 x 1024ピクセルの画像ドキュメントを処理し、最大5つの画像か、複数ページの画像の場合は5ページを処理します。画像数または画像ページ数が5を超える場合は、最初の5つの画像または5ページが処理されます。modeパラメータをsingle_item_qaに設定した場合、items配列に含めることができる要素は1つのみです。現在、Box AIでは、マルチモーダルリクエストがサポートされていません。画像とテキストの両方が送信された場合、Box AIで処理されるのはテキストのみです。

利用可能なオプション:
multiple_item_qa,
single_item_qa
Example:

"multiple_item_qa"

prompt
string
required

LLMが回答するようにクライアントが提供するプロンプト。プロンプトの長さは10000文字に制限されています。

Example:

"What is the value provided by public APIs based on this document?"

items
項目に関するAIへの質問 · object[]
required

LLMで処理する項目 (多くの場合はファイル)。

Required array length: 1 - 25 elements
dialogue_history
会話履歴 · object[]

これまでにLLMに渡されたプロンプトおよび回答の履歴。これにより、レスポンスの生成時にLLMに追加のコンテキストが提供されます。

include_citations
boolean

引用情報を返すかどうかを示すフラグ。

Example:

true

ai_agent
AIへの質問リクエストのエージェント · object

リクエストの処理に使用されるAIエージェント。

Response

LLMからの回答を含む成功したレスポンス。

AIの質問への応答。 AIの応答。

answer
string
required

LLMから提供された回答。

Example:

"Public APIs are important because of key and important reasons."

created_at
string<date-time>
required

プロンプトに対する回答が作成された時点のISO日付形式のタイムスタンプ。

Example:

"2012-12-12T10:53:43-08:00"

completion_reason
string

応答が終了した理由。

Example:

"done"

ai_agent_info
リクエストで使用されるモデルおよびプロセッサに関する情報。 · object

リクエストで使用されるモデルおよびプロセッサに関する情報。

citations
LLMの回答で参照された部分の引用情報 · object[]

LLMの回答で参照された部分の引用情報。