How to host an AI agent: a beginner's guide
A simple guide to hosting your first AI agent. from running it locally to deploying on a VPS or cloud server. Covers the basics of Docker, API keys, and keeping your agent running.
TL;DR: Hosting an AI agent is simpler than it sounds. You don’t need a GPU: your agent calls LLM APIs remotely. The quickest path is Docker + Railway: write a Dockerfile, set API keys as environment variables, deploy with a git push. Costs $5-20/month.
So you built an AI agent on your laptop. It works. Now you want it live so you can access it from anywhere, share it with a team, or point a webhook at it. Hosting is the step between “works on my machine” and “works for other people.”
This guide covers the simplest path to getting your agent on a server. For a deeper dive into production infrastructure, see the detailed deployment server guide.
Key takeaways:
- No GPU needed: your agent calls LLM APIs, not runs them
- Docker + Railway is the quickest path: 5 minutes from repo to live URL
- Store API keys as environment variables, never in code
- Add health checks so you know when your agent goes down
- Start with a platform, graduate to a VPS when you outgrow it
What you need
An AI agent is just code that calls LLM APIs. It doesn’t need a GPU or specialized hardware. Any server that can run Python or Node.js can host it.
| Requirement | Minimum | Recommended |
|---|---|---|
| RAM | 256 MB | 1 GB |
| CPU | 1 core | 2 cores |
| Storage | 1 GB | 10 GB |
| OS | Linux | Ubuntu 22.04+ |
Option 1: Railway (simplest)
Railway is the fastest way to get an agent online. It auto-detects your project type and handles Docker builds, networking, and SSL.
- Create a Railway account and install the CLI
- Connect your GitHub repo
- Add API keys as environment variables in the dashboard
- Run
railway upor connect the repo for auto-deploy - Get a
yourapp.railway.appURL
Railway handles restart on crash, logs, and basic monitoring out of the box. For a personal agent or prototype, this is all you need.
Option 2: VPS (more control)
For production workloads or when you need full control over the environment, a VPS from DigitalOcean, Hetzner, or Linode gives you a Linux server to work with.
# After SSHing into your VPS
apt update && apt install -y docker.io
git clone https://github.com/you/your-agent.git
cd your-agent
export ANTHROPIC_API_KEY=sk-ant-..
docker build -t my-agent .
docker run -d -p 8080:8080 --name my-agent my-agent
Your agent is now live on http://your-server-ip:8080. Add Nginx as a reverse proxy for SSL and a custom domain.
Keeping it running
Two things matter after deployment:
Health checks. Add a /health endpoint to your agent that returns 200. Your hosting platform can ping this every minute and restart the agent if it stops responding.
Restart policy. Docker’s --restart unless-stopped flag ensures your agent comes back up after a crash or server reboot. Always use it.
docker run -d --restart unless-stopped -p 8080:8080 --name my-agent my-agent
That’s it. Your agent is live. For more advanced setup, Nginx reverse proxy, custom domains, monitoring dashboards, and zero-downtime deploys, check the detailed deployment server guide.
Related Posts
- AI agent deployment guide: from localhost to production. Docker containerization, cost controls, monitoring, and the full deployment checklist
- AI agent deployment server setup. Production-grade VPS infrastructure with Docker Compose, Nginx, SSL, and CI/CD
- How to build your first AI agent in 2026. A step-by-step tutorial from scratch, building the core loop and tools
This article was published on Agentic Up (https://agenticup.dev): practical guides for developers and founders building with AI agents. Reach me at [email protected].