This directory contains example configurations for integrating OpenClaw with Tokenomics.
- tokenomics-config.yaml - Tokenomics server config with OpenClaw support
- policies/ - Example policies for different OpenClaw deployments
slack-bot.json- Slack bot policy with budgets and security rulesdiscord-bot.json- Discord bot policypersonal-assistant.json- Personal assistant policy (mobile/desktop)enterprise-fleet.json- Enterprise multi-agent policy with team budgets
- agents/ - Example OpenClaw agent configurations
slack-config.json- OpenClaw Slack bot pointing to tokenomicsdiscord-config.json- OpenClaw Discord bot pointing to tokenomicspersonal-config.json- OpenClaw personal assistant (macOS/iOS/Android)
- .env.example - Environment variables template
- docker-compose.yml - Full stack: tokenomics + webhook collector + monitoring
- integration-test.sh - Automated integration test script
cp .env.example .env
# Edit .env and add your API keys:
# - OPENAI_PAT (your OpenAI API key)
# - ANTHROPIC_PAT (your Anthropic API key)
# - TOKENOMICS_HASH_KEY (32-char hex for token hashing)
# - TOKENOMICS_ENCRYPTION_KEY (32-char hex for encryption)# Option A: Using Docker Compose (recommended)
docker-compose up -d
# Option B: Manual setup
export $(cat .env | xargs)
tokenomics serve --dir ~/.tokenomicsVerify tokenomics is running:
curl http://localhost:8080/health
# Expected: {"status":"ok"}Create a Slack bot token:
../../bin/tokenomics token create \
--policy @policies/slack-bot.json \
--expires 1y
# Output includes:
# - Token: tkn_...
# - Hash: <sha256 hash>Store the raw token (tkn_...) for use in OpenClaw config.
Create a Discord bot token:
../../bin/tokenomics token create \
--policy @policies/discord-bot.json \
--expires 1y
# Output: Token hash abc123def...Edit agents/slack-config.json:
{
"llm": {
"api_url": "http://localhost:8080",
"api_key": "tkn_..." // Raw token from step 3
}
}./integration-test.shThis will:
- Create test tokens for each agent type
- Verify budget enforcement
- Test jailbreak detection
- Test PII masking
- Verify webhook events are received
- Generate a test report
┌─────────────────────────────────────────────────────────┐
│ OpenClaw Agents (distributed) │
│ - Slack Bot (agents/slack-config.json) │
│ - Discord Bot (agents/discord-config.json) │
│ - Personal Assistant (agents/personal-config.json) │
└──────────────┬──────────────────────────────────────────┘
│ HTTP requests to /v1/chat/completions
│ Token: Bearer {token-hash}
▼
┌─────────────────────────────────────────────────────────┐
│ Tokenomics Reverse Proxy (tokenomics-config.yaml) │
│ │
│ 1. Validate wrapper token │
│ 2. Apply policy rules │
│ - Check budget (daily/monthly) │
│ - Apply PII masking │
│ - Detect jailbreak attempts │
│ 3. Route to provider │
│ 4. Track usage in ledger │
│ 5. Send webhook events │
└────────────────┬────────────────────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
OpenAI Anthropic Azure OpenAI
│
└──────────────────────────────────────────┐
▼
┌─────────────────────┐
│ Webhook Collector │
│ (localhost:9090) │
│ │
│ Receives events: │
│ - budget.alert │
│ - security.pii │
│ - rate.exceeded │
└─────────────────────┘
examples/openclaw/
├── README.md # This file
├── .env.example # Environment variables template
├── tokenomics-config.yaml # Tokenomics server config
├── docker-compose.yml # Full stack setup
├── integration-test.sh # Automated tests
│
├── policies/ # Token policies
│ ├── slack-bot.json # Slack agent policy
│ ├── discord-bot.json # Discord agent policy
│ ├── personal-assistant.json # Personal assistant policy
│ └── enterprise-fleet.json # Multi-team policy
│
└── agents/ # OpenClaw agent configs
├── slack-config.json # Slack bot pointing to tokenomics
├── discord-config.json # Discord bot pointing to tokenomics
└── personal-config.json # Personal assistant config
./integration-test.sh --fullThis runs:
- Token creation test - Creates test tokens for each policy
- Budget enforcement test - Verifies overspending is blocked
- PII detection test - Confirms PII is masked in requests/responses
- Jailbreak detection test - Verifies jailbreak attempts are caught
- Webhook delivery test - Confirms events are sent to webhook receiver
- Performance test - Checks latency overhead
- Recovery test - Verifies proxy recovers from provider failures
tail -f ~/.tokenomics/test-results.jsonFor each OpenClaw deployment, verify:
- Token Creation: Agent token created with policy successfully
- Authentication: OpenClaw agent can authenticate to tokenomics
- Routing: Request routed to correct provider
- Budget Enforcement: Request denied when budget exceeded
- Security Rules: PII masked, jailbreak blocked
- Webhook Events: Events received by webhook collector
- Usage Tracking: Session recorded in ledger
- Performance: Proxy latency < 500ms (no slow provider)
# Check if port 8080 is in use
lsof -i :8080
# Kill conflicting process
kill -9 <PID>
# Check logs
tail -f ~/.tokenomics/tokenomics.log# Verify tokenomics is running
curl http://localhost:8080/health
# Check firewall (if using remote tokenomics)
curl -v https://tokenomics.example.com/health
# Verify token record by hash (from `token create` output)
../../bin/tokenomics token get --hash <token-hash># Start webhook collector in foreground
go run ../../examples/webhook-collector/main.go -secret my-webhook-secret
# Check tokenomics config has webhook endpoint
grep -A5 "webhooks:" tokenomics-config.yaml# Check policy has rate_limit section
cat policies/slack-bot.json | grep -A10 "rate_limit"
# Verify token is using correct policy
../../bin/tokenomics token get --hash <token-hash> | grep -A20 "\"policy\""
# Check session usage files
ls ~/.tokenomics/sessions/For production:
- Use absolute paths for all config files
- Store .env securely - Use secrets manager (Vault, Sealed Secrets, etc.)
- Enable TLS - Set
tls.enabled: truein tokenomics-config.yaml - Set up monitoring - Wire webhook events to your alerting system
- Enable high-availability - Run multiple tokenomics instances with shared Redis backend
- Backup ledger data -
.tokenomics/tokenomics.dbcontains all token data
See docs/CONFIGURATION.md, docs/POLICIES.md, and docs/EVENTS.md for production settings.
Use policies/slack-bot.json + policies/discord-bot.json for a team running multiple agents.
./integration-test.sh --team-modeUse policies/enterprise-fleet.json for cost center tracking and per-team budgets.
./integration-test.sh --enterprise-modeUse policies/personal-assistant.json for a single-user mobile/desktop deployment.
./integration-test.sh --personal-modeWith default settings (1000 req/min rate limit):
| Metric | Expected | Max |
|---|---|---|
| Latency (p50) | 50ms | 100ms |
| Latency (p99) | 200ms | 500ms |
| Throughput | 900-1000 req/min | Depends on provider |
| Memory per agent | ~5MB | ~10MB |
| CPU per 100 agents | ~1 core | ~2 cores |
- Main integration guide:
docs/OPENCLAW_INTEGRATION.md - Policy reference:
docs/POLICIES.md - Configuration reference:
docs/CONFIGURATION.md - Webhook events:
docs/EVENTS.md