Deploying Your AI Agent › Deploying to the Cloud
AI Agent HandbookAll chapters 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.pyOr 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:
- Create an account and a new project
- Connect your code repository (GitHub, GitLab, etc.)
- Configure environment variables (your API keys)
- Deploy with a single command or button click
For example, with Railway:
railway login
railway init
railway upThe 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:
railway logsThese 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.