This guide walks you through hosting a Swarms agent on Google Cloud Run — a fully managed container platform that auto-scales from zero. The setup uses a slim Docker image, anDocumentation Index
Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
Use this file to discover all available pages before exploring further.
api/api.py Flask endpoint, and gcloud for deployment.
Project structure
Step 1: Prerequisites
- Google Cloud account — sign in at console.cloud.google.com and enable billing on a project.
- gcloud SDK — install via the official guide.
- Docker — install via the Docker docs.
- Project — create a new Google Cloud project and note the Project ID.
- APIs — enable the following in the API Library:
- Cloud Run API
- Cloud Build API
- Artifact Registry API
Step 2: Build the agent
api/api.py
requirements.txt
Dockerfile
Cloud Run sends traffic to port
8080 by default — keep that as the listening port.Step 3: Authenticate
Step 4: Push the image to Artifact Registry
Step 5: Deploy to Cloud Run
--allow-unauthenticated makes the service publicly reachable. Drop it to require IAM-authenticated calls.
Step 6: Test the deployment
Cloud Run prints a URL after deploy. Hit the endpoint:Step 7: Update the service
Iterating is just rebuild → push → redeploy:Troubleshooting
- Permission errors — your account needs the Cloud Run Admin and Artifact Registry Reader roles.
-
Port issues — Cloud Run expects port
8080. Make sure your Flask app binds to it. -
Logs:
Source: docs/swarms_cloud/cloud_run.md
See also
- Deployment Solutions Overview — when to pick Cloud Run vs cron jobs vs Kubernetes.
- FastAPI Agent API — alternative API stack using FastAPI + Uvicorn.
- Cloudflare Workers — edge deployment pattern for cron-driven agents.