Agents API

Deploy, configure, and monitor your Hyperfold agents programmatically.

Overview

The Agents API provides full lifecycle management for your commerce agents, including deployment, configuration, scaling, and observability.

EndpointMethodDescription
/v1/agentsGETList all agents
/v1/agents/:idGETGet agent details
/v1/agents/deployPOSTDeploy new agent
/v1/agents/:id/configPATCHUpdate configuration
/v1/agents/:id/logsGETStream logs
/v1/agents/:id/metricsGETGet metrics

List Agents

# GET /v1/agents
# List all deployed agents
curl -X GET https://api.hyperfold.io/v1/agents \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme"
# Response
{
  "data": [
    {
      "id": "agent_neg_001",
      "name": "sales-negotiator",
      "type": "negotiator",
      "version": "1.2.0",
      "status": "running",
      "instances": 3,
      "created_at": "2025-01-15T10:00:00Z",
      "metrics": {
        "requests_24h": 4521,
        "avg_latency_ms": 340,
        "error_rate": 0.003
      }
    },
    {
      "id": "agent_ful_001",
      "name": "fulfillment-processor",
      "type": "fulfillment",
      "version": "1.0.0",
      "status": "running",
      "instances": 2
    }
  ]
}
# GET /v1/agents/:id
# Get agent details
curl -X GET https://api.hyperfold.io/v1/agents/agent_neg_001 \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme"
# Response includes full configuration
{
  "id": "agent_neg_001",
  "name": "sales-negotiator",
  "type": "negotiator",
  "version": "1.2.0",
  "status": "running",
  "config": {
    "llm_provider": "openai",
    "llm_model": "gpt-4-turbo",
    "max_tokens": 4096,
    "temperature": 0.7
  },
  "scaling": {
    "min_instances": 2,
    "max_instances": 50,
    "current_instances": 3,
    "target_concurrency": 100
  },
  "capabilities": ["negotiate", "recommend", "bundle"],
  "endpoints": {
    "acp": "https://acp.acme.hyperfold.app/negotiator"
  }
}

Deploy Agent

# POST /v1/agents/deploy
# Deploy a new agent or update existing
curl -X POST https://api.hyperfold.io/v1/agents/deploy \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "sales-negotiator",
    "type": "negotiator",
    "source": {
      "type": "git",
      "repository": "https://github.com/acme/agents",
      "branch": "main",
      "path": "negotiator/"
    },
    "config": {
      "llm_provider": "openai",
      "llm_model": "gpt-4-turbo",
      "temperature": 0.7,
      "system_prompt_override": null
    },
    "scaling": {
      "min_instances": 2,
      "max_instances": 50,
      "target_concurrency": 100
    },
    "environment": {
      "CUSTOM_VAR": "value"
    }
  }'
# Response (202 Accepted)
{
  "deployment_id": "deploy_xyz789",
  "agent_id": "agent_neg_001",
  "status": "deploying",
  "progress": {
    "stage": "building",
    "percent": 25
  },
  "estimated_completion": "2025-01-20T10:05:00Z"
}
# GET /v1/agents/deploy/:deployment_id
# Check deployment status
curl -X GET https://api.hyperfold.io/v1/agents/deploy/deploy_xyz789 \
  -H "Authorization: Bearer hf_live_xxx"
# Response
{
  "deployment_id": "deploy_xyz789",
  "agent_id": "agent_neg_001",
  "status": "completed",
  "version": "1.2.1",
  "completed_at": "2025-01-20T10:04:30Z",
  "logs_url": "https://console.hyperfold.io/deployments/deploy_xyz789/logs"
}

Deployment Sources

Source TypeDescription
gitDeploy from Git repository
dockerDeploy from container image
templateUse built-in agent template
uploadUpload source directly

Configure

# PATCH /v1/agents/:id/config
# Update agent configuration (hot reload)
curl -X PATCH https://api.hyperfold.io/v1/agents/agent_neg_001/config \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme" \
  -H "Content-Type: application/json" \
  -d '{
    "llm_model": "gpt-4o",
    "temperature": 0.5,
    "max_discount_percent": 25,
    "negotiation_style": "friendly"
  }'
# Response
{
  "agent_id": "agent_neg_001",
  "config_version": 3,
  "changes": [
    {"field": "llm_model", "from": "gpt-4-turbo", "to": "gpt-4o"},
    {"field": "temperature", "from": 0.7, "to": 0.5}
  ],
  "applied_at": "2025-01-20T10:10:00Z",
  "rollout": "immediate"
}
# PATCH /v1/agents/:id/scaling
# Update scaling configuration
curl -X PATCH https://api.hyperfold.io/v1/agents/agent_neg_001/scaling \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme" \
  -H "Content-Type: application/json" \
  -d '{
    "min_instances": 5,
    "max_instances": 100,
    "target_concurrency": 150
  }'
# POST /v1/agents/:id/restart
# Restart all agent instances
curl -X POST https://api.hyperfold.io/v1/agents/agent_neg_001/restart \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme" \
  -d '{"strategy": "rolling"}'

Logs & Metrics

# GET /v1/agents/:id/logs
# Stream agent logs
curl -X GET "https://api.hyperfold.io/v1/agents/agent_neg_001/logs?since=1h&level=info&limit=100" \
  -H "Authorization: Bearer hf_live_xxx" \
  -H "X-Project-ID: proj_acme"
# Response
{
  "logs": [
    {
      "timestamp": "2025-01-20T10:15:30.123Z",
      "level": "info",
      "message": "Session started",
      "context": {
        "session_id": "sess_abc123",
        "customer_tier": "gold"
      }
    },
    {
      "timestamp": "2025-01-20T10:15:30.456Z",
      "level": "info",
      "message": "Price quote generated",
      "context": {
        "product_id": "prod_xyz",
        "offered": 150.00,
        "counter": 162.00
      }
    }
  ],
  "meta": {
    "count": 100,
    "has_more": true,
    "next_cursor": "cursor_xyz"
  }
}
# GET /v1/agents/:id/metrics
# Get agent performance metrics
curl -X GET "https://api.hyperfold.io/v1/agents/agent_neg_001/metrics?period=24h&granularity=1h" \
  -H "Authorization: Bearer hf_live_xxx"
# Response
{
  "agent_id": "agent_neg_001",
  "period": "24h",
  "summary": {
    "total_requests": 4521,
    "success_rate": 0.997,
    "avg_latency_ms": 340,
    "p95_latency_ms": 890,
    "conversions": 1247,
    "revenue": 187450.00
  },
  "timeseries": [
    {"timestamp": "2025-01-20T00:00:00Z", "requests": 120, "latency_ms": 320},
    {"timestamp": "2025-01-20T01:00:00Z", "requests": 85, "latency_ms": 310}
  ]
}

Log Levels

LevelDescription
debugDetailed debugging information
infoGeneral operational events
warnWarning conditions
errorError events