Deploying Your AI Agent › Deploying to the Cloud

Michael BrenndoerferAugust 18, 20252 min read
AI Agent HandbookAll chapters
Part 14 of 15Deployment and Operations - From Prototype to Production
Chapter 39Deploying Your AI Agent › Deploying to the Cloud
Reading section 6 of 10 · Deploying to the Cloud · 2 minSection 6 of 10 · 2 min

Book contents

Section 6 of 10 · 2 min read

Deploying Your AI Agent › Deploying to the CloudOne section · Sections in this chapter6 / 10 ↓

For cloud deployment, you have many options. Let's walk through a straightforward path using a platform-as-a-service provider, which handles much of the infrastructure complexity for you.

Preparing for Cloud Deployment

First, add a file that tells the platform how to run your application. For example, if using Heroku, you'd create a Procfile:

web: python assistant.py

Or if you're using Docker (a containerization tool that packages your app with all its dependencies), you'd create a Dockerfile:

FROM python:3.11-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

CMD ["python", "assistant.py"]

This Docker container includes everything your agent needs to run, making deployment consistent across different environments.

Deploying to a Platform

Most platforms follow a similar pattern:

  1. Create an account and a new project
  2. Connect your code repository (GitHub, GitLab, etc.)
  3. Configure environment variables (your API keys)
  4. Deploy with a single command or button click

For example, with Railway:

In[2]:
Code
railway login
railway init
railway up

The platform builds your application, starts it running, and gives you a URL where it's accessible. Your agent is now live on the internet.

Monitoring and Logs

Once deployed, you need visibility into what's happening. Most platforms provide logs you can view in their dashboard or via command-line tools:

In[4]:
Code
railway logs

These logs show your agent's output, including any errors or debugging information you've added. This is where the observability techniques from Chapter 12 become essential. By logging key decisions and actions, you can diagnose issues even when you can't directly interact with the running agent.