LoopFour

Agents API

AI-powered agents for data extraction, content generation, and decision making

Agents API

Agents are AI-powered execution units that can be used in workflow steps. The platform provides both core agents (available to all companies) and the ability to create custom agents.

Core Agents

Four universal core agents are available to all companies:

IDNameTypeDescription
agent_extractionUniversal Extraction AgentextractionExtract structured data from documents with confidence scoring
agent_contentContent Generation AgentcontentGenerate professional emails, messages, and notifications
agent_transformData Transformation AgenttransformTransform data between formats and schemas
agent_decisionDecision & Routing AgentdecisionMake business decisions and route based on criteria

Agent Scopes

ScopeDescription
globalAvailable to all companies (core agents)
companyRestricted to the creating company

List Agents

Retrieve all agents available to your company, including core agents and custom agents.

GET /api/v1/agents

Query Parameters

ParameterTypeDefaultDescription
typestring-Filter by type: extraction, content, transform, decision, code, classification, custom
statusstring-Filter by status: active, deprecated
searchstring-Search by agent name
includeBuiltInbooleantrueInclude core agents in results
limitnumber50Number of results (1-100)
cursorstring-Cursor for pagination

Example

curl -X GET "http://localhost:3000/api/v1/agents?type=extraction" \
  -H "x-api-key: YOUR_API_KEY"

Create Agent

Create a new custom agent for your company.

POST /api/v1/agents

Request Body

FieldTypeRequiredDescription
namestringYesAgent display name
descriptionstringNoAgent description
typestringYesAgent type (see below)
providerstringNoAI provider: openai (default), anthropic
modelstringNoModel ID (defaults to gpt-4o)
systemPromptstringYesSystem prompt defining agent behavior
outputSchemaobjectNoJSON Schema for structured output
temperaturenumberNoTemperature (0.0-2.0), defaults to 0.7
maxTokensnumberNoMax tokens in response, defaults to 4096

Agent Types

TypeDescription
extractionExtract structured data from documents/text
contentGenerate text content (emails, messages, etc.)
transformTransform data between formats
decisionMake decisions and classify items
codeGenerate or analyze code
classificationClassify inputs into categories
customCustom agent with user-defined behavior

Supported Models

ProviderModels
OpenAIgpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, o1, o3-mini
Anthropicclaude-3-5-sonnet-latest, claude-3-5-haiku-latest, claude-3-opus-latest

Get Agent

Retrieve details of a specific agent, including core agents.

GET /api/v1/agents/:id

Path Parameters

ParameterTypeDescription
idstringAgent ID or core agent ID (e.g., agent_extraction)

Update Agent

Update a custom agent. Each update increments the version number.

PUT /api/v1/agents/:id

Only company-owned agents can be updated. Core agents and agents from other companies cannot be modified.

Delete Agent

Soft delete an agent. The agent is marked as deprecated and will no longer appear in listings.

DELETE /api/v1/agents/:id

Core agents cannot be deleted. Only company-owned agents can be removed.

Test Agent

Test an agent with sample input to verify configuration and output.

POST /api/v1/agents/:id/test

Request Body

FieldTypeRequiredDescription
inputobjectYesInput variables for the agent
userMessagestringNoOptional user message override

Core agents cannot be directly tested via API. Create a workflow with an agent step to test built-in agents.

Execute Agent

Execute an agent standalone (outside of a workflow context).

POST /api/v1/agents/:id/execute

Request Body

FieldTypeRequiredDescription
inputobjectYesInput variables for the agent
userMessagestringNoUser message for the agent
workflowRunIdstringNoOptional workflow run ID for tracking
overridesobjectNoRuntime parameter overrides

Overrides

FieldTypeDescription
temperaturenumberOverride temperature for this execution
maxTokensnumberOverride max tokens
modelstringOverride model for this execution

List Agent Executions

Retrieve execution history for an agent.

GET /api/v1/agents/:id/executions

Query Parameters

ParameterTypeDefaultDescription
limitnumber50Number of results (1-100)
cursorstring-Cursor for pagination

Core Agent Input Variables

Universal Extraction Agent (agent_extraction)

VariableTypeDescription
documentstringDocument content to extract from
schemaobjectJSON Schema defining fields to extract
fieldsarrayList of field definitions (alternative to schema)
documentTypestringDocument type hint (invoice, receipt, contract)
customInstructionsstringAdditional extraction instructions

Content Generation Agent (agent_content)

VariableTypeDescription
contentTypestringemail, message, summary, notification
tonestringprofessional, friendly, formal, casual, urgent
formatstringtext, html, markdown
recipientstringWho the content is for
subjectstringSubject or topic
contextstringBackground context
keyPointsarrayKey points to include
customInstructionsstringAdditional instructions

Data Transformation Agent (agent_transform)

VariableTypeDescription
dataanyData to transform
sourceSchemaobjectSchema of input data
targetSchemaobjectDesired output schema
mappingRulesarrayField mapping rules
defaultValuesobjectDefault values for missing fields
customInstructionsstringAdditional instructions

Decision & Routing Agent (agent_decision)

VariableTypeDescription
dataanyData to evaluate
decisionTypestringapproval_routing, classification, priority
optionsarrayAvailable decision options
criteriaarrayEvaluation criteria
thresholdsobjectThreshold values
contextstringAdditional context
customInstructionsstringAdditional instructions

Error Responses

Agent Not Found (404)

{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Agent not found"
  }
}

Cannot Modify Built-in Agent (400)

{
  "success": false,
  "error": {
    "code": "BAD_REQUEST",
    "message": "Cannot modify built-in agents"
  }
}

Duplicate Name (400)

{
  "success": false,
  "error": {
    "code": "BAD_REQUEST",
    "message": "An agent with the name \"Invoice Extractor\" already exists"
  }
}