メインコンテンツへスキップ
POST
/
chat-messages
Error
A valid request URL is required to generate request examples
{
  "event": "message",
  "task_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "mode": "chat",
  "answer": "<string>",
  "metadata": {
    "usage": {
      "prompt_tokens": 123,
      "prompt_unit_price": "<string>",
      "prompt_price_unit": "<string>",
      "prompt_price": "<string>",
      "completion_tokens": 123,
      "completion_unit_price": "<string>",
      "completion_price_unit": "<string>",
      "completion_price": "<string>",
      "total_tokens": 123,
      "total_price": "<string>",
      "currency": "<string>",
      "latency": 123
    },
    "retriever_resources": [
      {
        "position": 123,
        "dataset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "dataset_name": "<string>",
        "document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "document_name": "<string>",
        "segment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "score": 123,
        "content": "<string>"
      }
    ]
  },
  "created_at": 123
}

承認

Authorization
string
header
必須

APIキー認証。すべてのAPIリクエストにおいて、Authorization HTTPヘッダーにAPIキーを含めてください。形式:Bearer {API_KEY}。APIキーの漏洩を防ぐため、APIキーはクライアント側で共有または保存せず、サーバー側で保存することを強くお勧めします。

ボディ

application/json

チャットメッセージ送信リクエストボディ。

query
string
必須

ユーザー入力/質問内容。

user
string
必須

ユーザー識別子、アプリケーション内で一意である必要があります。重要な注意事項: Service API は WebApp で作成された対話を共有しません。API を通じて作成された対話は、WebApp インターフェースで作成されたものとは分離されています。

inputs
object

アプリで定義されたさまざまな変数値の入力を許可します。デフォルトは{}

response_mode
enum<string>
デフォルト:streaming

応答の返却モード。streaming(推奨)はSSEベース。blockingは実行完了後に結果を返します(Cloudflareの100秒タイムアウト制限あり;エージェントアシスタントモードではサポートされていません)。

利用可能なオプション:
streaming,
blocking
conversation_id
string<uuid>

会話ID、以前のチャット記録に基づいて会話を続けるには、前のメッセージのconversation_idを渡す必要があります。

files
object[]

アップロードされたファイルリスト。現在は画像タイプのみサポート。

auto_generate_name
boolean
デフォルト:true

タイトルを自動生成します。デフォルトはtrueです。

レスポンス

リクエスト成功。応答のコンテンツタイプと構造はリクエストのresponse_modeパラメータに依存します。

  • response_modeblockingの場合、application/json形式のChatCompletionResponseJaオブジェクトを返します。
  • response_modestreamingの場合、text/event-stream形式のChunkBasicChatEventJaオブジェクトストリームを返します。

ブロッキングモードでの完全なアプリ結果。

event
string

イベントタイプ、固定で message

:

"message"

task_id
string<uuid>

タスクID。

id
string<uuid>

ユニークID。

message_id
string<uuid>

一意のメッセージID。

conversation_id
string<uuid>

会話ID。

mode
string

アプリモード、chatとして固定。

:

"chat"

answer
string

完全な応答内容。

metadata
object

メタデータ。

created_at
integer<int64>

メッセージ作成タイムスタンプ。