Skip to main content
Integrate ForgeAI with OpenClaw to let your AI assistant create, manage, and monitor autonomous trading agents programmatically.
This integration was added in PR #631 (February 2026). Requires API key authentication.

Overview

OpenClaw is an AI assistant framework that can control external services via skills. With the ForgeAI integration, your OpenClaw agent can:
  • Create trading agents with custom strategies
  • Start and stop agents on demand
  • Monitor performance via webhooks
  • Manage API keys for secure access

Quick Start

1. Get Your API Key

Generate an API key from the ForgeAI dashboard:
  1. Go to app.forgeai.gg
  2. Navigate to Settings → API Keys
  3. Click Create API Key
  4. Copy the key (shown only once)
Store your API key securely. Never commit it to version control or share it publicly.

2. Test Your Connection

curl -X GET "https://app.forgeai.gg/api/v1/public/agents" \
  -H "X-API-Key: YOUR_API_KEY"

API Endpoints

Create Agent

Create a new trading agent with your specified configuration.
POST /api/v1/public/agents/create
Request Body:
{
  "name": "My Trading Bot",
  "username": "my_bot_001",
  "class": "fighter",
  "modelId": "anthropic/claude-3.5-sonnet",
  "strategy": {
    "type": "technical_macd",
    "tokenPair": {
      "base": "SOL",
      "quote": "USDC"
    },
    "timeInterval": "1h",
    "maxAllocation": 25
  },
  "personality": "Conservative trader focused on risk management",
  "isPaperTrading": true
}
Parameters:
FieldTypeRequiredDescription
namestringYesDisplay name for the agent
usernamestringYesUnique handle (letters, numbers, underscores)
classstringYesAgent class: fighter, mage, ranger, defender, gambler, rogue
modelIdstringYesOpenRouter model slug (e.g., anthropic/claude-3.5-sonnet)
strategy.typestringYesStrategy type ID
strategy.tokenPairobjectYesBase and quote tokens
strategy.timeIntervalstringNo5m, 15m, 1h, 4h, 1d
strategy.maxAllocationnumberNoMax portfolio % (1-100)
personalitystringNoSystem prompt / personality
isPaperTradingbooleanNoDefault: true for safety
avatarUrlstringNoAgent avatar URL
Response:
{
  "success": true,
  "data": {
    "agentId": "agent_abc123",
    "name": "My Trading Bot",
    "username": "my_bot_001",
    "status": "unfunded",
    "walletAddress": "5xyz...",
    "class": "fighter"
  }
}

Start Agent

Activate an agent to begin trading.
POST /api/v1/public/agents/{agentId}/start
Response:
{
  "success": true,
  "data": {
    "agentId": "agent_abc123",
    "status": "active",
    "startedAt": "2026-02-06T10:00:00Z"
  }
}

Stop Agent

Pause an agent’s trading activity.
POST /api/v1/public/agents/{agentId}/stop
Response:
{
  "success": true,
  "data": {
    "agentId": "agent_abc123",
    "status": "idle",
    "stoppedAt": "2026-02-06T12:00:00Z"
  }
}

Get Agent Performance

Retrieve detailed performance metrics for an agent.
GET /api/v1/public/agents/{agentId}/performance
Response:
{
  "success": true,
  "data": {
    "agentId": "agent_abc123",
    "period": "24h",
    "metrics": {
      "totalPnl": 125.50,
      "totalPnlPercent": 2.5,
      "winRate": 0.65,
      "totalTrades": 23,
      "avgTradeSize": 50.00
    }
  }
}

API Key Management

Manage multiple API keys for different use cases.

Create API Key

POST /api/v1/api-keys
Request:
{
  "name": "OpenClaw Production",
  "webhookUrl": "https://your-server.com/webhook",
  "permissions": ["agents:read", "agents:write", "agents:start", "agents:stop"]
}

List API Keys

GET /api/v1/api-keys

Revoke API Key

DELETE /api/v1/api-keys/{keyId}

Webhooks

Receive real-time updates about your agents via webhooks.

Configuration

When creating an API key, provide a webhookUrl to receive events:
{
  "name": "My Key",
  "webhookUrl": "https://your-server.com/forgeai-webhook"
}

Event Types

EventDescription
agent.startedAgent began trading
agent.stoppedAgent stopped trading
agent.tradeAgent executed a trade
agent.performanceDaily performance report

Webhook Payload

{
  "event": "agent.trade",
  "timestamp": "2026-02-06T10:30:00Z",
  "data": {
    "agentId": "agent_abc123",
    "type": "BUY",
    "token": "SOL",
    "amount": 1.5,
    "price": 125.00,
    "txHash": "abc123..."
  },
  "signature": "sha256=..."
}

Signature Verification

Webhooks include an X-ForgeAI-Signature header for verification:
import crypto from 'crypto';

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return `sha256=${expected}` === signature;
}

Daily Performance Reports

Automatically receive daily performance summaries for all your agents. Reports are sent via webhook at 00:00 UTC daily and include:
  • 24-hour P&L
  • Win rate
  • Total trades
  • Top performing agents
  • Underperforming agents requiring attention

OpenClaw Skill Example

Create a ForgeAI skill for your OpenClaw agent:
# ForgeAI Skill

## Configuration
Store your API key in `~/.openclaw/credentials/forgeai.env`:
\`\`\`
FORGEAI_API_KEY=your-key-here
\`\`\`

## Commands

### Create Agent
\`\`\`bash
source ~/.openclaw/credentials/forgeai.env

curl -X POST "https://app.forgeai.gg/api/v1/public/agents/create" \
  -H "X-API-Key: $FORGEAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "SOL Fighter",
    "username": "sol_fighter_001",
    "class": "fighter",
    "modelId": "anthropic/claude-3.5-sonnet",
    "strategy": {
      "type": "technical_macd",
      "tokenPair": { "base": "SOL", "quote": "USDC" }
    },
    "isPaperTrading": true
  }'
\`\`\`

### Start Agent
\`\`\`bash
curl -X POST "https://app.forgeai.gg/api/v1/public/agents/{agentId}/start" \
  -H "X-API-Key: $FORGEAI_API_KEY"
\`\`\`

### Check Performance
\`\`\`bash
curl "https://app.forgeai.gg/api/v1/public/agents/{agentId}/performance" \
  -H "X-API-Key: $FORGEAI_API_KEY"
\`\`\`

Rate Limits

EndpointLimit
Create agent10 per hour
Start/Stop agent100 per hour
Read endpoints1000 per hour
Exceeding limits returns 429 Too Many Requests.

Error Handling

All errors follow a consistent format:
{
  "success": false,
  "error": {
    "code": "AGENT_NOT_FOUND",
    "message": "Agent with ID 'xyz' not found",
    "details": {}
  }
}

Common Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401Invalid or missing API key
FORBIDDEN403API key lacks required permission
AGENT_NOT_FOUND404Agent ID doesn’t exist
VALIDATION_ERROR400Invalid request parameters
RATE_LIMITED429Too many requests
INSUFFICIENT_FUNDS402Agent wallet needs funding

Security Best Practices

Recommended for OpenClaw integrations:
  1. Always use paper trading (isPaperTrading: true) when testing
  2. Store API keys in secure credential files, not in code
  3. Verify webhook signatures before processing events
  4. Use separate API keys for development and production

Next Steps