Skip to main content

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

Headers

HeaderRequiredDescription
AuthorizationYesAPI key in Bearer snorbe_... format
Content-TypeYesapplication/json

Request Body

{
  "json": {
    "modelName": "snorbe-fast",
    "inputText": "Research the latest semiconductor trends",
    "workspaceId": "cmkt9lpfe000bu95cdrcr2nbt",
    "promptKey": "chat-routing",
    "locale": "en",
    "fileUrls": [],
    "mentionedAgentRunIds": []
  }
}

Parameters

ParameterTypeRequiredDescription
modelNamestringYesModel name
inputTextstringYesInput text for the agent
workspaceIdstringYesWorkspace ID (from workspace.getDefaultWithApiKey)
promptKey"chat-routing"YesCurrently only "chat-routing" is supported
localestringYes"ja" or "en"
fileUrlsstring[]NoAttached file URLs (max 10). Default: []
triggerChatIdstringNoTriggering chat ID
mentionedAgentRunIdsstring[]NoPast AgentRun IDs referenced via @mention
maxRetriesnumberNoRetry count (0-5)
retryDelayMsnumberNoRetry delay in ms (0-10000)
maxBrowsingStepsnumberNoMax 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 StatusCodeDescription
400BAD_REQUESTValidation error
401UNAUTHORIZEDInvalid API key
429TOO_MANY_REQUESTSRate limit exceeded
500INTERNAL_SERVER_ERRORAgent execution error