Box Developerドキュメント

Box Developerドキュメントの新しいベータ版サイトがまもなくリリースされる予定です。最新の開発者向けガイド、APIリファレンス、AI搭載の検索により、Boxを使用した迅速な開発をサポートします。更新情報については今しばらくお待ちください。

最新バージョン

テキストを生成

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

このエンドポイントはバージョン2024.0です。引き続き使用するために 変更は必要ありません。詳細については、 **Box APIのバージョン管理**を参照してください。

サポートされている大規模言語モデル (LLM) にAIリクエストを送信し、提供されたプロンプトに基づいて生成されたテキストを返します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

テキストの生成に使用されるAIエージェント。

object array本文内省略可能

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

string本文内省略可能
"Here is the first draft of your professional email about public APIs."

以前にLLMから提供された回答。

string (date-time)本文内省略可能
"2012-12-12T10:53:43-08:00"

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

string本文内省略可能
"Make my email about public APIs sound more professional."

以前にクライアントによって提供され、LLMが回答したプロンプト。

object array本文内必須

LLMで処理する項目 (多くの場合はファイル)。この配列に含めることができる要素は1つだけです。

: Box AIは、最大1 MBのテキストレプリゼンテーションを含むドキュメントを処理します。ファイルサイズが1 MBを超えた場合は、テキストレプリゼンテーションの最初の1 MBが処理されます。

string本文内必須
"123"

項目のID。

string本文内必須
"file"

項目のタイプ。

次の値に固定: file

string本文内省略可能
"This is file content that is relevant to the text gen request."

新規テキストを生成したり既存テキストを編集したりする場合にコンテキストとして使用するコンテンツ。

string本文内必須
"Write an email to a client about the importance of public APIs."

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

レスポンス

application/jsonAIの応答

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

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

予期しないエラー。

post
テキストを生成
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

Box SDKのバージョン戦略の詳細については、 **こちら**を確認してください。


cURL
curl -i -L POST "https://api.box.com/2.0/ai/text_gen" \
     -H "content-type: application/json" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -d '{
          "prompt": "Write a social media post about protein powder.",
          "items": [
         {
            "id": "12345678",
            "type": "file",
            "content": "More information about protein powders"
        },
        ],
          "dialogue_history": [
            {
                "prompt": "Can you add some more information?",
                "answer": "Public API schemas provide necessary information to integrate with APIs...",
                "created_at": "2013-12-12T11:20:43-08:00"
            }
        ],
          "ai_agent": {
            "type": "ai_agent_text_gen",
            "basic_gen": {
              "model": "azure__openai__gpt_4o_mini"
            }
         }
     }'
Node/TypeScript v10
await client.ai.createAiTextGen({
  prompt: 'Paraphrase the documents',
  items: [
    new AiTextGenItemsField({
      id: fileToAsk.id,
      type: 'file' as AiTextGenItemsTypeField,
      content:
        'The Earth goes around the Sun. The Sun rises in the east in the morning.',
    }),
  ],
  dialogueHistory: [
    {
      prompt: 'What does the earth go around?',
      answer: 'The Sun',
      createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
    } satisfies AiDialogueHistory,
    {
      prompt: 'On Earth, where does the Sun rise?',
      answer: 'east',
      createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
    } satisfies AiDialogueHistory,
  ],
} satisfies AiTextGen);
Python v10
client.ai.create_ai_text_gen(
    "Paraphrase the documents",
    [
        CreateAiTextGenItems(
            id=file_to_ask.id,
            type=CreateAiTextGenItemsTypeField.FILE,
            content="The Earth goes around the Sun. The Sun rises in the east in the morning.",
        )
    ],
    dialogue_history=[
        AiDialogueHistory(
            prompt="What does the earth go around?",
            answer="The Sun",
            created_at=date_time_from_string("2021-01-01T00:00:00Z"),
        ),
        AiDialogueHistory(
            prompt="On Earth, where does the Sun rise?",
            answer="east",
            created_at=date_time_from_string("2021-01-01T00:00:00Z"),
        ),
    ],
)
.NET v10
await client.Ai.CreateAiTextGenAsync(requestBody: new AiTextGen(prompt: "Paraphrase the documents", items: Array.AsReadOnly(new [] {new AiTextGenItemsField(id: fileToAsk.Id, type: AiTextGenItemsTypeField.File) { Content = "The Earth goes around the Sun. The Sun rises in the east in the morning." }})) { DialogueHistory = Array.AsReadOnly(new [] {new AiDialogueHistory() { Prompt = "What does the earth go around?", Answer = "The Sun", CreatedAt = Utils.DateTimeFromString(dateTime: "2021-01-01T00:00:00Z") },new AiDialogueHistory() { Prompt = "On Earth, where does the Sun rise?", Answer = "east", CreatedAt = Utils.DateTimeFromString(dateTime: "2021-01-01T00:00:00Z") }}) });
Swift v10
try await client.ai.createAiTextGen(requestBody: AiTextGen(prompt: "Paraphrase the documents", items: [AiTextGenItemsField(id: fileToAsk.id, type: AiTextGenItemsTypeField.file, content: "The Earth goes around the Sun. The Sun rises in the east in the morning.")], dialogueHistory: [AiDialogueHistory(prompt: "What does the earth go around?", answer: "The Sun", createdAt: try Utils.Dates.dateTimeFromString(dateTime: "2021-01-01T00:00:00Z")), AiDialogueHistory(prompt: "On Earth, where does the Sun rise?", answer: "east", createdAt: try Utils.Dates.dateTimeFromString(dateTime: "2021-01-01T00:00:00Z"))]))
Java v10
client.getAi().createAiTextGen(new AiTextGen.Builder("Paraphrase the documents", Arrays.asList(new AiTextGenItemsField.Builder(fileToAsk.getId()).type(AiTextGenItemsTypeField.FILE).content("The Earth goes around the Sun. The Sun rises in the east in the morning.").build())).dialogueHistory(Arrays.asList(new AiDialogueHistory.Builder().prompt("What does the earth go around?").answer("The Sun").createdAt(dateTimeFromString("2021-01-01T00:00:00Z")).build(), new AiDialogueHistory.Builder().prompt("On Earth, where does the Sun rise?").answer("east").createdAt(dateTimeFromString("2021-01-01T00:00:00Z")).build())).build())
.NET v6
await client.Ai.CreateAiTextGenAsync(requestBody: new AiTextGen(prompt: "Paraphrase the documents", items: Array.AsReadOnly(new [] {new AiTextGenItemsField(id: fileToAsk.Id, type: AiTextGenItemsTypeField.File) { Content = "The Earth goes around the Sun. The Sun rises in the east in the morning." }})) { DialogueHistory = Array.AsReadOnly(new [] {new AiDialogueHistory() { Prompt = "What does the earth go around?", Answer = "The Sun", CreatedAt = Utils.DateTimeFromString(dateTime: "2021-01-01T00:00:00Z") },new AiDialogueHistory() { Prompt = "On Earth, where does the Sun rise?", Answer = "east", CreatedAt = Utils.DateTimeFromString(dateTime: "2021-01-01T00:00:00Z") }}) });
Node v4
await client.ai.createAiTextGen({
  prompt: 'Paraphrase the documents',
  items: [
    new AiTextGenItemsField({
      id: fileToAsk.id,
      type: 'file' as AiTextGenItemsTypeField,
      content:
        'The Earth goes around the Sun. The Sun rises in the east in the morning.',
    }),
  ],
  dialogueHistory: [
    {
      prompt: 'What does the earth go around?',
      answer: 'The Sun',
      createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
    } satisfies AiDialogueHistory,
    {
      prompt: 'On Earth, where does the Sun rise?',
      answer: 'east',
      createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
    } satisfies AiDialogueHistory,
  ],
} satisfies AiTextGen);

レスポンスの例

{
  "ai_agent_info": {
    "models": [
      {
        "name": "azure__openai__text_embedding_ada_002",
        "provider": "azure",
        "supported_purpose": "embedding"
      }
    ],
    "processor": "basic_text"
  },
  "answer": "Public APIs are important because of key and important reasons.",
  "completion_reason": "done",
  "created_at": "2012-12-12T10:53:43-08:00"
}