AIに質問リクエストを送信

post
https://api.box.com/2.0
/ai/ask

サポートされているLLMにAIリクエストを送信し、提供されたコンテキストを考慮してユーザーの質問に特化した回答を返します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

object array本文内必須

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

: Box AIは、最大1 MBのテキストレプリゼンテーションを含むドキュメント、または最大25ファイルを処理します (いずれか早い方)。ファイルサイズが1 MBを超えた場合は、テキストレプリゼンテーションの最初の1 MBが処理されます。modeパラメータをsingle_item_qaに設定した場合、items配列には要素を1つしか含めることができません。

string本文内必須
"123"

項目のID。

string本文内必須
"file"

項目のタイプ。

次の値に固定: file

string本文内省略可能
"This is file content."

項目のコンテンツ (多くの場合はテキストレプリゼンテーション)。

string本文内必須
"multiple_item_qa"

このモードでは、このリクエストの対象となる項目を1つにするか複数にするかを指定します。single_item_qaを選択すると、items配列には要素を1つしか含めることができません。multiple_item_qaを選択すると、最大25項目を指定できます。

次の値のいずれか1つ: multiple_item_qa,single_item_qa

string本文内必須
"What is the value provided by public APIs based on this document?"

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

レスポンス

application/jsonAIの応答

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

予期しないクライアントエラー。

予期しないサーバーエラー。

post
AIに質問リクエストを送信
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
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"
        }
       ],
     }'
Java
BoxAIResponse response = BoxAI.sendAIRequest(
    api,
    "What is the content of the file?",
    Collections.singletonList("123456", BoxAIItem.Type.FILE)),
    BoxAI.Mode.SINGLE_ITEM_QA
);
TypeScript Gen
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);
Python Gen
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",
        ),
    ],
)
.NET (Beta)
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" }})));

レスポンスの例

{
  "answer": "Public APIs are important because of key and important reasons.",
  "completion_reason": "done",
  "created_at": "2012-12-12T10:53:43-08:00"
}