エージェント実行
リサーチエージェントを直接実行します。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": []
}
}
パラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|
modelName | string | はい | 使用するモデル名 |
inputText | string | はい | エージェントへの入力テキスト |
workspaceId | string | はい | ワークスペース ID(workspace.getDefaultWithApiKey で取得) |
promptKey | "chat-routing" | はい | 現在は "chat-routing" のみ対応 |
locale | string | はい | "ja" または "en" |
fileUrls | string[] | いいえ | 添付ファイル URL(最大10件)。デフォルト: [] |
triggerChatId | string | いいえ | 起点となるチャット ID |
mentionedAgentRunIds | string[] | いいえ | @mention で参照する過去の AgentRun ID |
maxRetries | number | いいえ | リトライ回数(0-5) |
retryDelayMs | number | いいえ | リトライ間隔(ms、0-10000) |
maxBrowsingSteps | number | いいえ | ブラウジングの最大ステップ数(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 ステータス | コード | 説明 |
|---|
| 400 | BAD_REQUEST | バリデーションエラー |
| 401 | UNAUTHORIZED | API キーが無効 |
| 429 | TOO_MANY_REQUESTS | レート制限超過 |
| 500 | INTERNAL_SERVER_ERROR | エージェント実行エラー |