メインコンテンツへスキップ

エージェント実行

リサーチエージェントを直接実行します。chat.sendMessageWithApiKey よりも細かい制御が必要な場合に使用します。
通常は chat.sendMessageWithApiKey の使用を推奨します。このエンドポイントはエージェント実行の詳細なパラメータが必要な場合に使います。

リクエスト

POST /api/trpc/agentRun.executeWithApiKey

ヘッダー

ヘッダー必須説明
AuthorizationはいBearer snorbe_... 形式の API キー
Content-Typeはいapplication/json

リクエストボディ

{
  "json": {
    "modelName": "snorbe-fast",
    "inputText": "半導体の最新トレンドを調べて",
    "workspaceId": "cmkt9lpfe000bu95cdrcr2nbt",
    "promptKey": "chat-routing",
    "locale": "ja",
    "fileUrls": [],
    "mentionedAgentRunIds": []
  }
}

パラメータ

パラメータ必須説明
modelNamestringはい使用するモデル名
inputTextstringはいエージェントへの入力テキスト
workspaceIdstringはいワークスペース ID(workspace.getDefaultWithApiKey で取得)
promptKey"chat-routing"はい現在は "chat-routing" のみ対応
localestringはい"ja" または "en"
fileUrlsstring[]いいえ添付ファイル URL(最大10件)。デフォルト: []
triggerChatIdstringいいえ起点となるチャット ID
mentionedAgentRunIdsstring[]いいえ@mention で参照する過去の AgentRun ID
maxRetriesnumberいいえリトライ回数(0-5)
retryDelayMsnumberいいえリトライ間隔(ms、0-10000)
maxBrowsingStepsnumberいいえブラウジングの最大ステップ数(1-10)

レスポンス

エージェント実行結果が返ります。レスポンス構造は実行内容により異なります。
{
  "result": {
    "data": {
      "json": {
        "text": "調査結果...",
        "finishReason": "stop",
        "status": "completed",
        "runId": "clxyz...",
        "usage": {
          "promptTokens": 1234,
          "completionTokens": 567
        }
      }
    }
  }
}

使用例

# 1. ワークスペース ID を取得
WORKSPACE_ID=$(curl -s \
  "https://app.snorbe.com/api/trpc/workspace.getDefaultWithApiKey" \
  -H "Authorization: Bearer snorbe_your_api_key_here" \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['data']['json']['workspaceId'])")

# 2. エージェントを実行
curl -X POST "https://app.snorbe.com/api/trpc/agentRun.executeWithApiKey" \
  -H "Authorization: Bearer snorbe_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d "{\"json\":{\"modelName\":\"snorbe-fast\",\"inputText\":\"半導体の最新トレンド\",\"workspaceId\":\"$WORKSPACE_ID\",\"promptKey\":\"chat-routing\",\"locale\":\"ja\"}}"

エラーレスポンス

HTTP ステータスコード説明
400BAD_REQUESTバリデーションエラー
401UNAUTHORIZEDAPI キーが無効
429TOO_MANY_REQUESTSレート制限超過
500INTERNAL_SERVER_ERRORエージェント実行エラー