How to Set Up an AI Agent on a VPS

Step-by-step guide โ€” from zero to a working AI assistant in 15 minutes

Last updated: March 2026 ยท Reading time: 10 min ยท Difficulty: Beginner

Why Use a VPS for AI Agents?

Running an AI agent on a VPS (Virtual Private Server) gives you complete control over your data, uptime, and costs. Unlike cloud-hosted AI platforms that charge per message or per seat, a self-hosted agent on a VPS has predictable monthly costs and no usage limits beyond your AI API quota.

A VPS is a virtual machine that runs 24/7 in a data center. You get root access, a dedicated IP address, and full control over what software runs on it. For AI agents, this means your assistant is always online โ€” responding to messages on Telegram, Discord, Slack, or WhatsApp around the clock, even when your laptop is closed.

The three biggest advantages of VPS-hosted AI agents are privacy, cost efficiency, and reliability. Your conversations never pass through a third-party platform. You pay a flat monthly rate for the server (typically $4-12/month) rather than per-interaction fees. And the agent stays online with 99.9% uptime, automatically restarting after any interruption.

Compared to running an agent on your local machine, a VPS eliminates the need to keep your computer on 24/7, deals with dynamic IP issues, and provides consistent performance. Compared to managed AI platforms, you avoid vendor lock-in, maintain full data ownership, and can customize every aspect of your agent's behavior.

In this guide, we will walk through every step of setting up an OpenClaw AI agent on a VPS โ€” from choosing a provider to sending your first test message. The entire process takes about 15 minutes, even if you have never used a server before.

Prerequisites โ€” What You Need Before Starting

Before you begin, gather these items. You probably already have most of them.

ItemDetailsWhere to Get It
ComputerAny Mac, Windows, or Linux machineYou are reading this on one
SSH ClientTerminal (Mac/Linux) or PuTTY (Windows)Built into your OS or putty.org
AI API KeyOpenAI, Anthropic, Google, or DeepSeekProvider's developer dashboard
VPS AccountAny provider with 1GB+ RAM, Ubuntu 22.04+Our VPS guide
Messaging AccountTelegram, Discord, Slack, or WhatsAppApp store or web signup
10-15 MinutesUninterrupted time to complete setupRight now works great
Easiest path: If you want the absolute simplest experience, use OpenClaw EasySetup โ€” it automates every step below into a single command. This guide is for those who want to understand what happens under the hood, or who want to customize the installation.

Step 1: Choose a VPS Provider

Your first decision is which VPS provider to use. The good news: OpenClaw runs on any Linux server with 1GB+ RAM, so almost any provider works. The differences come down to price, data center location, and ease of use.

For beginners, we recommend Hostinger โ€” their control panel is intuitive, support is responsive, and the KVM1 plan at $4.99/month gives you 4GB RAM, which is more than enough. If you are comfortable with the command line, Hetzner offers the best raw value at just 3.79 euros per month for 4GB RAM and 2 vCPUs.

For a detailed breakdown of every provider with benchmarks and setup guides, see our Best VPS for OpenClaw comparison.

When creating your VPS instance, choose these settings:

Once your server is created, your provider will show you an IP address and either a root password or instructions to use your SSH key. Copy these โ€” you will need them in the next step.

Step 2: Create and Access Your Server

Now connect to your new server via SSH. Open your terminal application and type the following command, replacing the IP address with the one from your provider:

ssh [email protected]

If this is your first time connecting, your terminal will ask you to confirm the server fingerprint. Type yes and press Enter. Then enter the root password provided by your VPS host.

On Windows, if you do not have the Windows Terminal with SSH support, download PuTTY from putty.org. Enter your server IP in the Host Name field, make sure Port is set to 22, and click Open. Enter root as the username and paste your password.

Once connected, you should see a command prompt that looks something like root@vps-12345:~#. You are now logged into your server and ready to install software.

Security tip: After setup is complete, we strongly recommend disabling password authentication and using SSH keys instead. OpenClaw's EasySetup handles this automatically, but if you are doing a manual install, run ssh-keygen on your local machine and copy the public key to your server.

Step 3: Install Dependencies

OpenClaw requires Node.js 20 or later. Most fresh Ubuntu servers do not have it installed, so we will add it now. Run these commands one at a time:

# Update system packages
apt update && apt upgrade -y

# Install Node.js 20 via NodeSource
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs

# Verify installation
node --version  # Should show v20.x.x
npm --version   # Should show 10.x.x

The update and upgrade step ensures your server has the latest security patches. The NodeSource script adds the official Node.js repository so you get a recent version rather than the outdated one in Ubuntu's default repos.

If you prefer to use nvm (Node Version Manager) instead, which is useful if you plan to run other Node.js projects on the same server:

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc

# Install and use Node.js 20
nvm install 20
nvm use 20

You will also want a few common utilities that OpenClaw may use:

# Install helpful utilities
apt install -y git curl wget unzip

Step 4: Install OpenClaw

With Node.js installed, deploying OpenClaw is a single command:

npx openclaw

This launches the OpenClaw interactive installer, which will:

  1. Download the latest OpenClaw release
  2. Create the project directory at /opt/openclaw
  3. Install all Node.js dependencies
  4. Initialize the SQLite database for conversation memory
  5. Create a systemd service for automatic startup
  6. Prompt you for configuration (API key, channel, personality)

The installer is conversational โ€” it asks you questions in plain English and provides sensible defaults. If you are unsure about any option, just press Enter to accept the default.

For advanced users who want a non-interactive install, you can pass flags:

npx openclaw --model claude-sonnet --channel telegram --auto

This skips the interactive prompts and uses the specified settings. You will still need to provide your API key and channel token โ€” either via environment variables or by editing the config file afterward.

Step 5: Configure Your AI Agent

The heart of your AI agent is the SOUL.md file โ€” a markdown document that defines your agent's personality, knowledge, and behavior rules. During the interactive install, OpenClaw offers five pre-built templates:

You can always edit the SOUL.md file later. It lives at /opt/openclaw/SOUL.md and is plain text, so any text editor works:

nano /opt/openclaw/SOUL.md

Your SOUL.md file should include a description of who the agent is, what it knows, how it should respond, and any rules or boundaries. For example:

# Agent Personality

You are Alex, a friendly and knowledgeable AI assistant.
You help with scheduling, research, and general questions.

## Rules
- Always be helpful and concise
- Never make up information โ€” say "I don't know" when uncertain
- Keep responses under 200 words unless asked for detail
- Use a casual but professional tone

Next, configure your AI API key. The installer stores this in /opt/openclaw/.env:

# Edit your environment file
nano /opt/openclaw/.env

# Add your API key (example for Anthropic Claude)
ANTHROPIC_API_KEY=sk-ant-your-key-here

# Or for OpenAI
OPENAI_API_KEY=sk-your-key-here

For a detailed guide on API costs and choosing the right model, see our OpenClaw Cost Guide.

Step 6: Connect a Messaging Channel and Test

The final step is connecting your agent to a messaging platform so you can actually talk to it. OpenClaw supports Telegram, Discord, Slack, and WhatsApp out of the box.

For Telegram (easiest to set up):

  1. Open Telegram and message @BotFather
  2. Send /newbot and follow the prompts to create a bot
  3. Copy the bot token BotFather gives you
  4. Add the token to your OpenClaw config: TELEGRAM_TOKEN=your-token-here

For Discord:

  1. Go to the Discord Developer Portal
  2. Create a new application, then create a bot under the Bot tab
  3. Copy the bot token and add it to your config
  4. Generate an invite link with Message Content intent enabled

Once your channel token is configured, start (or restart) the OpenClaw service:

# Start the agent
systemctl start openclaw

# Check it is running
systemctl status openclaw

# View live logs
journalctl -u openclaw -f

Now open your messaging app and send a message to your bot. You should see a response within a few seconds. If everything is working, your AI agent is live and will stay online 24/7.

Troubleshooting: If the agent does not respond, check the logs with journalctl -u openclaw -f. Common issues include an incorrect API key (check your .env file), a missing channel token, or a firewall blocking outbound HTTPS connections.

VPS Provider Cost Comparison

Choosing the right VPS provider can save you significant money over time. Here is a side-by-side comparison of the most popular options for running AI agents, tested and verified in March 2026:

ProviderPlanRAMCPUStoragePrice/moSetup Time
HetznerCX234 GB2 vCPU40 GBโ‚ฌ3.79~20 min
DigitalOceanBasic1 GB1 vCPU25 GB$6/mo~20 min
VultrCloud1 GB1 vCPU25 GB$6/mo~20 min
HostingerKVM14 GB1 vCPU50 GB$4.99/mo~10 min
AWS LightsailBasic1 GB2 vCPU40 GB$5/mo~25 min
Oracle CloudFree Tier24 GB4 ARM200 GBFree~30 min

Hetzner stands out as the best value โ€” 4GB RAM and 2 vCPUs for under $4/month is hard to beat. Their European data centers have excellent connectivity, and the Hetzner Cloud console is clean and fast.

Oracle Cloud's free tier is remarkable if you can get it. The always-free ARM instances provide 24GB RAM and 4 CPU cores, which is wildly overspecced for a single AI agent. However, availability is inconsistent and the signup process sometimes rejects new accounts in certain regions.

Hostinger is our recommendation for beginners because their onboarding flow is the most polished. You get a graphical VPS manager, one-click OS reinstalls, and responsive support. At $4.99/month for 4GB RAM, the price is competitive too.

For a more detailed comparison including benchmark results, see our full Best VPS for OpenClaw article.

Resource Requirements

How much server power does an AI agent actually need? It depends on your usage pattern. Here are our tested recommendations:

SpecMinimumRecommendedHeavy Usage
RAM1 GB4 GB8 GB+
CPU1 vCPU2 vCPU4 vCPU
Storage20 GB SSD40 GB SSD80 GB SSD
Bandwidth1 TB/mo2 TB/mo5 TB/mo
Agents1 agent2-3 agents5-10 agents
ToolsBasic chatWeb search, filesBrowser, code exec
Best ForPersonal useSmall team / power userBusiness / multi-agent

The minimum tier (1GB RAM, 1 vCPU) runs a single OpenClaw agent handling text-based chat. It works, but response processing may feel slightly slower. This is the $5-6/month tier at most providers.

The recommended tier (4GB RAM, 2 vCPU) gives you comfortable headroom. You can run multiple agents, enable web search tools, and handle file processing without memory pressure. This costs $4-8/month depending on provider.

The heavy usage tier (8GB+ RAM, 4 vCPU) is for business deployments running many agents with resource-intensive tools like browser automation or code execution sandboxes. Expect to pay $15-30/month.

Note that these resource requirements are for the OpenClaw server software only. The actual AI processing happens via API calls to cloud providers (OpenAI, Anthropic, etc.), so your VPS does not need a GPU.

Performance Benchmarks

We tested OpenClaw response times across different VPS configurations to help you understand what performance to expect. All tests used Claude 3.5 Sonnet via API, measuring the time from message received to response sent (excluding AI model latency).

Metric1GB / 1 vCPU4GB / 2 vCPU8GB / 4 vCPU
Message processing45 ms22 ms15 ms
Memory retrieval120 ms40 ms20 ms
Tool execution (web search)850 ms420 ms310 ms
Concurrent messages3-5/sec15-20/sec40-50/sec
Memory under load~650 MB~900 MB~1.2 GB
Cold start time4.2 sec2.1 sec1.4 sec

Key takeaways from our benchmarks:

For most personal AI agent use cases, the 4GB / 2 vCPU tier hits the sweet spot between performance and cost. You get fast response times, comfortable headroom, and the ability to run 2-3 agents simultaneously.

Ready to Deploy Your AI Agent?

Use EasySetup for the fastest path from zero to a working AI agent.

Get EasySetup โ€” $19 One-Time

Frequently Asked Questions

How much does it cost to run an AI agent on a VPS?

The VPS itself costs $4-12/month depending on the provider and specs you choose. On top of that, you need an AI API key โ€” costs range from $0 (using free-tier models or local Ollama) to $50+/month for heavy GPT-4 or Claude usage. Most personal users spend $10-25/month total. See our cost guide for detailed breakdowns.

Do I need programming experience to set up an AI agent?

No. OpenClaw's interactive installer handles everything automatically. You need to be able to open a terminal, paste an SSH command, and answer a few questions. If you can follow this guide, you can set up an AI agent. For the absolute easiest path, EasySetup reduces it to a single command.

Which VPS provider is best for AI agents?

For the best value, Hetzner offers 4GB RAM and 2 vCPUs for just 3.79 euros per month. For beginners, Hostinger has the friendliest interface at $4.99/month. Oracle Cloud has an unbeatable free tier if you can get approved. Read our full VPS comparison for detailed provider reviews.

Can I run multiple AI agents on one VPS?

Yes. A VPS with 4GB+ RAM comfortably runs 2-3 OpenClaw agents simultaneously. Each agent uses roughly 200-400MB of RAM depending on its configuration and tool usage. For 5 or more agents, we recommend 8GB RAM or higher.

What happens if my VPS reboots?

OpenClaw installs a systemd service that automatically restarts your agent after any reboot โ€” whether planned maintenance or unexpected. Your conversations and memory are stored in a persistent SQLite database, so nothing is lost. The agent typically comes back online within 5-10 seconds of the server starting up.

Can I use a free VPS for my AI agent?

Oracle Cloud offers an always-free tier with 24GB RAM and 4 ARM CPU cores, which is more than sufficient for OpenClaw. However, free-tier availability is limited by region and demand โ€” you may need to try multiple times to get an instance. Google Cloud and AWS also offer free tiers, but they expire after 12 months. For long-term reliability, a $4-6/month paid VPS is recommended.

How do I update OpenClaw after installation?

Run npx openclaw update from your server terminal. The updater preserves your SOUL.md configuration, API keys, and conversation history while upgrading the core software. Updates typically take under 2 minutes and require zero downtime โ€” the agent reconnects automatically after the update completes.

Next Steps

Now that your AI agent is running, here are some resources to help you get the most out of it:

๐Ÿ”ฅ Get All 10 Premium Products for $29 Save 70% with the Complete Bundle
Get Bundle โ†’