Execute Agent
Execute a research agent directly. Use this when you need more control than chat.sendMessageWithApiKey provides.
For most use cases, chat.sendMessageWithApiKey is recommended. Use this endpoint when you need fine-grained control over agent execution parameters.
Request
POST /api/trpc/agentRun.executeWithApiKey
| Header | Required | Description |
|---|
Authorization | Yes | API key in Bearer snorbe_... format |
Content-Type | Yes | application/json |
Request Body
{
"json": {
"modelName": "snorbe-fast",
"inputText": "Research the latest semiconductor trends",
"workspaceId": "cmkt9lpfe000bu95cdrcr2nbt",
"promptKey": "chat-routing",
"locale": "en",
"fileUrls": [],
"mentionedAgentRunIds": []
}
}
Parameters
| Parameter | Type | Required | Description |
|---|
modelName | string | Yes | Model name |
inputText | string | Yes | Input text for the agent |
workspaceId | string | Yes | Workspace ID (from workspace.getDefaultWithApiKey) |
promptKey | "chat-routing" | Yes | Currently only "chat-routing" is supported |
locale | string | Yes | "ja" or "en" |
fileUrls | string[] | No | Attached file URLs (max 10). Default: [] |
triggerChatId | string | No | Triggering chat ID |
mentionedAgentRunIds | string[] | No | Past AgentRun IDs referenced via @mention |
maxRetries | number | No | Retry count (0-5) |
retryDelayMs | number | No | Retry delay in ms (0-10000) |
maxBrowsingSteps | number | No | Max browsing steps (1-10) |
Response
Returns the agent execution result. Response structure varies based on execution type.
{
"result": {
"data": {
"json": {
"text": "Research results...",
"finishReason": "stop",
"status": "completed",
"runId": "clxyz...",
"usage": {
"promptTokens": 1234,
"completionTokens": 567
}
}
}
}
}
Examples
# 1. Get workspace 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. Execute agent
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\":\"Latest semiconductor trends\",\"workspaceId\":\"$WORKSPACE_ID\",\"promptKey\":\"chat-routing\",\"locale\":\"en\"}}"
Error Responses
| HTTP Status | Code | Description |
|---|
| 400 | BAD_REQUEST | Validation error |
| 401 | UNAUTHORIZED | Invalid API key |
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded |
| 500 | INTERNAL_SERVER_ERROR | Agent execution error |