Put your AI Agents on a VPS… trust me artwork

Put your AI Agents on a VPS… trust me

David Ondrej

December 5, 2026

0:00

David Ondrej

My name is David Ondrej, and in this video, I'll show you how to self-host your AI agents. Self-hosting means running your application on a server that you control. The alternative is cloud-hosted solutions, or SaaS, both of which mean someone else controls the server for you. Now, there are many benefits to self-hosting. First, you have full control over your data and over the privacy. Second, it's usually way more affordable than cloud-based solutions. And third, you avoid ecosystem lock-in. So if you wanna move your AI agent elsewhere, you can do so very easily. So here's the plan, first, I'll show you how to build a simple AI agent in Python. Second, we will SSH into a virtual private server. And third, I'll show you how to deploy that AI agent onto your VPS. I'll show you the VPS option, because not only is it the most convenient, it's also the most scalable and the most affordable type of self-hosting. Now, you might be thinking, but David, what even is a VPS? A VPS stands for Virtual Private Server, and it's a remote Linux server with its own RAM, its own CPU and storage on a shared machine. So to deploy your AI agent on your Virtual Private Server, first we need an AI agent. So let me show you how you can build your own first agent in Python. You don't need any framework, nothing like that. We're gonna use AI to do the coding for us. So you can do this even if you're a complete beginner. So let's jump into Cursor and let's open an empty project. You can use either Cursor, Codex, Cloud Code, whatever AI agent you want. We're basically gonna one-shot this, right? So my goal is to build a simple agent and to show you how to deploy it. So first off, I'm gonna create a Markdown file named buildidea.md, and I'm gonna paste in the build idea. And as you can see, it's very simple. An AI agent that runs on a daily cron scrapes the hacker news front page and saves the top 10 posts into a Markdown file. You can review this weekly, monthly, doesn't matter. This agent will always be running on your VPS, no matter if you check it or not. So all you need to do is give it a list of commands and a list of times, and it will run those commands on those times. Anyways, let's jump back into the IDE, and I'm gonna be using Codex, because right now it's one of the best coding agents in the world, I think it's better than Cloud Code. So let me expand the left side, and all I'm gonna do is type in, build a simple project folder structure for the build idea in, and then I'm gonna tag the markdown file. The goal is to then deploy this agent on a VPS. So let's use Python only. Boom, pure English, you don't have to be a professional developer. These AI agents have gotten so good over the past year, it's actually kinda crazy. And you can see that on the right, we already start seeing some of the folders, right? We have the data, scripts, and SRC. We also have the ENV file, in which I pasted in my password for the SSH server, but more on that in a bit. And then we have the build idea.md. And as you can see, Codex is already creating these Python files and it's working very fast. I'm gonna explain the concept of Hacker News. This is a kind of a news site that usually shows you stuff that's happening in the software and startup space. And by the way, you can use the same type of AI agents to scrape any website, whether that is archive for really interesting AI or machine learning research papers, whether that is Twitter for what's trending, or any other site you want. What I'm about to show you is very versatile, so feel free to adapt it for your own use case. Anyways, Codex has finished building. So as you can see, it created like eight different Python files, each of them being very short, like 20 to 30 lines. So then I'm gonna ask it, tell me how I can test this project here locally, answer in short. All right, so first we need to activate a Python environment. It's suggesting me to create a virtual environment, but instead I'm gonna use Conda. So we do Conda, activate testing. Then I'm gonna do pip install-r requirements. I'm just following the instructions that Codex is giving me. So this will install all of the dependencies of this project. And then the last thing we have to do is type in Python script slash run digest. This is the Python file that will run the digest, and boom, there it is. Yeah, these are the top 10 posts. One shorted, no errors, no issues. The AI agents are getting too good at this. Now, this is already very useful. We have an automatic way to scrape hacker news every single day, but to make it an AI agent, we need to add another layer on top of it, using an LLM, that extracts some useful insights from this. So since this is a bunch of context, I'm leaning towards using a reasoning model to give us actually useful thoughts, rather than just a typical non-reasoning model. So for something like this, I'm gonna switch to Perplexity, I'm gonna switch to Deep Research, and I'm gonna ask it, read the official OpenRouter docs, and tell me how I can use GPT 5.1 thinking with medium reasoning effort. And now Perplexity is gonna do the Deep Research, and honestly, you can use ChatGPT as well. Claude, Gemini, it doesn't really matter. Perplexity just has a very balanced Deep Research that doesn't take too much time, but still checks 40, 50 sources to give you a detailed response. Then what I'm gonna do is, while that's running, inside of Cursor, I'm gonna create a new folder named .docs. In there, I'm gonna move our build idea, I'm gonna create a new file as well, name it OpenRouter.md, and in here, I'm gonna paste in the research findings from Perplexity so we can easily tag the file anytime and reference it. Now, since our project already works, what I'm gonna do is I'm gonna initialize a new GitHub repo, git init, boom. Then I'm gonna stage everything. I actually know, first thing we have to do is create a git ignore. So I'm gonna go back into codecs and tell it, create a comprehensive git ignore for this project. And the reason for that is we have an environment variable, right? So here we're gonna put all our secrets and EMV variables, such as OpenRouter API key as well. And this needs to be ignored by git. You do not wanna track your environment variables by git, that is a very bad habit. Then I'm gonna do another git command, git add dot to stage everything, and then I'm gonna do git commit dot em, first commit. Boom, that way we can track everything through git, even if we don't use GitHub, we're just gonna keep it simple for now. Anyways, let's see, Perplexity has finished, I'm gonna click copy, scroll all the way down, click the copy button, switch back to our IDE, paste it in into the empty markdown file, save that. And then I'm gonna go back to Codex, and I'm gonna say, read openrouter.md, and update our project so that after we scrape the Hacker News front page, we will run a single API call to GPT 5.1 Thinking, telling it to analyze these Hacker News stories and extract actionable insights and trends in the AI space from that data. And then we append the response from the LLM into the same MD file. So this is gonna convert a simple scraper into an actual AI agent that can generate unique insights from this data. And obviously, as the new stories on Hacker News change, this will be collecting different trends. So even if you take two weeks off, and you kind of feel that, okay, maybe you might be out of sync with what's happening in the AI, maybe you think that you're falling behind, you can just check your VPS, and you will have 14 different reports, each of them telling you what are the latest things happening in AI, so you can get up to speed super fast. And it doesn't take a genius to see how we could build top of this and make it a lot more powerful. But if you watch until the end, you will have the necessary skill set to not only build AI agents, but to self-host them on a VPS. So really, if you sit down for the next 10 minutes and pay attention, you will be far ahead of everybody else. Okay, so it seems like Codex has finished the updates, so what I'm gonna do is I'm gonna again stage everything, and I'm gonna do another commit, git commit, add it, llm processing. Boom, this is a very good habit for any projects that are gonna develop for more than two hours. Initializing a git repository makes sure that even if the AI agent messes up something, you can simply go back to the previous commit. Okay, so before we deploy the agent to our VPS, let's just do one quick test locally to make sure it runs. Tell me how to test this locally. All right, so we probably need to reinstall requirements.txt, because we have some new dependencies, such as the OpenAI SDK. Then, actually we need to change, because it wants me to export the API key, but we already have the environment file, so what I'm gonna say is change the code to use the .env file from root folder. In the meantime, we need to switch to OpenRouter. Top right, click on keys. If you don't have an OpenRouter account, just log in with your Gmail or your GitHub. Super fast, super simple, takes 20 seconds. Then go to top right, click on keys, create API key. I'm gonna name it subscribe. If you're watching this, make sure to subscribe. It takes two seconds and it helps out a lot. And I'm gonna click on create, boom, copy that. Do not share your API keys with anybody. Treat them as passwords. They should be completely private. Then make sure to hit command S to save. Our codex already finished because it's very fast. So what we need to do now is rerun this command. Python, execute this Python file basically. So I'm gonna clear the terminal and run it again.

Read the other 13 minutes of this episode here.

$15 gets you this episode and 99 more. Credits never expire. After checkout, one link brings you back here to read it.

Not what you expected? Full refund within 14 days.

Thousands of transcripts fetched by people building searchable podcast archives

Fetch transcripts with code

The same credits work from a script or an AI agent. The demo key returns a sample episode in full, no card needed:

request
curl -H "x-api-key: pt_demo" \
  https://spoken.md/transcripts/1000651996090

Markdown with the speakers named, for your notes, your knowledge base, or anything that makes HTTP calls.

From $0.10 per transcript. No subscription. Credits never expire. Prices exclude VAT, added at checkout for EU customers. Not what you expected? Email us within 14 days with 20 or fewer credits used and we refund the pack in full.

Using your own key:

request
curl -H "x-api-key: YOUR_KEY" \
  https://spoken.md/transcripts/1000805807380