The Raspberry Pi is the perfect platform for a personal AI agent. Low power, always-on, and completely under your control. If you want to self-host OpenClaw without a power-hungry server, the Pi is your answer.
This guide walks you through installing and optimizing OpenClaw on a Raspberry Pi 4. By the end, you'll have a fully functional AI agent running on $50 hardware.
What You'll Need
- Raspberry Pi 4 (4GB or 8GB RAM)
- MicroSD card (32GB+) or USB SSD
- Power supply (USB-C, 3A+)
- Internet connection (WiFi or Ethernet)
- OpenAI API key
Note: Raspberry Pi 3 will work but is noticeably slower. Pi Zero and Pi 2 are not recommended due to insufficient RAM.
Why Run on Raspberry Pi?
Low Power
5-7 watts vs 50-100W for a desktop. Perfect for 24/7 operation.
Affordable
$50-100 total cost vs $500+ for a server or ongoing cloud fees.
Private
Your data stays on your hardware. No cloud dependencies.
Always-On
No sleep mode. Your agent is ready whenever you need it.
Step 1: Prepare Your Pi
Start with a fresh Raspberry Pi OS (64-bit) installation:
- Download Raspberry Pi Imager
- Install Raspberry Pi OS (64-bit) on your SD card/SSD
- Boot the Pi and complete initial setup
- Enable SSH:
sudo raspi-config→ Interface Options → SSH - Update system:
sudo apt update && sudo apt upgrade -y
Step 2: Install OpenClaw
Install Node.js and OpenClaw:
# Install Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Verify installation
node --version # Should show v20.x.x
npm --version
# Install OpenClaw globally
sudo npm install -g openclaw
# Verify installation
openclaw --versionStep 3: Configure OpenClaw
Set up your agent configuration:
# Create agent directory
mkdir ~/my-agent
cd ~/my-agent
# Initialize OpenClaw
openclaw init
# Set your OpenAI API key
export OPENAI_API_KEY=your-api-key-here
# Edit configuration
nano openclaw.yamlAdd your API key to ~/.bashrc for persistence:
echo 'export OPENAI_API_KEY=your-api-key-here' >> ~/.bashrc
source ~/.bashrcStep 4: Optimize for Pi
Raspberry Pi has limited resources. Optimize OpenClaw for better performance. See our memory optimization guide for detailed tips.
# openclaw.yaml optimizations for Pi
memory:
conversation:
max_messages: 10 # Reduce for Pi's limited RAM
max_tokens: 2000
model:
default: gpt-3.5-turbo # Faster, cheaper than GPT-4
timeout:
request: 30000 # 30 second timeoutStep 5: Run Your Agent
Start your agent:
# Run in foreground
openclaw run
# Or run with PM2 for auto-restart
sudo npm install -g pm2
pm2 start openclaw --name my-agent
pm2 save
pm2 startupConnect to your Pi agent via Telegram or Discord to control it from anywhere.
Troubleshooting
Slow Performance?
- Switch to USB SSD if using SD card
- Use GPT-3.5 instead of GPT-4
- Reduce conversation history limits
- Check CPU temperature:
vcgencmd measure_temp
Out of Memory?
- Increase swap:
sudo dphys-swapfile swapoff && sudo nano /etc/dphys-swapfile - Run fewer agents simultaneously
- Close unnecessary system services
FAQ
Frequently Asked Questions
Which Raspberry Pi models work?
How much power does it use?
Can I run multiple agents?
Is it fast enough?
Should I use SD card or SSD?
Final Thoughts
Running OpenClaw on a Raspberry Pi is a practical way to self-host your AI agent. It's not as fast as a desktop or cloud server, but for $50 you get a private, always-on assistant that uses minimal power.
The Pi shines for personal use, home automation integrations, and learning. For production workloads with many users, consider managed hosting or a more powerful server.
Ready to Build Your Pi Agent?
Deploy OpenClaw on your Raspberry Pi and start building today.
Get Started →