Hosting
Servers
Web Development Pricing
Resources
Get started → Log in
Home/Blog/VPS for AI agents

VPS for AI agents:
run Claude Code and Codex 24/7.

27 November 20269 min readBy the RapidServer team

Why run an AI agent on a VPS?

An AI agent such as Claude Code, OpenAI's Codex CLI or your own bot sends its prompts to a model provider's API, then runs commands and edits files on the machine it lives on. A VPS keeps that machine online 24/7 when your laptop sleeps, keeps the agent away from your personal files, and gives it a fixed IP and NVMe storage. The model runs on the provider's servers, so a CPU VPS is enough.

What a CPU VPS can and cannot run

A virtual private server for AI agents doesn't need a GPU when the model runs elsewhere. Claude Code calls Anthropic, Codex CLI calls OpenAI, and agents built on their SDKs do the same. For visual AI workflows, see n8n self-hosting on a VPS.

WorkloadOn our VPSWhy
Claude Code, Codex CLI and other coding agentsRuns wellThe model runs at the provider; the VPS runs commands and tests.
Your own agents, bots and n8n workflows on a model APIRuns wellSmall processes that must stay online.
Agents that drive a headless browserRuns, with more RAMEach browser needs its own memory.
Small local models on CPURuns, slowlyWithout a GPU, answers come far slower than from a hosted API.
Large local LLMs, fine-tuning or trainingNot a fitOur VPS plans have no GPU.

Every RapidServer VPS is a KVM server with dedicated vCPU, NVMe and full root, but no GPU.

Secure Linux setup

  1. Deploy Ubuntu 24.04 LTS or Debian 12. Anthropic's Claude Code setup page lists Ubuntu 20.04+ and Debian 10+ with 4 GB of RAM or more. Add your SSH key in the client area first: every new VPS boots with it installed and password login disabled.
  2. Create an admin user with sudo and close root login, as in our developer setup steps.
  3. Give the agent its own user, without sudo, so a bad command can reach only that user's files. Keep it out of the docker group too, which is close to root.

sudo adduser --disabled-password agent

Switch to it with sudo -iu agent. An agent that only calls APIs needs no open port except SSH: run sudo ufw allow OpenSSH, then sudo ufw enable. Add fail2ban and unattended-upgrades for security updates.

Install Python, Node.js and the agent

sudo apt update && sudo apt install -y git tmux python3-venv

Python comes with Ubuntu and Debian; give each project its own environment with python3 -m venv .venv. For Node.js, install a current LTS release from nodejs.org or with nvm, as distribution packages can lag behind.

Claude Code

Claude Code runs in the terminal, so it works over SSH. As the agent user, run Anthropic's native installer:

curl -fsSL https://claude.ai/install.sh | bash

Then run claude in a project folder. You need a paid Claude plan or a Claude Console account. With no browser on the server, press c to copy the login link, open it on your laptop and paste the code back if asked, or set ANTHROPIC_API_KEY (Anthropic's login guide).

Codex CLI and other agents

OpenAI's Codex CLI is a coding agent that runs locally, which here means on the server. Install it with npm install -g @openai/codex or OpenAI's install script, then run codex. On a headless server, sign in with codex login --device-auth (a beta, switched on in ChatGPT's security settings) or with an API key (OpenAI's sign-in guide). Other agents follow the same pattern: one CLI or script, one key, one Linux user.

Keep it running: tmux or systemd

Anything started in a plain SSH session stops when you disconnect.

tmux for interactive agents such as Claude Code and Codex:

tmux new -s agent

Start the agent, detach with Ctrl+B then D, and log out; it keeps working. Later, run tmux attach -t agent from your laptop or phone.

systemd for agents that run on their own, such as a bot or a worker loop, so they start at boot and restart after a crash. Create /etc/systemd/system/my-agent.service; under [Service], the key lines are:

LineWhat it does
User=agentRuns it as the agent user, not root
WorkingDirectory=/home/agent/my-agentStarts in the project folder
EnvironmentFile=/home/agent/.config/my-agent.envLoads the API keys
ExecStart=/home/agent/my-agent/.venv/bin/python main.pyStarts your agent
Restart=alwaysRestarts it after a crash

Add WantedBy=multi-user.target under [Install] so it starts at boot, then run:

sudo systemctl daemon-reload && sudo systemctl enable --now my-agent

Follow its logs with journalctl -u my-agent -f. For scheduled jobs, cron or a systemd timer can call Claude Code's non-interactive mode, claude -p, which refuses actions that need approval unless you allow those tools with --allowedTools. Authenticate it with a Console API key, or a token from claude setup-token on a Claude plan.

Keeping API keys safe

  • One locked file. Keep keys in an environment file such as ~/.config/my-agent.env, owned by the agent user, with chmod 600. In tmux, load it with set -a; . ~/.config/my-agent.env; set +a.
  • Never in git. Add env files to .gitignore. Git keeps history, so a key committed once stays readable after you delete it.
  • One key per project, with a limit. Create separate keys in the Anthropic or OpenAI console and set spending limits there, so a leak or a runaway loop has a ceiling. If a key may have leaked, revoke it and make a new one.
  • Login files count too. ~/.claude/.credentials.json and ~/.codex/auth.json hold tokens; OpenAI says its file is plain text, so keep it private and never commit it.

Sizing by workload

WorkloadStarting planPer month
One coding agent, or a small bot on a model APIStardust: 2 vCPU, 4 GB RAM, 20 GB NVMe₹581
An agent across several repositories and build cachesNew Moon: 2 vCPU, 4 GB RAM, 40 GB NVMe₹674
Several agents at once, Docker, a database or a headless browserFull Moon: 4 vCPU, 8 GB RAM, 160 GB NVMe₹1,723
A shared agent server for a team, with CIEclipse: 8 vCPU, 16 GB RAM, 320 GB NVMe₹3,445

Every plan meets Claude Code's 4 GB RAM minimum. Builds, tests, Docker, browsers and parallel agents are what grow the server. Watch free -m for a week, then resize from the client area with the difference prorated. Prices exclude 18% GST. For websites, see how much VPS you need.

A server your agents can live on.

KVM with dedicated vCPU, NVMe and full root in Mumbai or Delhi NCR, ready a few minutes after payment, from ₹581/mo.

See VPS hosting plans

Mumbai or Delhi?

Mumbai (BOM1) and Delhi NCR (DEL1) cost the same. An agent talks mostly to its model provider and to you, so pick the city nearest you, or nearest the servers the agent works on. Mumbai suits western and southern India and international traffic; Delhi NCR suits Delhi, Noida, Gurugram and the north. The two are about 22 ms apart, and our team moves a VPS between them for free. See latency from each city.

Backups and your own git remote

Every RapidServer VPS gets daily backups kept for 7 days, plus snapshots on demand. Take a snapshot before a big agent refactor or a package upgrade, and roll back if it goes wrong.

Also push to your own git remote, such as a private GitHub or GitLab repository. Have the agent work on a branch and push after each task, using a deploy key limited to that repository. Backups protect the server; the remote protects the work and lets you review every change.

What it costs

  • The server: a fixed RapidServer price from ₹581/mo plus 18% GST, billed monthly in rupees with a GST invoice. It costs the same whether the agent is busy or idle, with no yearly lock-in.
  • The model: your Claude or ChatGPT plan, or API usage, billed separately by Anthropic, OpenAI or whichever provider you use. RapidServer isn't affiliated with them and doesn't sell their plans or API credits.

Questions

Can I run Claude Code on a VPS?+
Yes. Claude Code is a terminal tool, and Anthropic lists Ubuntu 20.04+ and Debian 10+ with 4 GB of RAM or more. Install it as a non-root user, sign in with the login link or a Console API key, and run it in tmux. It needs a paid Claude plan or a Console account.
Can I use a VPS for OpenAI Codex?+
Yes. Codex CLI runs in the terminal of the machine you install it on, so it works on a Linux VPS over SSH. Sign in with ChatGPT through device code login or with an API key, and keep it in tmux.
Do I need a GPU VPS to run AI agents?+
Not for agents that call a hosted model such as Claude or GPT, because the model runs at the provider. A GPU matters only for running large models yourself or training them, and RapidServer VPS plans have no GPU.
Can I run a local LLM on a CPU VPS?+
Small open models run on CPU, but slowly compared with a hosted API, and bigger models need far more RAM. That is fine for experiments; for an agent that must reply quickly, call a hosted model.
How much RAM does a VPS for AI agents need?+
4 GB runs one coding agent or a small bot: our Stardust plan with 2 dedicated vCPU, at ₹581/mo. For several agents, Docker or headless browsers, start with Full Moon: 4 vCPU and 8 GB RAM.
Is it safe to keep API keys on a VPS?+
Yes, with care: an env file owned by the agent's user with chmod 600, never in git, a separate key per project with a spending limit, and the agent running without sudo. Revoke any key you think has leaked.
Can I run OpenClaw on a VPS?+
Yes. OpenClaw runs as one Gateway process on Linux and talks to your chat apps and model provider, so a CPU VPS keeps it online around the clock. Keep the Gateway on loopback and reach it through an SSH tunnel, as its docs advise. Setup, sizing and security: OpenClaw VPS hosting.
AI agent ke liye kaunsa VPS lena chahiye?+
Agar aapka agent Claude ya OpenAI jaise cloud model ka API use karta hai, to GPU ki zaroorat nahi, normal Linux VPS kaafi hai. Ek agent ke liye Stardust (2 vCPU, 4 GB RAM) ₹581/mo plus GST se shuru karein. API ka bill provider alag se leta hai. Basics ke liye VPS kya hai padhein.

Give your agents a server that never sleeps.

KVM VPS with dedicated vCPU, NVMe and full root in Mumbai or Delhi NCR, billed monthly in rupees with a GST invoice.