Back to Blog
ai Mar 7, 2026 6 min read

How to Run an AI Agent on a VPS: Complete Guide

H

HowToDeploy Team

Lead Engineer @ howtodeploy

How to Run an AI Agent on a VPS: Complete Guide

Running your own AI agent on a VPS gives you full control over your data, eliminates per-message fees, and lets you customize everything. This guide covers what you need, how to choose the right setup, and two ways to deploy — manual and one-click.


What you need

A cloud provider account

You need a VPS (Virtual Private Server) from any major cloud provider. Here are the recommended options, sorted by cost:

ProviderCheapest planRAMStorageMonthly cost
HetznerCX224GB40GB€4.35
VultrCloud Compute1GB25GB$5.00
DigitalOceanBasic Droplet1GB25GB$6.00
LinodeNanode1GB25GB$5.00
AWS EC2t3.micro1GB8GB~$8.50

For most AI agents, 1-2GB RAM is sufficient. If you're running agent swarms or multiple concurrent conversations, start with 4GB.

An LLM API key

Most AI agent frameworks connect to an LLM provider for the actual AI reasoning. You'll need an API key from one of:

  • Anthropic (Claude) — best for complex reasoning and tool use
  • OpenAI (GPT-4o) — widest ecosystem and plugin support
  • Google (Gemini) — strong multimodal capabilities
  • xAI (Grok) — real-time information access

The cost depends on usage. For a personal agent handling 50-100 messages per day, expect $5-15/month in API costs.

Messaging platform credentials

If you want your AI agent to respond on messaging platforms, you'll need bot tokens or API credentials for each channel:

  • Telegram — BotFather token (free)
  • Discord — Bot token via Discord Developer Portal (free)
  • WhatsApp — WhatsApp Business API access
  • Slack — Slack App with bot permissions (free)
  • Signal — Signal CLI or signald setup

Option 1: Manual deployment

This is the traditional approach — SSH into a server, install dependencies, and configure everything by hand.

Step 1: Provision a server

Create a VPS with your chosen provider. Select:

  • OS: Ubuntu 22.04 LTS (most compatible)
  • Region: closest to your users for lowest latency
  • Size: 1-2GB RAM minimum

Step 2: SSH into your server

ssh root@your-server-ip

Step 3: Update system packages

apt update && apt upgrade -y

Step 4: Install dependencies

The specific dependencies vary by agent framework. For a Node.js-based agent like Nanoclaw:

# Install Node.js 20
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
 
# Install build tools
apt install -y git build-essential
 
# Install PM2 for process management
npm install -g pm2

Step 5: Clone and configure the agent

git clone https://github.com/qwibitai/nanoclaw.git /opt/nanoclaw
cd /opt/nanoclaw
npm install

Create an environment file with your configuration:

cat > .env << EOF
ANTHROPIC_API_KEY=your-api-key
TELEGRAM_BOT_TOKEN=your-telegram-token
DISCORD_BOT_TOKEN=your-discord-token
ADMIN_EMAIL=your@email.com
EOF

Step 6: Start the agent

pm2 start npm --name "nanoclaw" -- start
pm2 save
pm2 startup

Step 7: Set up a reverse proxy (optional)

If the agent has a web interface, install Caddy for automatic HTTPS:

apt install -y caddy

Configure Caddy:

your-domain.com {
    reverse_proxy localhost:3000
}

The manual approach takes 30-60 minutes

And that's for a straightforward setup. If you hit dependency conflicts, OS version differences, or configuration issues, it can take much longer.


Option 2: One-click deployment

HowToDeploy automates the entire process above. Connect your cloud provider, pick an AI agent, fill in your API keys, and click Deploy.

Step 1: Connect your cloud provider

Go to Settings → Cloud Providers and add your API key for DigitalOcean, Hetzner, Vultr, Linode, or AWS.

Step 2: Choose an AI agent

Browse the app catalog and select the agent that fits your use case:

  • Nanoclaw — Claude agent with WhatsApp/Telegram/Discord/Slack/Signal
  • Openclaw — Personal AI gateway with 10+ channels and mobile apps
  • Zeroclaw — Minimal Rust agent (~5MB RAM) for edge/IoT
  • Tinyclaw — Multi-agent teams with web dashboard
  • Picoclaw — Single Go binary, 6 channels, boots in under 1 second

Step 3: Fill in the config

Enter only the required fields — typically your LLM API key, admin email, and messaging bot tokens.

Step 4: Click Deploy

HowToDeploy provisions the server, installs all dependencies, configures the agent, sets up SSL, and streams progress back to you in real time. The entire process takes 3-5 minutes.


Choosing the right AI agent framework

FrameworkLanguageRAM usageChannelsBest for
NanoclawNode.js~1GB5Teams, multi-channel support
OpenclawNode.js~1GB10+Personal AI, mobile access
ZeroclawRust~5MBMultipleEdge, IoT, resource-constrained
TinyclawNode.js~1GB3Multi-agent teams, task management
PicoclawGo<10MB6Simple setup, quick deployment

For personal use

Start with Picoclaw (simplest) or Openclaw (most channels + mobile apps).

For teams

Nanoclaw is the best balance of features and simplicity. If you need multiple specialized agents, go with Tinyclaw.

For edge/IoT

Zeroclaw is the only choice — 5MB RAM and no external dependencies.


Security considerations

Running an AI agent on a VPS means you're responsible for security. Key practices:

  • Keep your server updated — enable automatic security updates
  • Use SSH keys, not passwords — disable password authentication in sshd_config
  • Firewall — only open ports you need (22 for SSH, 443 for HTTPS)
  • Encrypt secrets — store API keys in environment variables, never in code
  • Monitor logs — watch for unusual activity or excessive API usage

HowToDeploy handles SSH key generation, firewall configuration, and secret management automatically for one-click deployments.


Cost breakdown

Here's what running a self-hosted AI agent actually costs:

ItemMonthly cost
VPS (Hetzner)$4.50
LLM API usage$5-30 (varies)
Domain (optional)~$1 (annual/12)
Total$10-35/month

Compare that to SaaS AI agent platforms that charge $50-200/month per seat, plus per-message fees.


Next steps

  1. Connect a cloud provider — takes 2 minutes
  2. Pick an AI agent — browse the catalog
  3. Deploy — one click, 3-5 minutes

Get started →