📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Deploying Billions of AI Agents is Easier than You Think

Cole Medin19:39

Transcription

Recently, in an interview, Mark Zuckerberg, the founder of Meta, made a prediction that in the near future, there are going to be billions of agents running out in the wild—literally more than the number of people walking on this Earth.

It might seem like a bold claim, but that is what we're going to talk about today. But first, check out this clip:

"I think we're going to live in a world where there are going to be hundreds of millions, billions of different AI agents eventually—probably more AI agents than there are people in the world. We just don't believe that there's going to be kind of one big AI, whether it's a product or a model that uses. We kind of fundamentally believe in having this broad diversity in different sets of models, and that, you know, every business and people are just going to want a lot of their own stuff that they're going to make. I think that that's kind of going to be interesting. It's going to be a lot of what makes this interesting."

And he isn't wrong. In fact, he is spot-on, especially considering just how easy it is to deploy and scale AI agents in a very configurable way.

Imagine a world in the future where businesses have a core set of AI agents to pick from, built by people like you, and have them deployed and customized to their needs instantly. I'm talking dozens or hundreds of agents for millions of different businesses. That is the billions of agents that Mark is talking about.

Now, I'm not going to give you some grandiose introduction where I deploy hundreds of agents at the same time, but what I am going to show you in this video is how simple it is to really take an AI agent and deploy it into the cloud in a scalable way.

A lot of people, maybe yourself included, build your AI agents on your computer, but then when it's time to bring it into the cloud, you get intimidated, and it seems very difficult to actually take your agent into production and scale it for multiple businesses.

But I'm going to show you that with the certain setup that I'm going to walk you through, it's actually really easy. This is going to be a super practical guide for you if you're looking to deploy your agent.

But also, my goal here is just to get your imagination going—taking this kind of process and seeing how much you can extend it to really make it so that you can partake in building the billions of agents that are going to take over the world, probably in the near term.

And it is all revolving around my favorite tool for deploying code, which is Docker. If you don't love Docker by the end of this video, I am not doing my job right.

Also, what we're deploying today is the GitHub agent that we've been working on as part of the miniseries covering my full process for building AI agents because this video is a part of that series.

So, this agent can consume entire repositories for code Q&A, and now we are bringing it to the cloud. The best part is we're going to be doing it completely for free to get started. Super exciting stuff! Let's go ahead and dive right into it.

All right, so let's set the stage here a little bit, and then we'll dive into getting things set up with Docker. I'll show you how easy it is to deploy this to the cloud, and I'll even deploy the front end that we built in the last video in the series to the cloud as well.

So, this is our GitHub agent right here that we've been building with Pantic AI, which is my favorite agent framework right now. We have these tools defined for it to get the metadata for a GitHub repository, to get the file structure of it, and then, of course, we have our tool to get the contents of specific files.

Using all these tools together, that is how our agent is able to analyze code and answer questions that we have about a repository that we give it the URL to.

In this series, we created an API endpoint for our agent with FastAPI, that way we have an endpoint for our agent that we can hit with a front end. I showed early in the series how to use Agent Zero, which is my platform I built for you on the Live Agent Studio, to instantly have a front end for any agent that you run locally.

We also showed in the last video in the series how to create your own custom front end. We did that with Lovable and Bolt. DIY.

So, we got our endpoint here. This is all nice; we have everything ready to deploy in the cloud as an API endpoint. But this is where we get to the difficult part.

Everything's running locally, and it's running great. I mean, I've got it open in my terminal right here. I can even go to Agent Zero and test it out.

So, I'll paste in this prompt that I have ready for it here, asking it to describe the Bolt.DIY GitHub repository, and it's hitting our agent. Things are working well; it's calling the tools, and it got the answer for us. This is working absolutely phenomenally, but it's all running locally.

At some point, I want to actually deploy it to the cloud. That's what we're going to be doing right now. But there's an issue here. We have to make sure that the machine that we are deploying this API to has the right version of Python and the right packages installed.

There are things that we have to do before we can just go ahead and run our endpoint script right here to host our agent.

At this point, you might be thinking, "What the heck, Zuckerberg? How can you have billions of agents out there when all these machines need to have everything configured exactly right for your agents? And if a machine goes down, you've got to spin up another one to make sure that it has everything set up. What if you want to run on a serverless architecture, and it doesn't support your database driver by default, so there's not a way to install that? How do you just manage everything for your agent?"

It can seem kind of difficult to get all this set up when you have all these prerequisites for your agents—even simple things like Python and your packages.

If only there was a way to package everything together in a neat way where you have this deterministic set of steps to get everything set up for your agent and then execute it at the end.

So, you have this perfect little isolated environment that you can put anywhere, and it'll work really on any platform with any architecture. And that is where Docker comes in.

Take a look at this. It's basically exactly what I just said we need. We have a set of steps right here that sets up everything in this isolated environment. You can kind of think of it as its own private little computer that has just what you need for the agent installed, and then it even runs the agent at the end right here with our FastAPI endpoint.

A huge bonus to setting this up, besides just making it so you can really deploy this anywhere, is that you can use an AI IDE like Cursor or Wind Surf to define all of the steps to create your agent in code.

That way, you don't have to create some external process to go into a server and run these commands one at a time. You can actually do this in code and have AI help you create it.

I did not create this Docker file myself; I just used Wind Surf to make it. I'm going to be honest, and that's why I'm not going to go through some in-depth guide right now for how all these commands work. I mean, I do understand that, but right now the focus is just using this Docker file I created with AI and using it to deploy our agent.

With this, we basically have this little virtual machine running our agent that a lot of different platforms support. So, that's what we're going to do right now—take this Docker file, go over to one of those platforms, and I'll show you just how easy it is to deploy this and scale it.

I'll talk about how you could deploy it to other types of platforms as well.

All right, so the first thing that I do before I ever deploy a Docker container to the cloud is I test it locally, and I'd highly recommend that you do the same. Just like with any other code that we create, we want to make sure that there's nothing wrong in our Docker file—especially because we're using AI to create it here.

I mean, that's what I did, and I'd recommend doing it. We want to make sure it didn't hallucinate anything. The worst thing is when you have an error when you deploy in the cloud, and you don't actually know if it's because of your cloud configuration or because there actually is an error in your code.

So, you want it running locally perfectly first, then deploy it into the cloud.

We're going to build and run the container using Docker Desktop. So, just go to docker.io, file this updated README, and all the code for the agent I'll have in a GitHub repository, which I'll have linked in the description of this video, so you can download this and follow along completely as well.

I'm going to go ahead and take this command right here to build the container with Docker. Just a very simple command to build. I'm in the directory right here that we're seeing in VS Code, which is why I have a dot for building in the current directory.

So, it'll find the Docker file in the current directory, and for me, it built instantly just because I already have things cached. I built this when I was prepping the video, obviously for you.

When you run it the first time, it'll take a little bit because it's going to run all of these commands here to get that perfect environment set up for exactly what your AI agent needs. The thing that'll take the most time is installing all of the Python packages for your agent.

Then, going back to the README here, we can now run this command to spin up our container. So, I'm going to copy this, go back into my terminal—uh, hold on, let me copy it right here.

All right, there we go. Now I'll go into my terminal, paste this. We're exposing port 8001 because that is the port for our AI agent endpoint, and then passing in the ENV file because obviously our agent needs the ENV file just like when we run it outside of our container.

So, I'm going to run this, and the output that we get from FastAPI looks just like what we usually see, but now that it's all running within the container itself. You can go to Docker Desktop and actually check that out yourself too.

So, I'm going to go back over to the Agent Zero front end and make sure that things are still working now that it's running within the container.

So, I'm just going to do a little test message this time and make sure that everything's still working. I just want a fast response, and there we go—it's working well.

If I go back to my terminal, we got the output right here from the Pantic AI agent. Things are looking great, so we know that everything is working perfectly now locally.

Now we can go and take the same little isolated machine and deploy it to the cloud. Because it is this isolated environment that we set up exactly for our agent, we have absolute certainty that since it's working locally, it will also work no matter where we deploy it in the cloud.

Whether we do server deployed on a dedicated server, it doesn't matter because it's all running the same Docker container. That is the beauty of Docker and what makes it so scalable and so easy to deploy.

So, let's go ahead and do that now.

There are a million different ways to deploy Docker containers in the cloud. I mean, you can go serverless with AWS or Google Cloud, or go to Digital Ocean, use their app platform or their droplets like you might have done with n8n. There are so many options for you because of how flexible Docker containers are.

For this video specifically, I chose Render. I'm not sponsored by them in any way; this is just the one that I found the easiest to deploy Docker containers, as you'll see in a little bit.

Also, they have a free tier, which just makes it so easy for you to get started. You can use their free tier for both the Docker backend for the agent that I'm about to show you and then also deploying the front end that we built in the last video in the series.

I'll show you how to do that at the end as well. There's also great documentation for deploying Docker on Render that I'll have linked in the description. They just have great documentation in general, which is another reason that I picked them.

To actually get started deploying, you'll go to your dashboard—just dashboard.render.com. It does that intelligent determination for you—very, very convenient.

I'm going to select the main branch; it's there by default. You can pick the region that's closest to you or your customers, leave the root directory the same, and then for the instance type, we're just going with the free tier right now.

Take note of these limitations, but it is a great place to get started. For the environment variables, this is one of the best parts of Docker. You can use environment variables to determine how things are built in the Docker file, and also this is how you can get things configured differently to have your AI agent set and customized to different clients or businesses or departments of your business—whatever it might be.

I'm going to be adding in my environment variables this way, just copying in from my ENV file. But before I do that, I just want to speak a little bit to this.

This is one of the things with Docker that makes it so scalable. You can have environment variables here that you deploy for different instances. Like, I can go on Render right here and have one instance for an agent for my sales department and then another agent that is the instance for my marketing department.

They can have environment variables set to determine different things with the agent to make it behave differently and customized to the people that are actually using that agent.

That's another part of what makes it so that you can have these Docker agents that can scale so well. You use environment variables to configure them essentially.

So, what I'm going to do here is pause the video, enter in all my environment variables that I have locally, and then come back once that is done.

All right, environment variables are set. I'm not going to go over all these in detail because I cover that in other videos in the series here, but the important thing is it was super easy to bring in.

This is how you can configure so much different behavior with your agent if you are using your environment variables well.

Then, for the advanced section here, there is nothing that you have to change. We have already set up everything that we need. It's so easy with Docker because it's the Docker file that's really instructing how you get this instance set up for exactly what your agent needs and all of those dependencies.

I'm going to go ahead and click on deploy web server. Now, once you go into the view here where it shows the build logs, you can watch everything in real time as it's pulling the code from GitHub, running your Docker file to build and serve your agent and the API endpoint for it.

I'm going to pause and come back once it's done with this entire setup here.

Took about five minutes, and now our AI agent endpoint is live on Render. Take a look at this; we got the output very familiar to us. This is exactly what we saw in our terminal running locally, and we got this nice little message saying our service is live.

Now we can go ahead and test this out. So, I'm going to go back over to Agent Zero and test it, and then we'll get into deploying the front end on Render as well.

So, I'm going to copy this link right here, go back over to Agent Zero, start a new conversation. Let me open up the settings right here. The only thing I have to change, because I set everything else the exact same for Supabase and everything, is the URL here.

So, I'm going to replace the localhost with what we have from Render here. So, we got this special Render URL, and you can configure this to be your own domain and everything. I mean, all the flexibility you would need in Render, you've got.

Then it's going to be the same extension here/API and Pantic GitHub agent. So, I'll go ahead and click on save; it'll refresh, and I'll have a new conversation.

Yeah, let's actually—let me just go back and steal the same question here. I'll just use the exact same question to make sure that things are working well.

So, we'll send this in right here, and then we'll go back over to Render and make sure that it's actually talking to our agent. And there we go—yep, we got a new request out to our agent, and it looks like it had to—oh yeah, there we go.

All right, yeah, it took a little bit; there's a bit of a delay there, but yeah, we got the response here. So, it got the repo info, ran that tool back over Agent Zero, and we have a response.

So, this is working perfectly. It took like five minutes, and we have the Docker container running up on Render already.

There are so many ways that you could take this forward by creating load balancing or deploying to serverless architecture or getting more Render instances spun up to scale your agent horizontally.

Or you could go up in your instance size to scale it vertically. There are so many more things that I want to get into in other videos on my channel, but this is a fantastic starting point just showing you with Docker how easy it is to deploy any AI agent you could possibly build.

All right, last thing we want to do really quick is deploy the custom front end that we built in the last video in this series to Render as well.

So, just as a refresher here, we got this GitHub repository, and it's very simple. We just started with Lovable, built our app there, and then moved it into Bolt.DIY to do a bunch of improvements with Gemini for free.

I didn't change anything in this project from when we last worked on it besides a couple of changes here for the environment variables. So, I just used Wind Surf again, just using an AI, and it's not just a cop-out so I don't have to explain it.

I just don't want to spend more time explaining this than literally what it took to make this change itself. But I have all these environment variables defined here that are used within the code so that within my Render deployment, I can set the environment variables for Supabase and the endpoint that we want to hit because we're going to set this to be the API URL for our AI agent hosted on Render as well.

With these changes, and they're all pushed to the GitHub repository, which I'll have linked in the description as well, we can go back over to Render and deploy our page.

First of all, this is built with Vite and React. That's typically what Lovable and Bolt will spit out for you is a React plus Vite application.

In the Vite documentation for Render, it says specifically to create a static site. So, we used a web app for the backend, and you'll use a web app for single-page applications and dynamic applications, but Vite just spits out static content.

So, we're going to deploy a static site, and then they give some instructions for your build and publish command as well.

So, back over to Render, add a new static site, just pick the GitHub repo again. Here we go, pick and connect. It's going to automatically recognize it as Node now instead of—let me just add a new name because I already deployed it once.

Yeah, so it recognized that it is Node. We're using the main branch, and then for my install command, we want to run this command right here: npm install and npm run build.

Then the publish directory is just default to dist, and that's just following these instructions right here in the Vite guide. That is it.

Now we just have to set our environment variables. So, going back to the change that I made in GitHub here, we have the VITE_API_URL. So, that is going to point to our instance that we have for the AI agent in Render.

Specifically, I'm just going to copy exactly what I used in Agent Zero. So, this is my endpoint right here—super easy.

The only other two variables that we have to add here are the VITE_SUPABASE_URL and then also we have the SUPABASE_PUBLIC_KEY.

So, I'm going to go ahead and add these off-camera, and I'll be back once that is there, and then we'll deploy it.

All right, got our environment variables set up, and that is everything that we need. So, just like the backend with Docker, super, super simple. Nothing in the advanced settings we have to care about.

So, I'm going to go ahead and click on deploy static site. This will take just a little bit here; it's super fast with React and Vite, and I'll be back once it is done.

Thirty seconds later, and we are good to go. So, I'm going to go ahead and click on this URL, and that is going to take us to our site—exactly what we had running locally that we built in the last video in the series here.

So, I'm going to go ahead and send a message here just saying hello, just to test and make sure that everything is working with both the front end and the agent hosted on Render.

Boom! We got a response, so this is working perfectly. We now have our AI agent in a Docker container that we can deploy anywhere, scale really easily, just using Render as an example, and we've got the front end deployed as well.

So, everything is in the cloud now. We did it all in just minutes—super exciting stuff!

With that, we have deployed our AI agent and proof of concept front end to the cloud, and it was a piece of cake.

I hope that this guide made it very clear for you how to deploy agents and also got your wheels turning just seeing with Docker how easy it is to scale and deploy your agents and really get an infinite number of them up and running.

With containers and having your agents in this little isolated environment that you can put anywhere, it just gives you so many options and so much flexibility.

Also, for this AI agent series, I've got some more content coming soon that you don't want to miss. We're going to be taking the GitHub agent and extending it with RAG, and also I'll be showing you how to monetize an AI agent using our GitHub guide as an example.

So, if you appreciated this content and you're looking forward to more things building AI agents, I would really appreciate a like and a subscribe.

With that, I will see you in the next video.