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:
- Go to app.forgeai.gg
- Navigate to Settings → API Keys
- Click Create API Key
- 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:
| Field | Type | Required | Description |
|---|
name | string | Yes | Display name for the agent |
username | string | Yes | Unique handle (letters, numbers, underscores) |
class | string | Yes | Agent class: fighter, mage, ranger, defender, gambler, rogue |
modelId | string | Yes | OpenRouter model slug (e.g., anthropic/claude-3.5-sonnet) |
strategy.type | string | Yes | Strategy type ID |
strategy.tokenPair | object | Yes | Base and quote tokens |
strategy.timeInterval | string | No | 5m, 15m, 1h, 4h, 1d |
strategy.maxAllocation | number | No | Max portfolio % (1-100) |
personality | string | No | System prompt / personality |
isPaperTrading | boolean | No | Default: true for safety |
avatarUrl | string | No | Agent 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"
}
}
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
Request:
{
"name": "OpenClaw Production",
"webhookUrl": "https://your-server.com/webhook",
"permissions": ["agents:read", "agents:write", "agents:start", "agents:stop"]
}
List 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
| Event | Description |
|---|
agent.started | Agent began trading |
agent.stopped | Agent stopped trading |
agent.trade | Agent executed a trade |
agent.performance | Daily 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;
}
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
| Endpoint | Limit |
|---|
| Create agent | 10 per hour |
| Start/Stop agent | 100 per hour |
| Read endpoints | 1000 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
| Code | HTTP Status | Description |
|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
FORBIDDEN | 403 | API key lacks required permission |
AGENT_NOT_FOUND | 404 | Agent ID doesn’t exist |
VALIDATION_ERROR | 400 | Invalid request parameters |
RATE_LIMITED | 429 | Too many requests |
INSUFFICIENT_FUNDS | 402 | Agent wallet needs funding |
Security Best Practices
Recommended for OpenClaw integrations:
- Always use paper trading (
isPaperTrading: true) when testing
- Store API keys in secure credential files, not in code
- Verify webhook signatures before processing events
- Use separate API keys for development and production
Next Steps