OpenClaw can be self-hosted in your own infrastructure — full data control, no vendor lock-in. In this lesson, you'll set up a production-ready instance.
| Component | Minimum | Recommended (Production) |
|---|---|---|
| CPU | 4 cores | 8+ cores |
| RAM | 8 GB | 16+ GB |
| Storage | 50 GB SSD | 200+ GB NVMe |
| OS | Linux (Ubuntu 22.04+) | Linux (Ubuntu 24.04) |
| Docker | 24.0+ | 25.0+ with Compose v2 |
| Database | PostgreSQL 15 | PostgreSQL 16 with pgvector |
git clone https://github.com/agentos/openclaw.git
cd openclaw
cp .env.example .env
The .env file contains all essential settings:
# Database
DATABASE_URL=postgresql://openclaw:secret@db:5432/openclaw
REDIS_URL=redis://redis:6379
# API Keys
OPENCLAW_API_KEY=oc_live_...
OPENCLAW_SECRET=your-secret-key
# Retention
TRACE_RETENTION_DAYS=90
LOG_RETENTION_DAYS=30
# Feature Flags
ENABLE_ALIGNMENT_SCORING=true
ENABLE_COMPLIANCE_MODULE=true
docker compose up -d
OpenClaw starts the following services:
docker compose exec api openclaw init
docker compose exec api openclaw admin create --email admin@example.com
OpenClaw provides SDKs for all common agent frameworks:
# Python
pip install openclaw-sdk
# Node.js
npm install @openclaw/sdk
# Go
go get github.com/agentos/openclaw-go
from openclaw import OpenClaw
oc = OpenClaw(
api_key="oc_live_...",
endpoint="https://openclaw.your-domain.com",
environment="production"
)
OpenClaw uses a hierarchical key system:
Best Practice: Use a separate Project Key per agent deployment. This lets you control access granularly and isolate individual agents in emergencies without affecting others.